From 07584024b5f9e359bbd5e25035e17d50db240e30 Mon Sep 17 00:00:00 2001 From: Henrique Moody Date: Mon, 21 Sep 2015 13:27:11 -0300 Subject: [PATCH] Create "KgSubdivisionCode" rule --- .../KgSubdivisionCodeException.php | 31 +++++++++++++++ .../SubdivisionCode/KgSubdivisionCode.php | 38 +++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 library/Exceptions/SubdivisionCode/KgSubdivisionCodeException.php create mode 100644 library/Rules/SubdivisionCode/KgSubdivisionCode.php diff --git a/library/Exceptions/SubdivisionCode/KgSubdivisionCodeException.php b/library/Exceptions/SubdivisionCode/KgSubdivisionCodeException.php new file mode 100644 index 00000000..8864726e --- /dev/null +++ b/library/Exceptions/SubdivisionCode/KgSubdivisionCodeException.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 Kyrgyzstan subdivision code. + * + * ISO 3166-1 alpha-2: KG + */ +class KgSubdivisionCodeException extends SubdivisionCodeException +{ + public static $defaultTemplates = array( + self::MODE_DEFAULT => array( + self::STANDARD => '{{name}} must be a subdivision code of Kyrgyzstan', + ), + self::MODE_NEGATIVE => array( + self::STANDARD => '{{name}} must not be a subdivision code of Kyrgyzstan', + ), + ); +} diff --git a/library/Rules/SubdivisionCode/KgSubdivisionCode.php b/library/Rules/SubdivisionCode/KgSubdivisionCode.php new file mode 100644 index 00000000..0d2ba007 --- /dev/null +++ b/library/Rules/SubdivisionCode/KgSubdivisionCode.php @@ -0,0 +1,38 @@ + + * + * 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 Kyrgyzstan subdivision code. + * + * ISO 3166-1 alpha-2: KG + * + * @link http://www.geonames.org/KG/administrative-division-kyrgyzstan.html + */ +class KgSubdivisionCode extends AbstractSearcher +{ + public $haystack = array( + 'B', // Batken + 'C', // Chu + 'GB', // Bishkek + 'GO', // Osh City + 'J', // Jalal-Abad + 'N', // Naryn + 'O', // Osh + 'T', // Talas + 'Y', // Ysyk-Kol + ); + + public $compareIdentical = true; +}