From ab8152aa5b89b60c2894edd51985e381d8a69ca3 Mon Sep 17 00:00:00 2001 From: Henrique Moody Date: Mon, 21 Sep 2015 13:27:12 -0300 Subject: [PATCH] Create "KmSubdivisionCode" rule --- .../KmSubdivisionCodeException.php | 31 ++++++++++++++++++ .../SubdivisionCode/KmSubdivisionCode.php | 32 +++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 library/Exceptions/SubdivisionCode/KmSubdivisionCodeException.php create mode 100644 library/Rules/SubdivisionCode/KmSubdivisionCode.php diff --git a/library/Exceptions/SubdivisionCode/KmSubdivisionCodeException.php b/library/Exceptions/SubdivisionCode/KmSubdivisionCodeException.php new file mode 100644 index 00000000..cc1084f2 --- /dev/null +++ b/library/Exceptions/SubdivisionCode/KmSubdivisionCodeException.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 Comoros subdivision code. + * + * ISO 3166-1 alpha-2: KM + */ +class KmSubdivisionCodeException extends SubdivisionCodeException +{ + public static $defaultTemplates = array( + self::MODE_DEFAULT => array( + self::STANDARD => '{{name}} must be a subdivision code of Comoros', + ), + self::MODE_NEGATIVE => array( + self::STANDARD => '{{name}} must not be a subdivision code of Comoros', + ), + ); +} diff --git a/library/Rules/SubdivisionCode/KmSubdivisionCode.php b/library/Rules/SubdivisionCode/KmSubdivisionCode.php new file mode 100644 index 00000000..a89ba5e4 --- /dev/null +++ b/library/Rules/SubdivisionCode/KmSubdivisionCode.php @@ -0,0 +1,32 @@ + + * + * 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 Comoros subdivision code. + * + * ISO 3166-1 alpha-2: KM + * + * @link http://www.geonames.org/KM/administrative-division-comoros.html + */ +class KmSubdivisionCode extends AbstractSearcher +{ + public $haystack = array( + 'A', // Anjouan + 'G', // Grande Comore + 'M', // Moheli + ); + + public $compareIdentical = true; +}