Interface FieldValidator<T extends FormField>

Type Parameters:
T - FieldValidators are typed to a specific type of FormField.
All Known Implementing Classes:
FileMustBeCreatableValidator, FileMustBeReadableValidator, FileMustBeSpecifiedValidator, FileMustBeWritableValidator, FileMustExistValidator, FileMustNotExistValidator, NonBlankFieldValidator, YMDDateValidator

public interface FieldValidator<T extends FormField>
Provides an interface for performing validation on some type of FormField. Refer to the provided implementation classes in this package for examples of what you can do with this interface. Writing your own validator with custom business logic or validation rules is as easy as implementing this interface and writing the validate() method!
Since:
2019-11-23
Author:
scorbo2
  • Method Summary

    Modifier and Type
    Method
    Description
    validate(T fieldToValidate)
    Performs validation on the field in question, and returns a ValidationResult as appropriate.
  • Method Details

    • validate

      ValidationResult validate(T fieldToValidate)
      Performs validation on the field in question, and returns a ValidationResult as appropriate. Here you can do whatever checks you need to do, either on the FormField in question, or on other FormFields on the same FormPanel if you have references to them, or to whatever other state your application maintains. If you wish to signal a validation error, it's highly recommended to make sure you give some clue as to what the user can do to fix the problem.

      An example of bad validation:

      return new ValidationResult(false, "Something bad happened.");

      An example of good validation:

      return new ValidationResult(false, "Value must be less than 10.");
      Parameters:
      fieldToValidate - The FormField to be validated.
      Returns:
      A ValidationResult which describes whether the current value in our field is valid.