You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Therefore we always get IN back in this situation, because the phone number of an unknown validity has been parsed as belonging to this region.
If the intended behaviour is that when we are not in strict mode, then the phone number's region is derived from the phone number itself then validated, then it will always be validated with the region specified or India.
So it is never really a "unstrict" test for any valid global phone number. It always needs a region.
Hey there!
Thanks for making this!
I'm calling this library with the following.
This code is valid, because the type signature is as follows https://github.com/abhisekp/yup-phone/blob/master/src/yup-phone.ts#L16 - the first parameter is not required.
However, the library defaults to India in this case running the following:
When we do the following:
Therefore we always get
IN
back in this situation, because the phone number of an unknown validity has been parsed as belonging to this region.If the intended behaviour is that when we are not in strict mode, then the phone number's region is derived from the phone number itself then validated, then it will always be validated with the region specified or India.
So it is never really a "unstrict" test for any valid global phone number. It always needs a region.
Google's guide suggests that
isValidNumberForRegion
should be used sparing https://github.com/google/libphonenumber/blob/master/FAQ.md#when-should-i-use-isvalidnumberforregionMaybe when we aren't in strict mode then
isValidNumber()
could be used?Maybe I am missing something here?
In a PHP version of this library, one can pass empty strings or null when the region is unknown when parsing.
giggsey/libphonenumber-for-php#85
This however is not valid code:
In the other Javascript library port of libphonenumber, this is valid code:
Hope this isn't confusing!
The text was updated successfully, but these errors were encountered: