From fcae00f2e0bfbfdbb0b937929912c098a99d6769 Mon Sep 17 00:00:00 2001 From: Henrique Moody Date: Mon, 21 Sep 2015 13:27:30 -0300 Subject: [PATCH] Create "NpSubdivisionCode" rule --- .../NpSubdivisionCodeException.php | 31 ++++++++++++ .../SubdivisionCode/NpSubdivisionCode.php | 48 +++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 library/Exceptions/SubdivisionCode/NpSubdivisionCodeException.php create mode 100644 library/Rules/SubdivisionCode/NpSubdivisionCode.php diff --git a/library/Exceptions/SubdivisionCode/NpSubdivisionCodeException.php b/library/Exceptions/SubdivisionCode/NpSubdivisionCodeException.php new file mode 100644 index 00000000..f97dd92d --- /dev/null +++ b/library/Exceptions/SubdivisionCode/NpSubdivisionCodeException.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 Nepal subdivision code. + * + * ISO 3166-1 alpha-2: NP + */ +class NpSubdivisionCodeException extends SubdivisionCodeException +{ + public static $defaultTemplates = array( + self::MODE_DEFAULT => array( + self::STANDARD => '{{name}} must be a subdivision code of Nepal', + ), + self::MODE_NEGATIVE => array( + self::STANDARD => '{{name}} must not be a subdivision code of Nepal', + ), + ); +} diff --git a/library/Rules/SubdivisionCode/NpSubdivisionCode.php b/library/Rules/SubdivisionCode/NpSubdivisionCode.php new file mode 100644 index 00000000..465f597e --- /dev/null +++ b/library/Rules/SubdivisionCode/NpSubdivisionCode.php @@ -0,0 +1,48 @@ + + * + * 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 Nepal subdivision code. + * + * ISO 3166-1 alpha-2: NP + * + * @link http://www.geonames.org/NP/administrative-division-nepal.html + */ +class NpSubdivisionCode extends AbstractSearcher +{ + public $haystack = array( + '1', // Madhyamanchal + '2', // Madhya Pashchimanchal + '3', // Pashchimanchal + '4', // Purwanchal + '5', // Sudur Pashchimanchal + 'BA', // Bagmati + 'BH', // Bheri + 'DH', // Dhawalagiri + 'GA', // Gandaki + 'JA', // Janakpur + 'KA', // Karnali + 'KO', // Kosi + 'LU', // Lumbini + 'MA', // Mahakali + 'ME', // Mechi + 'NA', // Narayani + 'RA', // Rapti + 'SA', // Sagarmatha + 'SE', // Seti + ); + + public $compareIdentical = true; +}