Case-insensitive country for the PhoneNumber validator class #5892

Merged
merged 1 commit into from Mar 4, 2014

Projects

None yet

5 participants

@BruceLampson
Contributor

Recently, I have been working on some form validations and wanted to use the PhoneNumber validator class in my input filter.I realized that It would be awesome if we could set the country in a case-insensitive way :)

@BruceLampson BruceLampson Case-insensitive
I've recently been working on some form validations and wanted to use the PhoneNumber validator class in my input filter and realized it would be awesome if we could set the country case-insensitive :)
7112531
@mwillbanks
Contributor

Please supply an updated test for this behavior.

@weierophinney weierophinney added this to the 2.2.6 milestone Mar 3, 2014
@EvanDotPro EvanDotPro self-assigned this Mar 4, 2014
@EvanDotPro EvanDotPro added a commit that referenced this pull request Mar 4, 2014
@EvanDotPro EvanDotPro Added unit test for PR #5892 5826237
@EvanDotPro EvanDotPro merged commit 7112531 into zendframework:master Mar 4, 2014

1 check passed

default The Travis CI build passed
Details
@EvanDotPro
Member

@mwillbanks I went ahead and added a test while merging.

@mwillbanks
Contributor

@EvanDotPro thank you sir.

@wizzvet
wizzvet commented Apr 5, 2014

There is a side effect here... When you use this validator with the name of the parameter and not the value itself, it doesn't work !

Example:

 new PhoneNumber(
                        array(
                            'country' => 'country_id',
                            'allowed_types' => array('general')
                        )
                    )

country is set to : COUNTRY_ID and the value is no more found in the $context array

So, if you want that the country value is case-insensitive, a solution is to call strtoupper function in the loadPattern function :

protected function loadPattern($code)
{
        $code = strtoupper($code);
        ...
}
@BruceLampson BruceLampson deleted the BruceLampson:patch-2 branch Apr 5, 2014
@gianarb gianarb pushed a commit to zendframework/zend-i18n that referenced this pull request May 15, 2015
@EvanDotPro EvanDotPro Added unit test for PR zendframework/zendframework#5892 7f3fbbc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment