Class AbstractFieldValidator

java.lang.Object
ch.tocco.nice2.persist.core.api.validation.AbstractFieldValidator
All Implemented Interfaces:
FieldValidator
Direct Known Subclasses:
NotNullFieldValidatorImpl, TodoDateFieldPathValidator, XssProtectionFieldValidator

public abstract class AbstractFieldValidator extends Object implements FieldValidator
  • Constructor Details

    • AbstractFieldValidator

      public AbstractFieldValidator()
  • Method Details

    • validate

      public final void validate(List<Entity> entities, FieldModel fieldModel, Map<Entity,FieldValidationResult> fieldValidationResults, ValidationContext validationContext)
      Description copied from interface: FieldValidator
      Validate the field at hand.
      Specified by:
      validate in interface FieldValidator
      Parameters:
      entities - the entities to be validated
      fieldModel - the fieldModel to be validated
      fieldValidationResults - the FieldValdationResult to write the result of the validation to. FieldValidationResult for more details on how to construct the FieldValidationResult.
    • validate

      protected abstract void validate(Entity entity, FieldModel fieldModel, @Nullable @Nullable Object fieldValue, FieldValidationResult fieldValidationResult)
    • addMyself

      public boolean addMyself(EntityModel entityModel, FieldModel fieldModel)
      Description copied from interface: FieldValidator
      Implement this method to return true if the Validator should add itself to the FieldModel at hand. This method can be useful, if a validator is being used for all field types meeting a certain requirement (e.g. a specific type). The method is called for each field model at application startup when building the entity model.
      Specified by:
      addMyself in interface FieldValidator
      Parameters:
      entityModel - the EntityModel
      fieldModel - the FieldModel
      Returns:
      true to add the Validator to the EntityModel at hand
    • getName

      public final String getName()
      Specified by:
      getName in interface FieldValidator