Phone input prefill country issue fixed (#213)
* fix prefill phone issue * js phone parse fixes * revert last change * fix phone UI * Code optimize --------- Co-authored-by: Julien Nahum <julien@nahum.net>
This commit is contained in:
@@ -12,10 +12,13 @@ class ValidPhoneInputRule implements Rule
|
||||
|
||||
public function passes($attribute, $value)
|
||||
{
|
||||
if (!is_string($value) || !Str::startsWith($value, '+')) {
|
||||
if (!is_string($value) || !$value) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
if(ctype_alpha(substr($value, 0, 2))){ // First 2 will be country code
|
||||
$value = substr($value, 2);
|
||||
}
|
||||
$phoneUtil = \libphonenumber\PhoneNumberUtil::getInstance();
|
||||
$phone = $phoneUtil->parse($value);
|
||||
$this->reason = $phoneUtil->isPossibleNumberWithReason($phone);
|
||||
|
||||
Reference in New Issue
Block a user