diff --git a/application/Espo/Classes/FieldValidators/PhoneType.php b/application/Espo/Classes/FieldValidators/PhoneType.php index 76d831c849..82735b32d5 100644 --- a/application/Espo/Classes/FieldValidators/PhoneType.php +++ b/application/Espo/Classes/FieldValidators/PhoneType.php @@ -210,6 +210,10 @@ class PhoneType return false; } + if ((string) $numberObj !== $number) { + return false; + } + return $numberObj->isPossibleNumber(); } diff --git a/application/Espo/Tools/Import/Import.php b/application/Espo/Tools/Import/Import.php index 362840fe01..77a739d6c5 100644 --- a/application/Espo/Tools/Import/Import.php +++ b/application/Espo/Tools/Import/Import.php @@ -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);