validate method
Validates the given value against the rule.
This method checks whether the provided value meets the criteria defined by the validation rule. It can be used to enforce data integrity and ensure that inputs conform to expected formats or constraints.
value - The value to be validated. This can be of any type, allowing for flexible
validation logic that can handle various data types such as strings, numbers, or
custom objects.
options - An optional list of strings that can provide additional context or parameters
for the validation. These options can be used to customize the validation logic, for example,
by specifying minimum or maximum lengths, allowed characters, or other constraints.
Returns true if the value passes the validation, otherwise false. If the validation fails,
the message property should be used to provide feedback to the user.
Implementation
@override
bool validate(dynamic value, [List<String>? options]) {
if (value == null) return false;
return RegExp(r'^[a-zA-Z0-9]+$').hasMatch(value.toString());
}