mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Adding passthrough to localized Validation class for Validation::ssn. Tests added. Fixes #378
This commit is contained in:
parent
16f6d4d408
commit
0806545f35
2 changed files with 14 additions and 3 deletions
|
@ -782,11 +782,13 @@ class Validation extends Object {
|
|||
$_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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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 @@ class ValidationTest extends CakeTestCase {
|
|||
*
|
||||
* @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'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue