validate method

  1. @override
bool validate(
  1. dynamic value, [
  2. List<String>? options
])
override

Validates whether the provided value is numeric.

This method attempts to parse the value as a number. If the parsing is successful, the method returns true, indicating that the value is numeric. If the parsing fails or if the value is null, the method returns false.

The options parameter is not used in this validation rule, but it is included to adhere to the ValidationRule interface.

  • value: The value to be validated.
  • options: Additional options for validation (not used).

Returns true if the value is numeric, otherwise false.

Implementation

@override
bool validate(dynamic value, [List<String>? options]) {
  if (value == null) return false;
  return num.tryParse(value.toString()) != null;
}