validate method
Function to validate the form input. It takes a string and returns an String error message if the input is invalid or null if the input is valid.
Implementation
@override
String? validate(
BuildContext context,
String fieldName,
String? value,
) {
_longErrorMessage = null;
_shortErrorMessage = null;
if (value != null && value.isNotEmpty) {
final l10n = context.l10n;
_isValid = value.length >= length;
if (!_isValid) {
_shortErrorMessage = l10n.tooShortMessage;
_longErrorMessage = l10n.tooShortErrorMessage(fieldName, length);
}
} else {
_isValid = true;
}
return _shortErrorMessage;
}