Interface Validator<A extends Annotation,VIEWT>

Type Parameters:
A - Type of the annotation that puts current validator to the field.
VIEWT - Upper bound for field types that can be validated with this validator.

public interface Validator<A extends Annotation,VIEWT>
Interface for all configuration validators. Recommended to be a stateless class.

It is mandatory that all direct implementations of the interface explicitly specify types A and VIEW.

  • Method Summary

    Modifier and Type
    Method
    Description
    default boolean
    canValidate(Class<? extends Annotation> annotationType, Class<?> schemaFieldType, boolean namedList)
    Checks whether this validator can validate a schema field with given annotation and given class.
    void
    validate(A annotation, ValidationContext<VIEWT> ctx)
    Perform validation.
  • Method Details

    • validate

      void validate(A annotation, ValidationContext<VIEWT> ctx)
      Perform validation. All validation issues must be put into ValidationContext.addIssue(ValidationIssue).
      Parameters:
      annotation - Specific annotation from currently validated value.
      ctx - Validation context.
    • canValidate

      default boolean canValidate(Class<? extends Annotation> annotationType, Class<?> schemaFieldType, boolean namedList)
      Checks whether this validator can validate a schema field with given annotation and given class.
      Parameters:
      annotationType - Annotation type, belonging to a field.
      schemaFieldType - Field type, according to configuration schema.
      namedList - Whether the validated value is a named list of schemaFieldType elements or not.
      Returns:
      true if this validator can be used to validate desired configuration property.