validate method

  1. @override
Future<ValidationResult?> validate(
  1. BuildContext context,
  2. String? value,
  3. 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;
}