From ab77d0c9a4458633555e05d3f84e00a228577d4d Mon Sep 17 00:00:00 2001 From: Henrique Moody Date: Mon, 21 Sep 2015 13:26:49 -0300 Subject: [PATCH] Create "CgSubdivisionCode" rule --- .../CgSubdivisionCodeException.php | 31 ++++++++++++++ .../SubdivisionCode/CgSubdivisionCode.php | 41 +++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 library/Exceptions/SubdivisionCode/CgSubdivisionCodeException.php create mode 100644 library/Rules/SubdivisionCode/CgSubdivisionCode.php diff --git a/library/Exceptions/SubdivisionCode/CgSubdivisionCodeException.php b/library/Exceptions/SubdivisionCode/CgSubdivisionCodeException.php new file mode 100644 index 00000000..6f1e3a6c --- /dev/null +++ b/library/Exceptions/SubdivisionCode/CgSubdivisionCodeException.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 Republic of the Congo subdivision code. + * + * ISO 3166-1 alpha-2: CG + */ +class CgSubdivisionCodeException extends SubdivisionCodeException +{ + public static $defaultTemplates = array( + self::MODE_DEFAULT => array( + self::STANDARD => '{{name}} must be a subdivision code of Republic of the Congo', + ), + self::MODE_NEGATIVE => array( + self::STANDARD => '{{name}} must not be a subdivision code of Republic of the Congo', + ), + ); +} diff --git a/library/Rules/SubdivisionCode/CgSubdivisionCode.php b/library/Rules/SubdivisionCode/CgSubdivisionCode.php new file mode 100644 index 00000000..be62c7a0 --- /dev/null +++ b/library/Rules/SubdivisionCode/CgSubdivisionCode.php @@ -0,0 +1,41 @@ + + * + * 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 Republic of the Congo subdivision code. + * + * ISO 3166-1 alpha-2: CG + * + * @link http://www.geonames.org/CG/administrative-division-republic-of-the-congo.html + */ +class CgSubdivisionCode extends AbstractSearcher +{ + public $haystack = array( + '11', // Bouenza + '12', // Pool + '13', // Sangha + '14', // Plateaux + '15', // Cuvette-Ouest + '16', // Pointe-Noire + '2', // Lekoumou + '5', // Kouilou + '7', // Likouala + '8', // Cuvette + '9', // Niari + 'BZV', // Brazzaville + ); + + public $compareIdentical = true; +}