-
Notifications
You must be signed in to change notification settings - Fork 177
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #97 from cakephp/more-postal
Add postal validation for Croatia.
- Loading branch information
Showing
6 changed files
with
148 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
/** | ||
* Slovak Localized Validation class test case | ||
* | ||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org) | ||
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) | ||
* | ||
* Licensed under The MIT License | ||
* Redistributions of files must retain the above copyright notice. | ||
* | ||
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) | ||
* @link http://cakephp.org | ||
* @license http://www.opensource.org/licenses/mit-license.php MIT License | ||
*/ | ||
App::uses('HrValidation', 'Localized.Validation'); | ||
|
||
/** | ||
* HrValidationTest | ||
* | ||
*/ | ||
class HrValidationTest extends CakeTestCase { | ||
|
||
/** | ||
* test the postal method of HrValidation | ||
* | ||
* @return void | ||
*/ | ||
public function testPostal() { | ||
$this->assertTrue(HrValidation::postal('25616')); | ||
$this->assertFalse(HrValidation::postal('0989')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
/** | ||
* Indonesian Localized Validation class test case | ||
* | ||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org) | ||
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) | ||
* | ||
* Licensed under The MIT License | ||
* Redistributions of files must retain the above copyright notice. | ||
* | ||
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) | ||
* @link http://cakephp.org | ||
* @license http://www.opensource.org/licenses/mit-license.php MIT License | ||
*/ | ||
App::uses('IdValidation', 'Localized.Validation'); | ||
|
||
/** | ||
* Indonesian Validation Test Case | ||
*/ | ||
class IdValidationTest extends CakeTestCase { | ||
|
||
/** | ||
* Test the mobile method of IdValidation | ||
* | ||
* @return void | ||
*/ | ||
public function testMobile() { | ||
$this->assertTrue(IdValidation::mobile('08125985608')); | ||
$this->assertFalse(IdValidation::mobile('8125985608')); | ||
} | ||
|
||
/** | ||
* Test the postal method of IdValidation | ||
* | ||
* @return void | ||
*/ | ||
public function testPostal() { | ||
$this->assertTrue(IdValidation::postal('15000')); | ||
$this->assertFalse(IdValidation::postal('00091')); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
/** | ||
* Localized Validation class. Handles localized validation for Croatia. | ||
* | ||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org) | ||
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) | ||
* | ||
* Licensed under The MIT License | ||
* Redistributions of files must retain the above copyright notice. | ||
* | ||
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) | ||
* @link http://cakephp.org | ||
* @license http://www.opensource.org/licenses/mit-license.php MIT License | ||
*/ | ||
App::uses('LocalizedValidation', 'Localized.Validation'); | ||
|
||
/** | ||
* HrValidation | ||
* | ||
*/ | ||
class HrValidation extends LocalizedValidation { | ||
|
||
/** | ||
* Checks a postal code for Croatia. | ||
* | ||
* @param string $check The value to check. | ||
* @return bool Success. | ||
*/ | ||
public static function postal($check) { | ||
$pattern = '/^\d{5}$/'; | ||
return (bool)preg_match($pattern, $check); | ||
} | ||
|
||
/** | ||
* Checks a phone number. | ||
* | ||
* @param string $check The value to check. | ||
* @return bool Success. | ||
* @throws NotImplementedException | ||
*/ | ||
public static function phone($check) { | ||
throw new NotImplementedException('Validation method not implemented yet.'); | ||
} | ||
|
||
/** | ||
* Checks a country specific identification number. | ||
* | ||
* @param string $check The value to check. | ||
* @return bool Success. | ||
* @throws NotImplementedException | ||
*/ | ||
public static function personId($check) { | ||
throw new NotImplementedException('Validation method not implemented yet.'); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters