
Lightweight validation library offering a variety of validation rules and functions for input data, enhancing data integrity and consistency with easy-to-use syntax.
Valdi is a modular Kotlin library designed for validation and domain-driven design (DDD) enforcement in your Kotlin projects. It provides a powerful validation DSL, domain modeling annotations, and static analysis tooling to help you build robust, maintainable applications aligned with DDD principles.
valdi-validation-core provides a Kotlin-first validation framework centered around the concept of a Factory.
A factory validates input using a set of constraints and either produces a valid output or returns validation errors.
Constraints are defined as predicates coupled with error results implementing a marker interface for validation failures. Validation stops at the first failure, providing clear and precise error feedback.
The API exposes a simple and expressive DSL to build constraints inline, supporting both constant and lazily created errors.
val factory = factory<UserInput, User, UserError> {
constraints {
gives(UserError.EmptyName) on { it.name.isBlank() }
gives { UserError.InvalidEmail(it.email) } unless { it.email.isValidEmail() }
}
constructor { input -> User(input.name, input.email) }
}
sealed interface UserError : ValidationError { /* ... */ }
val result: ValidationResult<User, UserError> = factory.create(input)
val unsafe: User = factory.createOrThrow(input)
val nullable: User? = factory.createOrNull(input)To support Domain-Driven Design practices, valdi provides optional modules that integrate with your domain model and help enforce consistency:
The valdi-domain-core module introduces marker annotations like @ValueObject, @AggregateRoot, and @DomainEntity.
These are used to declare the role of a class within your domain model.
They do not affect behavior but serve as structural metadata.
The valdi-domain-detekt module provides Detekt rules that analyze your codebase for violations of common DDD patterns,
based on the annotations defined in valdi-domain-core.
This enables early feedback during development and helps maintain architectural boundaries.
These modules are optional and can be used independently of the validation system.
valdi is published as a set of modular libraries. You can include only what you need.
valdi-validation-core
implementation("com.y9vad9.valdi:valdi-validation-core:$version")
valdi-domain-core
implementation("com.y9vad9.valdi:valdi-validation-core:$version")
valdi-domain-detekt (Detekt plugin)
detektPlugins("com.y9vad9.valdi:valdi-domain-detekt:$version")
valdi is a Kotlin Multiplatform library with support for the following targets:
This project is licensed under the MIT License. You are free to use, modify, and distribute it with attribution.
Valdi is a modular Kotlin library designed for validation and domain-driven design (DDD) enforcement in your Kotlin projects. It provides a powerful validation DSL, domain modeling annotations, and static analysis tooling to help you build robust, maintainable applications aligned with DDD principles.
valdi-validation-core provides a Kotlin-first validation framework centered around the concept of a Factory.
A factory validates input using a set of constraints and either produces a valid output or returns validation errors.
Constraints are defined as predicates coupled with error results implementing a marker interface for validation failures. Validation stops at the first failure, providing clear and precise error feedback.
The API exposes a simple and expressive DSL to build constraints inline, supporting both constant and lazily created errors.
val factory = factory<UserInput, User, UserError> {
constraints {
gives(UserError.EmptyName) on { it.name.isBlank() }
gives { UserError.InvalidEmail(it.email) } unless { it.email.isValidEmail() }
}
constructor { input -> User(input.name, input.email) }
}
sealed interface UserError : ValidationError { /* ... */ }
val result: ValidationResult<User, UserError> = factory.create(input)
val unsafe: User = factory.createOrThrow(input)
val nullable: User? = factory.createOrNull(input)To support Domain-Driven Design practices, valdi provides optional modules that integrate with your domain model and help enforce consistency:
The valdi-domain-core module introduces marker annotations like @ValueObject, @AggregateRoot, and @DomainEntity.
These are used to declare the role of a class within your domain model.
They do not affect behavior but serve as structural metadata.
The valdi-domain-detekt module provides Detekt rules that analyze your codebase for violations of common DDD patterns,
based on the annotations defined in valdi-domain-core.
This enables early feedback during development and helps maintain architectural boundaries.
These modules are optional and can be used independently of the validation system.
valdi is published as a set of modular libraries. You can include only what you need.
valdi-validation-core
implementation("com.y9vad9.valdi:valdi-validation-core:$version")
valdi-domain-core
implementation("com.y9vad9.valdi:valdi-validation-core:$version")
valdi-domain-detekt (Detekt plugin)
detektPlugins("com.y9vad9.valdi:valdi-domain-detekt:$version")
valdi is a Kotlin Multiplatform library with support for the following targets:
This project is licensed under the MIT License. You are free to use, modify, and distribute it with attribution.