Interface Validator<T>

Type Parameters:
T - type of the object to be validated
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 Validator<T>
A generic validator, has a method to validate the object and add messages to a Errors.Collector. Simple example:
    Validator<String> validator = (str, collector) -> {
         if (null == str) {
             collector.fatal("String must not be null");
         }
     };
     Errors.Collector collector = Errors.collector();
     validator.validate("string", collector);
     // would throw an exception if invalid
     collector.collect().checkValid();
This interface is used by JwtValidator.Builder and EncryptedJwt.validate(java.util.List).
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    validate(T object, Errors.Collector collector)
    Validate the object against this class's configuration.
  • Method Details

    • validate

      void validate(T object, Errors.Collector collector)
      Validate the object against this class's configuration.
      Parameters:
      object - object to validate
      collector - collector of error messages to add problems to. Use Errors.Collector.fatal(Object, String) to mark the validation as a failure