PhoneRules class abstract final

Factory class for creating phone number validation rules.

Provides basic phone number validation. For comprehensive international phone validation, consider using a dedicated library like phone_number.

Example

final phoneValidator = PhoneRules.international(
  error: 'Invalid phone number',
);

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

international<E>({required E error}) Rule<String, E>
Validates that the phone number is in E.164 international format.
matches<E>(RegExp pattern, {required E error}) Rule<String, E>
Validates the phone number against a custom pattern.
maxDigits<E>(int max, {required E error}) Rule<String, E>
Validates that the phone number has at most max digits.
minDigits<E>(int min, {required E error}) Rule<String, E>
Validates that the phone number has at least min digits.
us<E>({required E error}) Rule<String, E>
Validates that the phone number is a valid US phone number.