Valar
0.6.0Type-safe validation for Scala 3
A validation library for Scala 3 that derives validators from your types at compile time. The derivation uses inline macros and Mirror types to inspect case classes and generate validation code through the type system. If a field type is missing a validator, the compiler reports every missing one, names the fields, and tells you what to add. Validators compose in two modes: zip to collect all errors in one pass, flatMap to stop at the first. Errors are structured with field paths, so a failure in a nested object points to the exact location. Cross-compiles to JVM and Scala Native.
- Compile-time derivation through Scala 3 inline macros and Mirror types
- Both error accumulation and fail-fast, chosen by how you compose
- Structured errors with field paths, severity, and error codes
- JVM and Scala Native
val user = (
field("name", nonEmpty),
field("age", between(0, 150)),
field("email", matches(emailPattern))
).zip // collects all errors in one pass
user.validate(input)
// Structured errors with field paths