AstrOOnauta / react-native-international-phone-number

⚛️ International mobile phone number input component for React Native 📱
https://snack.expo.dev/@astroonauta/react-native-international-phone-number
ISC License
272 stars 44 forks source link

customMask for phone numbers prefixed with a zero #67

Closed Bilal-Abdeen closed 2 weeks ago

Bilal-Abdeen commented 8 months ago

Thank you for the excellent library.

I wonder if it is at all possible to add a customMask that allows phone numbers with and without a prefix of a zero? I tried the following but it did NOT work. It seems that the library's mask can only separate digits with spaces. It would be great if it could consider the value entered.

customMask={[ "4## ### ###", "04## ### ###", ]} 

The above mask should allow ONLY: "04## ### ###" and "4## ### ###" However, it allows "### ### ###" and "#### ### ###"

Background: In some countries, calling a local mobile phone number requires the use of a zero before the phone number. For example, in Australia, to call a mobile phone number I need to dial 04## ### ###. While some users realise that they should enter the number without prefixing it with zero, some don't. My code removes the zero before saving it to the db.

PPHelios commented 7 months ago

I'm facing same issue, even after adding a description many people just add the zero, I made a work around by adding an extra mask for a list of countries I'm facing issue with, then validates the output before submitting and removing the 0 if the country code matches a number in this list.

AstrOOnauta commented 2 weeks ago

Same discurssion in https://github.com/AstrOOnauta/react-native-international-phone-number/issues/58