call method
Validates whether a value is less than or equal to the specified number
.
This method checks if the input value
is less than or equal to the provided number
.
If the value
is greater than the number
, an error message is generated
using the buildMessage
method.
Parameters:
attribute
: The identifier of the form attribute being validated.value
: The value to be validated.
Returns:
A validation error message if the value
is not less than or equal to the specified number
,
or null
if the value
is valid.
Implementation
@override
String? call(String attribute, String value) {
if (value.isNotEmpty) {
final parsedValue = num.tryParse(value);
if (parsedValue == null || !(parsedValue <= number)) {
return buildMessage(attribute, value, onExtra: (message){
message.replaceAll(':number', number.toString());
return message;
});
}
}
return null;
}