isPhone property
bool
get
isPhone
Checks if the string is a valid phone number.
Validates a variety of phone number formats using regular expressions, covering the most common international and local phone number formats.
Supported formats include:
- International format with country code: +1234567890, +1 234 567 890
- US/North American formats: (123) 456-7890, 123-456-7890
- Format with dots: 123.456.7890
- Simple digit sequence (7-15 digits): 1234567890
Returns true if the string is a valid phone number, otherwise returns false.
Example:
'+1 234 567 8901'.isPhone; // true
'(123) 456-7890'.isPhone; // true
'123.456.7890'.isPhone; // true
'1234567890'.isPhone; // true
'not-a-number'.isPhone; // false
''.isPhone; // false (empty string)
Implementation
bool get isPhone {
return _isPhone(this);
}