Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Case-insensitive country for the PhoneNumber validator class #5892

Merged
merged 1 commit into from
Mar 4, 2014

Conversation

BruceLampson
Copy link
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 :)

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 :)
@mwillbanks
Copy link
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 added a commit that referenced this pull request Mar 4, 2014
@EvanDotPro EvanDotPro merged commit 7112531 into zendframework:master Mar 4, 2014
@EvanDotPro
Copy link
Member

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

@mwillbanks
Copy link
Contributor

@EvanDotPro thank you sir.

@wizzvet
Copy link

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 patch-2 branch April 5, 2014 18:10
gianarb pushed a commit to zendframework/zend-i18n that referenced this pull request May 15, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants