validate method

  1. @override
bool validate(
  1. dynamic data
)
override

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'^\(?(\d{3})\)?[-\. ]?(\d{3})[-\. ]?(\d{4})( x\d{4})?$',
  );
  return regExp.hasMatch(data.toString());
}