Package ca.corbett.forms.validators
Class FileMustBeSpecifiedValidator
java.lang.Object
ca.corbett.forms.validators.FileMustBeSpecifiedValidator
- All Implemented Interfaces:
FieldValidator<FileField>
Similar to NonBlankFieldValidator for TextFields, this FieldValidator implementation
insists that a FileField cannot contain a blank value. Note that this validation is
in addition to the SelectionType for the FileField in question (e.g. if you specify
ExistingFile and also add this FieldValidator, then a file must be specified AND exist.
If you specify ExistingFile but don't add this FieldValidator, then the given file
must only exist if one is specified... blank value will return null in that case).
- Since:
- 2020-10-13
- Author:
- scorbo2
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionPerforms validation on the field in question, and returns a ValidationResult as appropriate.
-
Constructor Details
-
FileMustBeSpecifiedValidator
public FileMustBeSpecifiedValidator()
-
-
Method Details
-
validate
Description copied from interface:FieldValidatorPerforms 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:
validatein interfaceFieldValidator<FileField>- Parameters:
fieldToValidate- The FormField to be validated.- Returns:
- A ValidationResult which describes whether the current value in our field is valid.
-