us<E> static method

Rule<String, E> us<E>({
  1. required E error,
})

Validates that the phone number is a valid US phone number.

Accepts formats with or without +1 country code.

PhoneRules.us(error: 'Invalid US phone number')

Implementation

static Rule<String, E> us<E>({required E error}) => PredicateRule(
      predicate: (value) {
        final cleaned = value.replaceAll(RegExp(r'[\s\-\.\(\)]'), '');
        return _usPhoneRegex.hasMatch(cleaned);
      },
      error: error,
    );