From a47e8ba2e5909dd420c83febf0d4e64d1042238e Mon Sep 17 00:00:00 2001 From: Henrique Moody Date: Mon, 21 Sep 2015 13:27:29 -0300 Subject: [PATCH] Create "NiSubdivisionCode" rule --- .../NiSubdivisionCodeException.php | 31 +++++++++++++ .../SubdivisionCode/NiSubdivisionCode.php | 46 +++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 library/Exceptions/SubdivisionCode/NiSubdivisionCodeException.php create mode 100644 library/Rules/SubdivisionCode/NiSubdivisionCode.php diff --git a/library/Exceptions/SubdivisionCode/NiSubdivisionCodeException.php b/library/Exceptions/SubdivisionCode/NiSubdivisionCodeException.php new file mode 100644 index 00000000..54fb77dd --- /dev/null +++ b/library/Exceptions/SubdivisionCode/NiSubdivisionCodeException.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 Nicaragua subdivision code. + * + * ISO 3166-1 alpha-2: NI + */ +class NiSubdivisionCodeException extends SubdivisionCodeException +{ + public static $defaultTemplates = array( + self::MODE_DEFAULT => array( + self::STANDARD => '{{name}} must be a subdivision code of Nicaragua', + ), + self::MODE_NEGATIVE => array( + self::STANDARD => '{{name}} must not be a subdivision code of Nicaragua', + ), + ); +} diff --git a/library/Rules/SubdivisionCode/NiSubdivisionCode.php b/library/Rules/SubdivisionCode/NiSubdivisionCode.php new file mode 100644 index 00000000..8f80fe2d --- /dev/null +++ b/library/Rules/SubdivisionCode/NiSubdivisionCode.php @@ -0,0 +1,46 @@ + + * + * 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 Nicaragua subdivision code. + * + * ISO 3166-1 alpha-2: NI + * + * @link http://www.geonames.org/NI/administrative-division-nicaragua.html + */ +class NiSubdivisionCode extends AbstractSearcher +{ + public $haystack = array( + 'AN', // Region Autonoma del Atlantico Norte + 'AS', // Region Autonoma del Atlantico Sur + 'BO', // Boaco + 'CA', // Carazo + 'CI', // Chinandega + 'CO', // Chontales + 'ES', // Esteli + 'GR', // Granada + 'JI', // Jinotega + 'LE', // Leon + 'MD', // Madriz + 'MN', // Managua + 'MS', // Masaya + 'MT', // Matagalpa + 'NS', // Nueva Segovia + 'RI', // Rivas + 'SJ', // Rio San Juan + ); + + public $compareIdentical = true; +}