call method
Validates whether a value is within the specified list of items.
This method checks if the input value
is included in the provided items
list.
If the value
is not found within the list, 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 within the specified items
list,
or null
if the value
is valid.
Implementation
@override
String? call(String attribute, String value) {
if (value.isNotEmpty) {
if (!items.contains(value)) {
return buildMessage(attribute, value, onExtra: (message) {
message = message.replaceAll(':items', items.toString());
return message;
});
}
}
return null;
}