> ## Documentation Index
> Fetch the complete documentation index at: https://validity-kt.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Modules

> What validity-core and validity-phone hold, how to add them, the imports they need and how their versions move.

Validity is two modules on Maven Central, under the group `io.github.soleworks`, released together and always at the
same version, so a project that uses both never mixes versions:

| Module | What it adds | Depends on |
| - | - | - |
| `validity-core` | The DSL, the four entries and every constraint but the phone ones | The Kotlin standard library and kotlinx.coroutines |
| `validity-phone` | `phone`, `mobilePhone`, `countryCode` and `areaCode`, and their messages | `validity-core` and Google's libphonenumber |

Most projects need only `validity-core`.

## Add the dependency

```kotlin build.gradle.kts theme={"theme":"css-variables"}
implementation("io.github.soleworks:validity-core")
```

```groovy build.gradle theme={"theme":"css-variables"}
implementation 'io.github.soleworks:validity-core'
```

For phone numbers, add `validity-phone` too, at the same version:

```kotlin build.gradle.kts theme={"theme":"css-variables"}
implementation("io.github.soleworks:validity-phone")
```

```groovy build.gradle theme={"theme":"css-variables"}
implementation 'io.github.soleworks:validity-phone'
```

> [!WARNING]
>
> Validity is not on Maven Central yet: the first release is on its way. Until it lands, clone the
> [repository](https://github.com/soleworks/validity) next to your project and add `includeBuild("../validity")` to
> your `settings.gradle.kts`. Gradle then builds the dependency from the clone, so the dependency names no version.
> Maven cannot build from a clone, so a Maven project waits for the release.

## Requirements

> [card] Java 17+
>
> The JVM the artifacts are compiled for.

> [card] Kotlin 2.4
>
> The version Validity is built with. It uses context parameters for its DSL.

> [card] Coroutines
>
> kotlinx.coroutines comes with `validity-core`. You do not need to add it.

## Packages and imports

| Package | Module | Holds |
| - | - | - |
| `io.github.soleworks.validity` | core | `Validatable`, `ContextualValidatable`, `validation`, `validatable`, `required`, `ifPresent`, `forbidden`, the presence rules, `each`, `valid`, `convert`, `metadata`, `Validity`, `ValidationResult`, `Violation`, `ValidationException`, `Messages` |
| `io.github.soleworks.validity.constraints` | core | The general constraints, `or`, `and`, `not`, `HashAlgorithm` |
| `io.github.soleworks.validity.constraints.<country>` | core | The constraints of one country: `argentina`, `australia`, `belgium`, `brazil`, `bulgaria`, `canada`, `chile`, `china`, `colombia`, `france`, `germany`, `india`, `israel`, `italy`, `japan`, `mexico`, `netherlands`, `norway`, `pakistan`, `paraguay`, `peru`, `poland`, `portugal`, `russia`, `slovenia`, `southafrica`, `southkorea`, `spain`, `sweden`, `switzerland`, `thailand`, `ukraine`, `unitedarabemirates`, `unitedkingdom`, `unitedstates`, `uruguay` |
| `io.github.soleworks.validity.phone` | phone | The phone constraints, `PhoneFormat`, `PhoneMessages` and `Messages.phone` |

```kotlin theme={"theme":"css-variables"}
import io.github.soleworks.validity.*                        // Validatable, validation, required, each, ...
import io.github.soleworks.validity.constraints.*            // email, minLength, positive, ...
import io.github.soleworks.validity.constraints.brazil.*     // cpf, cnpj, cep, ...
import io.github.soleworks.validity.phone.*                  // phone, mobilePhone, ... (validity-phone)
```

Your IDE adds them for you when you complete a constraint.

## Why phone numbers are apart

libphonenumber is large and holds the numbering plans of every country. Keeping it out of `validity-core` means a
project that never validates a phone number does not ship it. A module adds its messages to the configuration without
the core knowing it, through `MessagesKey`, the same way [your own constraints](https://validity-kt.dev/guides/messages.md#messages-of-your-own-constraints)
can.

## Versions

Validity follows [Semantic Versioning](https://semver.org). While the version is `0.x`, a breaking change raises the
minor version, so moving to the next minor version may ask you to change your code. The
[changelog](https://github.com/soleworks/validity/blob/main/CHANGELOG.md) says what to change.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.