validate method

  1. @override
Map<String, dynamic>? validate(
  1. AbstractControl c
)
override

Returns a map of the errors associated with this control.

Each entry in the map is a separate error associated with the control. The key is an identifier for the error while the value is additional information used by the component to display the error. For instance a length validator could provide information about how long the current invalid string is and the max string length for the input to display.

Implementation

@override
Map<String, dynamic>? validate(AbstractControl c) {
  final v = c.value?.toString();
  if (v == null || v == '') return null;
  return v.length < minLength
      ? {
          'minlength': {'requiredLength': minLength, 'actualLength': v.length}
        }
      : null;
}