validate method
Return null if valid, otherwise a ValidationException.
Implementation
@override
ValidationException? validate(Object? value) {
final RegExp regex = RegExp(pattern);
if (value is String) {
if (!regex.hasMatch(value)) {
return ValidationException(this, value);
}
return null;
} else {
return ValidationException(
this,
value,
'Value must be a String type (is ${value.runtimeType})',
);
}
}