Validation DSL
Declare rules for properties, collection elements, map keys and values, and no-argument functions alongside each type's graph, selecting members by reference or applying rules to all of them at once.
Declarative validation of whole object graphs, with every failure reported at its path.
Declare rules for properties, collection elements, map keys and values, and no-argument functions alongside each type's graph, selecting members by reference or applying rules to all of them at once.
Rules for strings, collections, maps, comparable values, booleans and any value: blank and empty checks, lengths, contents, prefixes and suffixes, regular expressions, UUIDs and Luhn checksums, counts, distinctness, exact contents, keys and entries, ranges, equality, identity and null checks.
Reuse any core Specification as a rule, or write one as a lambda, and override any rule's message. Rules can apply conditionally with whenever and otherwise, and the condition is recorded on any failure it produces.
Validation descends into nested objects, collection elements and map values that have registered graphs, applying every graph in the class hierarchy and detecting cycles. Require a nested graph to be present, or skip one where descending isn't wanted.
Results mirror the shape of the subject, with the failures at each path, and can be queried by path or wildcard pattern, checked for validity or turned into an exception.
Every failure carries its path, a namespaced rule identifier such as string.notBlank, the rule's parameters and a message, so clients can act on failures rather than parse them. Results render as tree- shaped or flat JSON with no extra dependencies.
Collect every failure, or stop at the first when that's all you need to know.
describe<T>() lists every rule that applies to a type, including conditional branches and subtypes, at wildcard paths, so rules can be documented or shown to users before anything is validated.