From af7af91cb70cd067f6bb5fae753763aea1b72629 Mon Sep 17 00:00:00 2001 From: Henrique Moody Date: Mon, 21 Sep 2015 13:27:30 -0300 Subject: [PATCH] Create "NrSubdivisionCode" rule --- .../NrSubdivisionCodeException.php | 31 +++++++++++++ .../SubdivisionCode/NrSubdivisionCode.php | 43 +++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 library/Exceptions/SubdivisionCode/NrSubdivisionCodeException.php create mode 100644 library/Rules/SubdivisionCode/NrSubdivisionCode.php diff --git a/library/Exceptions/SubdivisionCode/NrSubdivisionCodeException.php b/library/Exceptions/SubdivisionCode/NrSubdivisionCodeException.php new file mode 100644 index 00000000..c7faaf8e --- /dev/null +++ b/library/Exceptions/SubdivisionCode/NrSubdivisionCodeException.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 Nauru subdivision code. + * + * ISO 3166-1 alpha-2: NR + */ +class NrSubdivisionCodeException extends SubdivisionCodeException +{ + public static $defaultTemplates = array( + self::MODE_DEFAULT => array( + self::STANDARD => '{{name}} must be a subdivision code of Nauru', + ), + self::MODE_NEGATIVE => array( + self::STANDARD => '{{name}} must not be a subdivision code of Nauru', + ), + ); +} diff --git a/library/Rules/SubdivisionCode/NrSubdivisionCode.php b/library/Rules/SubdivisionCode/NrSubdivisionCode.php new file mode 100644 index 00000000..969ecd9f --- /dev/null +++ b/library/Rules/SubdivisionCode/NrSubdivisionCode.php @@ -0,0 +1,43 @@ + + * + * 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 Nauru subdivision code. + * + * ISO 3166-1 alpha-2: NR + * + * @link http://www.geonames.org/NR/administrative-division-nauru.html + */ +class NrSubdivisionCode extends AbstractSearcher +{ + public $haystack = array( + '01', // Aiwo + '02', // Anabar + '03', // Anetan + '04', // Anibare + '05', // Baiti + '06', // Boe + '07', // Buada + '08', // Denigomodu + '09', // Ewa + '10', // Ijuw + '11', // Meneng + '12', // Nibok + '13', // Uaboe + '14', // Yaren + ); + + public $compareIdentical = true; +}