> ## 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.

# Installation

> Add Validity to a Gradle or Maven project.

Validity is two artifacts on Maven Central, under the group `io.github.soleworks`, released together and always at the
same version:

| Artifact | What it adds | Depends on |
| - | - | - |
| `validity-core` | The DSL and every constraint but the phone ones | kotlinx.coroutines |
| `validity-phone` | `phone`, `mobilePhone`, `countryCode` and `areaCode` | Google's libphonenumber |

Most projects need only `validity-core`.

## Add the dependency

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

```groovy build.gradle theme={null}
implementation 'io.github.soleworks:validity-core:0.1.0'
```

```xml pom.xml theme={null}
<dependency>
    <groupId>io.github.soleworks</groupId>
    <artifactId>validity-core</artifactId>
    <version>0.1.0</version>
</dependency>
```

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

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

```groovy build.gradle theme={null}
implementation 'io.github.soleworks:validity-phone:0.1.0'
```

```xml pom.xml theme={null}
<dependency>
    <groupId>io.github.soleworks</groupId>
    <artifactId>validity-phone</artifactId>
    <version>0.1.0</version>
</dependency>
```

> [!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.

## 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.

## Imports

The DSL lives in `io.github.soleworks.validity`, and the constraints in `io.github.soleworks.validity.constraints`.
The constraints of a country have a package of their own, and the phone constraints live in the phone module:

```kotlin theme={null}
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.

## 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.

> [card] [Next: validate your first class](https://validity-kt.dev/quickstart.md)
>
> Declare the rules of a class and read its violations.


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