validate method
Validates the given value.
Returns an error message String if validation fails, otherwise returns `null].
The context can optionally be used by rules needing access to localization, etc.
This context is provided by the FieldValidator when getValidator is called.
Implementation
@override
String? validate(String? value, {BuildContext? context}) {
if ((value ?? '').trim().isEmpty)
return null; // Don't validate empty strings
return double.tryParse(value!) == null ? message : null;
}