Scala

Validation and more, published on Maven Central.

Scala 3 brought inline metaprogramming, Mirror types, opaque types, union and intersection types, and strict equality. These are not just language features. They change what you can express at compile time and what the type system can prove for you. Valar leans on this throughout, deriving validators through the type system at compile time. Published on Maven Central.

Valar

0.6.0

Type-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