From d9ccffeba3ab22eb0b6a775cb7c5aac6195f3f7a Mon Sep 17 00:00:00 2001 From: Henrique Moody Date: Mon, 21 Sep 2015 13:26:32 -0300 Subject: [PATCH] Create "AmSubdivisionCode" rule --- .../AmSubdivisionCodeException.php | 31 ++++++++++++++ .../SubdivisionCode/AmSubdivisionCode.php | 40 +++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 library/Exceptions/SubdivisionCode/AmSubdivisionCodeException.php create mode 100644 library/Rules/SubdivisionCode/AmSubdivisionCode.php diff --git a/library/Exceptions/SubdivisionCode/AmSubdivisionCodeException.php b/library/Exceptions/SubdivisionCode/AmSubdivisionCodeException.php new file mode 100644 index 00000000..f282459b --- /dev/null +++ b/library/Exceptions/SubdivisionCode/AmSubdivisionCodeException.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 Armenia subdivision code. + * + * ISO 3166-1 alpha-2: AM + */ +class AmSubdivisionCodeException extends SubdivisionCodeException +{ + public static $defaultTemplates = array( + self::MODE_DEFAULT => array( + self::STANDARD => '{{name}} must be a subdivision code of Armenia', + ), + self::MODE_NEGATIVE => array( + self::STANDARD => '{{name}} must not be a subdivision code of Armenia', + ), + ); +} diff --git a/library/Rules/SubdivisionCode/AmSubdivisionCode.php b/library/Rules/SubdivisionCode/AmSubdivisionCode.php new file mode 100644 index 00000000..4b6babe4 --- /dev/null +++ b/library/Rules/SubdivisionCode/AmSubdivisionCode.php @@ -0,0 +1,40 @@ + + * + * 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 Armenia subdivision code. + * + * ISO 3166-1 alpha-2: AM + * + * @link http://www.geonames.org/AM/administrative-division-armenia.html + */ +class AmSubdivisionCode extends AbstractSearcher +{ + public $haystack = array( + 'AG', // Aragatsotn + 'AR', // Ararat + 'AV', // Armavir + 'ER', // Yerevan + 'GR', // Geghark'unik' + 'KT', // Kotayk' + 'LO', // Lorri + 'SH', // Shirak + 'SU', // Syunik' + 'TV', // Tavush + 'VD', // Vayots' Dzor + ); + + public $compareIdentical = true; +}