validate method
Validates the provided data against this rule.
Returns true if the data is valid, false otherwise.
Subclasses must implement this method.
Implementation
@override
bool validate(data) {
RegExp regExp = RegExp(r'(^[0-9]{4}?[0-9]$|^[0-9]{4}?[0-9]-[0-9]{4}$)');
return regExp.hasMatch(data.toString());
}