catamphetamine / react-phone-number-input

React component for international phone number input
http://catamphetamine.gitlab.io/react-phone-number-input/
MIT License
914 stars 193 forks source link

Why some phone number does not show country flag, are those invalid? #357

Closed nikhilsarvaiye closed 4 years ago

nikhilsarvaiye commented 4 years ago

If you try below numbers +1 785 456 5456 -- does work +1 456 456 5456 -- does not work

Below configuration <PhoneInput international limitMaxLength name={name} value={value} onChange={setValue} defaultCountry='US' useNationalFormatForDefaultCountryValue={false} addInternationalOption={false} displayInitialValueAsLocalNumber={false} countryOptionsOrder={['US', 'CA', 'AU', 'IN', '...']} />

Any way we can disable this behavior?

catamphetamine commented 4 years ago

It's not clear what you're talking about

nikhilsarvaiye commented 4 years ago

If you look at below image, there two number which has been set from record. Both values are getting set properly to phone control, but only first one show US country selected flag as valid. Any reason why other doesn't show, is it because its invalid?

isValidPhoneNumber shows the second number as invalid, can we have some input configuration like named validationType on whether to use isValidPhoneNumber or isPossiblePhoneNumber for validation? Currently I am using isPossiblePhoneNumber for error message validation but library is using isValidPhoneNumber internally.

image

catamphetamine commented 4 years ago

I see, so the issue being reported is that the second number's country isn't autodetected. This is the expected behavior, until Google's library demo returns different results. So you can check that in Google's demo if you want.

isValidPhoneNumber shows the second number as invalid

Then it's not valid

, can we have some input configuration like named validationType on whether to use isValidPhoneNumber or isPossiblePhoneNumber for validation?

This component doesn't use any validation internally, so it's not clear what you mean.

Currently I am using isPossiblePhoneNumber for error message validation but library is using isValidPhoneNumber internally.

This library isn't using any validation internally.

catamphetamine commented 4 years ago

I'll close this issue because the behavior is expected (though many people don't understand why it's expected because it's how libphonenumber-js works).