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 || lowerBound == null) return null;
  assert(control.value is Comparable, 'Value needs to be Comparable');
  if (control.value < lowerBound) {
    final lowerText = _numberFormat.format(lowerBound);
    return {numberBelowLowerBoundErrorKey: numberIsTooSmallMsg(lowerText)};
  }
  return null;
}