From caac88af271b0e4891f626ceb1a11b67ae7b867b Mon Sep 17 00:00:00 2001 From: Henrique Moody Date: Mon, 21 Sep 2015 13:26:50 -0300 Subject: [PATCH] Create "CmSubdivisionCode" rule --- .../CmSubdivisionCodeException.php | 31 +++++++++++++++ .../SubdivisionCode/CmSubdivisionCode.php | 39 +++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 library/Exceptions/SubdivisionCode/CmSubdivisionCodeException.php create mode 100644 library/Rules/SubdivisionCode/CmSubdivisionCode.php diff --git a/library/Exceptions/SubdivisionCode/CmSubdivisionCodeException.php b/library/Exceptions/SubdivisionCode/CmSubdivisionCodeException.php new file mode 100644 index 00000000..323c730e --- /dev/null +++ b/library/Exceptions/SubdivisionCode/CmSubdivisionCodeException.php @@ -0,0 +1,31 @@ + + * + * For the full copyright and license information, please view the "LICENSE.md" + * file that was distributed with this source code. + */ + +namespace Respect\Validation\Exceptions\SubdivisionCode; + +use Respect\Validation\Exceptions\SubdivisionCodeException; + +/** + * Exception class for Cameroon subdivision code. + * + * ISO 3166-1 alpha-2: CM + */ +class CmSubdivisionCodeException extends SubdivisionCodeException +{ + public static $defaultTemplates = array( + self::MODE_DEFAULT => array( + self::STANDARD => '{{name}} must be a subdivision code of Cameroon', + ), + self::MODE_NEGATIVE => array( + self::STANDARD => '{{name}} must not be a subdivision code of Cameroon', + ), + ); +} diff --git a/library/Rules/SubdivisionCode/CmSubdivisionCode.php b/library/Rules/SubdivisionCode/CmSubdivisionCode.php new file mode 100644 index 00000000..ed5f4578 --- /dev/null +++ b/library/Rules/SubdivisionCode/CmSubdivisionCode.php @@ -0,0 +1,39 @@ + + * + * For the full copyright and license information, please view the "LICENSE.md" + * file that was distributed with this source code. + */ + +namespace Respect\Validation\Rules\SubdivisionCode; + +use Respect\Validation\Rules\AbstractSearcher; + +/** + * Validator for Cameroon subdivision code. + * + * ISO 3166-1 alpha-2: CM + * + * @link http://www.geonames.org/CM/administrative-division-cameroon.html + */ +class CmSubdivisionCode extends AbstractSearcher +{ + public $haystack = array( + 'AD', // Adamawa Province (Adamaoua) + 'CE', // Centre Province + 'EN', // Extreme North Province (Extrême-Nord) + 'ES', // East Province (Est) + 'LT', // Littoral Province + 'NO', // North Province (Nord) + 'NW', // Northwest Province (Nord-Ouest) + 'OU', // West Province (Ouest) + 'SU', // South Province (Sud) + 'SW', // Southwest Province (Sud-Ouest). + ); + + public $compareIdentical = true; +}