minLength static method

FormFieldValidator<String> minLength(
  1. int length, {
  2. bool cleanMask = false,
  3. String? message,
})

Implementation

static FormFieldValidator<String> minLength(
  int length, {
  bool cleanMask = false,
  String? message,
}) {
  return (String? value) {
    String? _value = value;
    if (cleanMask && _value.isNotBlank) {
      _value = StringUtils.cleanMask(value!);
    }

    if ((value?.length ?? 0) < length) {
      return message ?? 'This field must have at least $length characters';
    }

    return null;
  };
}