phone static method
Fails when a non-empty value isn't a plausible phone number
(digits, spaces and + - ( ), 7–15 digits).
Implementation
static FormFieldValidator<String> phone(
[String message = 'Invalid phone number']) =>
(value) {
if (value == null || value.isEmpty) return null;
final digits = value.replaceAll(RegExp(r'[^0-9]'), '');
final shape = RegExp(r'^\+?[0-9\s\-()]+$');
return (shape.hasMatch(value) &&
digits.length >= 7 &&
digits.length <= 15)
? null
: message;
};