WC_Validation::is_phone
Validates a phone number using a regular expression.
Method of the class: WC_Validation{}
Hooks from the method
Returns
bool.
Usage
$result = WC_Validation::is_phone( $phone, $country );
- $phone(string) (required)
- Phone number to validate.
- $country(string|null)
- The country code the phone is being validated for, or null if unknown.
Default:null
WC_Validation::is_phone() WC Validation::is phone code WC 11.1.1
public static function is_phone( $phone, $country = null ) {
$valid = self::is_phone_format( $phone );
/**
* Filters whether a phone number is considered valid.
*
* @since 11.0.0
*
* @param bool $valid Whether the phone number passed the default validation.
* @param string $phone The phone number being validated.
* @param string|null $country The country code the phone is being validated for, or null if unknown.
*/
return (bool) apply_filters( 'woocommerce_validate_phone', $valid, $phone, $country );
}