Interface Validator

All Superinterfaces:
Cloneable
All Known Subinterfaces:
AllowedFileTypeValidator, AndGroupValidator, DecimalDigitsValidator, EmailValidator, GroupValidator, IbanValidator, LengthValidator, MandatoryValidator, NumberRangeValidator, PhoneValidator, RegexValidator, SocialSecurityNrValidator, UrlValidator, ValueValidator
All Known Implementing Classes:
AbstractGroupValidator, AbstractValidator, AllowedFileTypeValidatorImpl, AndGroupValidatorImpl, DecimalDigitsValidatorImpl, EmailValidatorImpl, GroupValidatorView, IbanValidatorImpl, LengthValidatorImpl, MandatoryValidatorImpl, NumberRangeValidatorImpl, PhoneValidatorImpl, RegexValidatorImpl, SocialSecurityNrValidatorImpl, UrlValidatorImpl

public interface Validator extends Cloneable
A validator to check if data matches expected rules. This validator is used for form input and entity data, maybe more to come.
  • Method Details

    • validate

      Validates a data component, for example a field or a group of fields.

      The fields map is required for looking at other values of this entity/form when conditions are in use.

      With this definition we don't know which value in the fields map is "us", cause we dont' know our name here. Don't think it's needed.

      Groups: if there are no (active) validators in this group then the OK status is returned.

      Parameters:
      value - the value to validate, non-null
      fields - (all fields, key=name, value=value plus type)
      Throws:
      IllegalArgumentException - Wrong data type.
    • doNegate

      boolean doNegate()
      Tells if the result of the validation is being negated (internally). This means that the properties of specific validator implementations like a number range have negated meaning in the end.
      Returns:
      .
    • setNegate

      void setNegate(boolean negate)
    • hasName

      boolean hasName()
      Returns:
      Tells if this validator has a name, otherwise it is null.
    • getName

      @Nullable @Nullable String getName()
    • setName

      void setName(String name)
    • getLevel

      ErrorLevel getLevel()
    • setLevel

      void setLevel(ErrorLevel level)
    • getRunOn

      RunOn getRunOn()
    • setRunOn

      void setRunOn(RunOn runOn)
    • doContinueOnFailure

      boolean doContinueOnFailure()
      If the validation process should continue on this level with next validator when this one "fails". Failing means a negative result, how negative depends on ghe error level, an INFO counts as failed too (the test failed, it's just not that important).
      Returns:
      .
    • setContinue

      void setContinue(boolean doContinue)
    • getType

      Class<? extends Validator> getType()
      Returns:
      The class of the implementing class.
    • canMergeConstraints

      boolean canMergeConstraints()
      Tells if the constraint data of this validator can be merged with another instance.

      This is validator-type specific. For example a date range validator can, a regex validator obviously cannot.

      See Also:
    • mergeConstraints

      boolean mergeConstraints(Validator validator, Validator.MergeMode mode)
      Merges the constraint data of this validator with the data of another instance.
      Parameters:
      validator - The validator to merge in.
      mode - How to merge.
      Returns:
      true if it was done. This should only fail if canMergeConstraints() says false.
      See Also:
    • clone

      Throws:
      CloneNotSupportedException