Class Validator

java.lang.Object
dev.relism.flash.ext.jackson.Validator

public final class Validator extends Object
The compiled constraints of one type. Built once per class and reused for every request.

verify(java.lang.Object) allocates nothing when a value passes: the loop walks an array (no iterator), reads fields through exact-signature MethodHandles (no boxing, no argument array), and compares against operands resolved at compile time. The violation list and the exception are constructed only once something actually fails.

  • Method Details

    • of

      public static Validator of(Class<?> type)
      The constraints of type, compiled the first time it is seen and reused after.
    • check

      public static <T> T check(T value)
      Verifies a value against its own type's constraints.
      Returns:
      value, so it can be used inline
      Throws:
      ValidationException - 422, listing every failure
    • isEmpty

      public boolean isEmpty()
      True when the type declares no constraints at all — verify(java.lang.Object) is then a no-op.
    • verify

      public void verify(Object target)
      Verifies every constraint on target.
      Throws:
      ValidationException - with all failures, never just the first