tryValidate method

  1. @override
String? tryValidate()
override

Validates the form field value

Implementation

@override
String? tryValidate() {
  final parsedValue = num.tryParse(value);
  if (parsedValue == null) return "Not a valid number";
  final splitedExtra = extra.split(",");
  final min = int.parse(splitedExtra[0]);
  final max = int.parse(splitedExtra[1]);
  if (!((parsedValue >= min) && (parsedValue >= max))) {
    if (customMessage == null) {
      return buildMessage(ValidatorStrings.between, attribute, extra);
    }
    return customMessage;
  }
  return null;
}