maxLength static method

ValidatorFn maxLength(
  1. num maxLength
)

Validator that requires controls to have a value of a maximum length.

Implementation

static ValidatorFn maxLength(num maxLength) {
  return /* Map < String , dynamic >? */ (model_module.AbstractControl
      control) {
    if (Validators.required(control) != null) return null;
    final v = control.value as String;
    return v.length > maxLength
        ? {
            'maxlength': {
              'requiredLength': maxLength,
              'actualLength': v.length
            }
          }
        : null;
  };
}