From a07846101fbddfdb3353e3b42a253c87fc3cfecf Mon Sep 17 00:00:00 2001 From: Henrique Moody Date: Mon, 21 Sep 2015 13:26:56 -0300 Subject: [PATCH] Create "ErSubdivisionCode" rule --- .../ErSubdivisionCodeException.php | 31 ++++++++++++++++ .../SubdivisionCode/ErSubdivisionCode.php | 35 +++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 library/Exceptions/SubdivisionCode/ErSubdivisionCodeException.php create mode 100644 library/Rules/SubdivisionCode/ErSubdivisionCode.php diff --git a/library/Exceptions/SubdivisionCode/ErSubdivisionCodeException.php b/library/Exceptions/SubdivisionCode/ErSubdivisionCodeException.php new file mode 100644 index 00000000..db7b1ebc --- /dev/null +++ b/library/Exceptions/SubdivisionCode/ErSubdivisionCodeException.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 Eritrea subdivision code. + * + * ISO 3166-1 alpha-2: ER + */ +class ErSubdivisionCodeException extends SubdivisionCodeException +{ + public static $defaultTemplates = array( + self::MODE_DEFAULT => array( + self::STANDARD => '{{name}} must be a subdivision code of Eritrea', + ), + self::MODE_NEGATIVE => array( + self::STANDARD => '{{name}} must not be a subdivision code of Eritrea', + ), + ); +} diff --git a/library/Rules/SubdivisionCode/ErSubdivisionCode.php b/library/Rules/SubdivisionCode/ErSubdivisionCode.php new file mode 100644 index 00000000..83f17748 --- /dev/null +++ b/library/Rules/SubdivisionCode/ErSubdivisionCode.php @@ -0,0 +1,35 @@ + + * + * 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 Eritrea subdivision code. + * + * ISO 3166-1 alpha-2: ER + * + * @link http://www.geonames.org/ER/administrative-division-eritrea.html + */ +class ErSubdivisionCode extends AbstractSearcher +{ + public $haystack = array( + 'AN', // Anseba (Keren) + 'DK', // Southern Red Sea (Debub-Keih-Bahri) + 'DU', // Southern (Debub) + 'GB', // Gash-Barka (Barentu) + 'MA', // Central (Maekel) + 'SK', // Northern Red Sea (Semien-Keih-Bahri) + ); + + public $compareIdentical = true; +}