Interface Validator<T>
- Type Parameters:
T- type of value checked
- All Superinterfaces:
BodyValidator<T>
- All Known Implementing Classes:
JakartaValidation,Rules
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Implementations must be thread-safe and must not retain the value. The returned list is empty
when the value is valid; otherwise it holds at most Validation.MAX_VIOLATIONS violations
whose fields are property paths built from developer-defined names and element indexes and whose
codes are fixed machine-readable strings. Violations are sent to clients, so they must never
contain the checked value or any other client input (no map keys, no messages). An implementation
that fails internally should throw an AxiomException,
typically InternalServerErrorException, whose response carries
no internal detail; other exceptions reach the server's generic 500 handling.
A validator is also core's BodyValidator, so it can check request bodies directly:
ctx.validatedBody(Order.class, ORDER).
-
Method Summary
Modifier and TypeMethodDescriptionReturns a validator that runs this validator and thenother, keeping the first occurrence of each violation and stopping onceValidation.MAX_VIOLATIONSare collected (later validators are then not run).Checks a value.
-
Method Details
-
validate
Checks a value.- Specified by:
validatein interfaceBodyValidator<T>- Parameters:
value- value to check; may be null, but never null when called byctx.validatedBody- Returns:
- immutable or caller-owned violations, empty when the value is valid; never null and
without null elements (callers fail with
IllegalStateExceptionotherwise)
-
and
Returns a validator that runs this validator and thenother, keeping the first occurrence of each violation and stopping onceValidation.MAX_VIOLATIONSare collected (later validators are then not run).- Parameters:
other- validator to run second- Returns:
- combined validator returning an immutable list
-