Interface BodyValidator<T>

Type Parameters:
T - type of value checked
All Known Subinterfaces:
Validator<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.

@FunctionalInterface public interface BodyValidator<T>
Checks a decoded request body for Context.validatedBody(Class, BodyValidator).

The optional axiom-validation module's Validator extends this interface, so its rule sets and the Jakarta Validation adapter can be passed directly; a lambda works too.

Thread safety and ownership. One instance is typically shared by every request, so implementations must be thread-safe and must not retain the value. Violations are sent to clients: fields and codes must come from developer-defined names, never from the value or any other client input.

  • Method Summary

    Modifier and Type
    Method
    Description
    validate(T value)
    Checks a value.
  • Method Details

    • validate

      List<Violation> validate(T value)
      Checks a value.
      Parameters:
      value - value to check; never null when called by validatedBody, but other callers (such as Validation.require) may pass null
      Returns:
      violations, empty when the value is valid; never null and without null elements (callers fail with IllegalStateException otherwise)