abhisekp / yup-phone

☎️ Adds a phone number validation check to yup validator using google-libphonenumber
https://www.npmjs.com/package/yup-phone
MIT License
240 stars 26 forks source link

Locale Validation not correct? #821

Open iandevlin opened 1 year ago

iandevlin commented 1 year ago

First of all thanks for creating this!

I guess this is more of a question than an issue, although the answer will indicate whether it's a bug or not.

My understanding would be if you tried to validate a number with a specific locale using a different country code, that it would return false.

e.g. given const phoneSchemaDE = yup.string().phone('DE');

I would expect the following to return false, as the country code is not DE: phoneSchemaDE.isValidSync('+919876543210'); but it doesn't, it returns true.

So my ultimate quesiton is, is the locale check: "is this number a valid phone number when calling FROM this country?" or "is this number a valid number FOR this country?"

abhisekp commented 1 year ago

The phone number is supposed to be valid for the specified country.

iandevlin commented 1 year ago

Thanks for the reply, although that doesn't answer my question?