Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

correct and unify country codes for validation #1191

Merged
merged 2 commits into from

2 participants

@dereuromark
Collaborator

As in postal() ca is the correct (2 letter iso) country code for Canada, so this should be corrected in phone() accordingly.

I will then also update the 2.4 docs:
dereuromark/docs@cakephp:2.4...dereuromark:2.4-validation

lib/Cake/Utility/Validation.php
((5 lines not shown))
case 'all':
- case 'can':
// includes all NANPA members.
@markstory Owner

The original 3 letter version should be left behind so compatibility is maintained. However all the docs/examples should use the new form.

@dereuromark Collaborator

Migration guide itself is not enough? Can be mark it as "deprecated" in the code somehow?

@markstory Owner

Since it is just one line in a case statement, I don't know why we'd break things.

@dereuromark Collaborator

All right, I'll fix it up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@markstory markstory merged commit 75fd460 into cakephp:2.4
@dereuromark dereuromark referenced this pull request in cakephp/docs
Merged

correct country code for validation #530

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 23, 2013
  1. @dereuromark
Commits on Mar 24, 2013
  1. @dereuromark
This page is out of date. Refresh to see the latest.
Showing with 3 additions and 1 deletion.
  1. +3 −1 lib/Cake/Utility/Validation.php
View
4 lib/Cake/Utility/Validation.php
@@ -617,8 +617,10 @@ public static function phone($check, $regex = null, $country = 'all') {
if (is_null($regex)) {
switch ($country) {
case 'us':
- case 'all':
+ case 'ca':
+ // deprecated three-letter-code
case 'can':
+ case 'all':
// includes all NANPA members.
// see http://en.wikipedia.org/wiki/North_American_Numbering_Plan#List_of_NANPA_countries_and_territories
$regex = '/^(?:\+?1)?[-. ]?\\(?[2-9][0-8][0-9]\\)?[-. ]?[2-9][0-9]{2}[-. ]?[0-9]{4}$/';
Something went wrong with that request. Please try again.