validate method

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

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 control) {
  if (control.value == null) return null; // Handled by accessor validator
  assert(control.value is Comparable, 'Value needs to be Comparable');
  if (control.value > upperBound) {
    final upperText = _numberFormat.format(upperBound);
    return {numberAboveUpperBoundErrorKey: numberIsTooLargeMsg(upperText)};
  }
  return null;
}