phone static method

String? phone(
  1. String? value, {
  2. String? message,
})

Validates phone number format

Example:

Validators.phone('+1234567890');

Implementation

static String? phone(String? value, {String? message}) {
  if (value == null || value.isEmpty) return null;
  final phoneRegex = RegExp(r'^\+?[\d\s-()]+$');
  if (!phoneRegex.hasMatch(value) || value.length < 10) {
    return message ?? 'Please enter a valid phone number';
  }
  return null;
}