phone validate strict

This commit is contained in:
Yuri Kuznetsov
2023-11-10 16:06:36 +02:00
parent 66cbf57f5e
commit 4cbdb18aef
2 changed files with 15 additions and 0 deletions

View File

@@ -210,6 +210,10 @@ class PhoneType
return false;
}
if ((string) $numberObj !== $number) {
return false;
}
return $numberObj->isPossibleNumber();
}

View File

@@ -1259,7 +1259,13 @@ class Import
private function formatPhoneNumber(string $value, Params $params): string
{
$value = trim($value);
if (str_starts_with($value, '+')) {
if ($this->config->get('phoneNumberInternational')) {
return $this->parsePhoneNumber($value, null);
}
return $value;
}
@@ -1269,6 +1275,11 @@ class Import
$code = strtoupper($params->getPhoneNumberCountry());
return $this->parsePhoneNumber($value, $code);
}
private function parsePhoneNumber(string $value, ?string $code): string
{
try {
$number = PhoneNumber::parse($value, $code);