Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adding passthrough to localized Validation class for Validation::ssn.…

… Tests added. Fixes #378
  • Loading branch information...
commit 0806545f35e01c2223734fed2087005a00ed0ccc 1 parent 16f6d4d
Mark Story markstory authored
4 cake/libs/validation.php
View
@@ -782,11 +782,13 @@ function ssn($check, $regex = null, $country = null) {
$_this->regex = '/\\A\\b[0-9]{9}\\b\\z/i';
break;
case 'us':
- default:
$_this->regex = '/\\A\\b[0-9]{3}-[0-9]{2}-[0-9]{4}\\b\\z/i';
break;
}
}
+ if (empty($_this->regex)) {
+ return $_this->_pass('ssn', $check, $country);
+ }
return $_this->_check();
}
13 cake/tests/cases/libs/validation.test.php
View
@@ -58,10 +58,18 @@ class TestNlValidation {
function postal($check) {
return true;
}
+/**
+ * ssn function for testing ssn pass through
+ *
+ * @return void
+ */
+ function ssn($check) {
+ return true;
+ }
}
/**
- * TestNlValidation class
+ * TestDeValidation class
*
* Used to test pass through of Validation
*
@@ -2041,9 +2049,10 @@ function testPostal() {
*
* @return void
*/
- function testPhoneAndPostalPass() {
+ function testPhonePostalSsnPass() {
$this->assertTrue(Validation::postal('text', null, 'testNl'));
$this->assertTrue(Validation::phone('text', null, 'testDe'));
+ $this->assertTrue(Validation::ssn('text', null, 'testNl'));
}
/**
Please sign in to comment.
Something went wrong with that request. Please try again.