Interface Validator<T>

  • Type Parameters:
    T - type of the object to be validated
    All Known Implementing Classes:
    Jwt.ExpirationValidator, Jwt.FieldValidator, Jwt.IssueTimeValidator, Jwt.NotBeforeValidator
    Functional Interface:
    This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

    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
    See Also:
    • Method Detail

      • validate

        void validate​(T object,
                      Errors.Collector collector)
        Validate the object against this class's configuration.
        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