-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Added I18n PhoneNumber validator based off of country #4127
Added I18n PhoneNumber validator based off of country #4127
Conversation
Thank you. Thank you. Thank you. Thank you. |
@EvanDotPro i think it may need some additional work to fit your use case a bit better but it should be customizable enough for now. I think it could possibly go through all patterns to find possible matches and then attempt to figure out a country or something like that but for now it requires a country :) |
I am wondering if there isn't a better way to implement a 200kb array in the validator, I was looking at SplFixedArray but that would require a second array for indexes. I wonder what the benchmarks are on memory usage on this PR. More generally, the question is, is this the best way to use large fixed datasets accross ZF2. |
@mwillbanks About the large array problem @ThomasCantonnet mentioned: I'd suggest to split the country data into individual files (Zend/I18n/Validator/PhoneNumer/[a-z]{2}.php). and then just load them as required:
This should solve a possible memory problem quite a bit. |
I'll refactor this a bit; likely tonight ;) |
Rebased, force pushed, adjusted for feedback. |
…number Added I18n PhoneNumber validator based off of country
how to set only for mobile? 'allowed_types' => array('mobile'), |
#5150 is still hanging ... |
…eature/i18n-validator-phonenumber Added I18n PhoneNumber validator based off of country
I am breaking off items from #3884 to make it easier to be able to merge each individually. Please see original PR for several notes. None were given on phone number implementation.
Phone Number
The Phone Number validator is based on libPhoneNumber's XML file. It is a multi-dimensional hash that takes the country code as a key then several subkeys for possible types, national types and separated by types of numbers. The country is primarily used so that you will only need to validate against a subset of items. A country is required.
Basic Usage: