validate method
- String? value
override
Validates the value and returns an error string if it fails,
or null if it passes.
Implementation
@override
String? validate(String? value) {
if (value == null || value.isEmpty) return null;
final escapedAllowed = RegExp.escape(allowed);
// Actually, we want to fail if it *contains* any character not in [a-zA-Z0-9\s] + allowed
final regex = RegExp('[^a-zA-Z0-9\\s$escapedAllowed]');
if (regex.hasMatch(value)) {
return message;
}
return null;
}