isValidPhone

Validates if the provided string is a properly formatted phone number. This function checks if the string contains only digits and possibly spaces, dashes, or parentheses, depending on the desired format.
> isValidPhone(phone: string): boolean
Parameters
  • phone: The phone number string to validate.
  • Returns: `true` if the phone number is valid, `false` otherwise.

Example

import { isValidPhone } from "@explita/daily-toolset";

isValidPhone("(123) 456-7890"); // true
isValidPhone("123456");         // false