Class FileMustBeCreatableValidator

java.lang.Object
ca.corbett.forms.validators.FileMustBeCreatableValidator
All Implemented Interfaces:
FieldValidator<FileField>

public class FileMustBeCreatableValidator extends Object implements FieldValidator<FileField>
A validator for use with FileField to ensure that the selected File is in a location that can be written. Specifically, if you're browsing for a new File which does NOT exist, it should be in a location where we have permission to create a new file.
Since:
2019-11-27
Author:
scorbo2
  • Constructor Details

    • FileMustBeCreatableValidator

      public FileMustBeCreatableValidator()
  • Method Details

    • validate

      public ValidationResult validate(FileField fieldToValidate)
      Description copied from interface: FieldValidator
      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.");
      Specified by:
      validate in interface FieldValidator<FileField>
      Parameters:
      fieldToValidate - The FormField to be validated.
      Returns:
      A ValidationResult which describes whether the current value in our field is valid.