minLength static method

FormFieldValidator minLength(
  1. num minLength, {
  2. String? errorText,
})

FormFieldValidator that requires the length of the field's value to be greater than or equal to the provided minimum length.

Implementation

static FormFieldValidator minLength(
  num minLength, {
  String? errorText,
}) {
  return (candidate) {
    final valueCandidate = candidate as String?;
    if (valueCandidate != null && valueCandidate.length < minLength) {
      return errorText ??
          "Value must have a length greater than or equal to $minLength";
    }
    return null;
  };
}