Add phone rule
It's very popular along with emails nowadays.
FYI there is package for that: https://github.com/giggsey/libphonenumber-for-php
@BoShurik Thanks! I only used the Python port though. :slightly_smiling_face: It's impractical to write such things from scratch, so it will come in handy for sure.
Looks like a separate package yiisoft/validator-phone with giggsey/libphonenumber-for-php as a dependency
or put rule in yiisoft/validator and add giggsey/libphonenumber-for-php in composer's suggest section
Phones are complicated. There are international ones that are more or less standardized. Local phone number rules are crazy.
I have developed a Yii3 phone number validator; please use it if you wish.
The user can choose whether to validate international and/or national phone numbers; for national numbers, the user can choose which country formats to accept.
International phone numbers are validated against the Extensible Provisioning Protocol (EPP) and/or ITU-T Recommendation E.123 (“Notation for national and i11l telephone numbers, e-mail addresses and Web addresses”) and ITU-T Recommendation E.164 (“The international public telecommunication numbering plan”) formats.
It validates national numbers using a NationalPhoneNumberDataInterface. I have written NationalPhoneNumberDataPhp (an implementation of NationalPhoneNumberDataInterface) which provides numbering plans in the ITU T0202 National Numbering Plans using a PHP file as the storage.
I've also written a helper that converts international numbers from ITU to EPP format and reformats national numbers to the country's standard format (provided by NationalPhoneNumberDataInterface); both intended to provide standard formats for storage and display if required.
The repositories are at: https://github.com/beastbytes/phone-number-validator https://github.com/beastbytes/n6l-phone-number-data https://github.com/beastbytes/n6l-phone-number-data-php https://github.com/beastbytes/phone-number-helper
@beastbytes Thanks! We can add the link to your extension to the guide.
I agree. While it's nice to have it in the core, it deserves its own package and special attention.