public function ValidatingService::isValidNumber in International Phone 8
Same name and namespace in other branches
- 8.2 src/Helpers/ValidatingService.php \Drupal\phone_international\Helpers\ValidatingService::isValidNumber()
- 3.x src/Helpers/ValidatingService.php \Drupal\phone_international\Helpers\ValidatingService::isValidNumber()
Utility for international phone numbers.
Parameters
string $number: Phone number verification and validation.
Return value
bool Return number valid(TRUE) or invalid(FALSE).
Overrides isValid::isValidNumber
File
- src/
Helpers/ ValidatingService.php, line 23
Class
- ValidatingService
- Class ValidatingService.
Namespace
Drupal\phone_international\HelpersCode
public function isValidNumber($number) {
$phoneUtil = PhoneNumberUtil::getInstance();
try {
$parseNumber = $phoneUtil
->parse($number);
return $phoneUtil
->isValidNumber($parseNumber);
} catch (NumberParseException $e) {
Drupal::logger('phone_international')
->debug($e);
return FALSE;
}
}