max<T> static method

FormFieldValidator<T> max<T>(
  1. num max, {
  2. bool inclusive = true,
  3. String? errorText,
})

Implementation

static FormFieldValidator<T> max<T>(num max, {
  bool inclusive = true,
  String? errorText,
}) {
  return (T? valueCandidate) {
    if (valueCandidate != null) {
      assert(valueCandidate is num || valueCandidate is String);
      final number = BasicNumberTransformer.currencyToNumber(valueCandidate.toString());
      if (number != null && (inclusive ? number > max : number >= max)) {
        return errorText ?? BasicFormValidatorMessageError().max!('$max');
      }
    }
    return null;
  };
}