validate method
Future<ValidationResult?>
validate(
- BuildContext context,
- String? value,
- FormValidationMode state
override
Implementation
@override
Future<ValidationResult?> validate(
BuildContext context, String? value, FormValidationMode state) async {
if (value == null) {
return null;
}
ShadcnLocalizations localizations =
Localizations.of(context, ShadcnLocalizations);
if (min != null && value.length < min!) {
return InvalidResult(message ?? localizations.formLengthLessThan(min!));
}
if (max != null && value.length > max!) {
return InvalidResult(
message ?? localizations.formLengthGreaterThan(max!));
}
return null;
}