From 95cfd72e76b0f0d9d8cbfcb5fa5e2c3bc981aae4 Mon Sep 17 00:00:00 2001 From: Henrique Moody Date: Mon, 21 Sep 2015 13:26:31 -0300 Subject: [PATCH] Create "AdSubdivisionCode" rule --- .../AdSubdivisionCodeException.php | 31 ++++++++++++++++ .../SubdivisionCode/AdSubdivisionCode.php | 36 +++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 library/Exceptions/SubdivisionCode/AdSubdivisionCodeException.php create mode 100644 library/Rules/SubdivisionCode/AdSubdivisionCode.php diff --git a/library/Exceptions/SubdivisionCode/AdSubdivisionCodeException.php b/library/Exceptions/SubdivisionCode/AdSubdivisionCodeException.php new file mode 100644 index 00000000..858b1dc9 --- /dev/null +++ b/library/Exceptions/SubdivisionCode/AdSubdivisionCodeException.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 Andorra subdivision code. + * + * ISO 3166-1 alpha-2: AD + */ +class AdSubdivisionCodeException extends SubdivisionCodeException +{ + public static $defaultTemplates = array( + self::MODE_DEFAULT => array( + self::STANDARD => '{{name}} must be a subdivision code of Andorra', + ), + self::MODE_NEGATIVE => array( + self::STANDARD => '{{name}} must not be a subdivision code of Andorra', + ), + ); +} diff --git a/library/Rules/SubdivisionCode/AdSubdivisionCode.php b/library/Rules/SubdivisionCode/AdSubdivisionCode.php new file mode 100644 index 00000000..9e5e9dc0 --- /dev/null +++ b/library/Rules/SubdivisionCode/AdSubdivisionCode.php @@ -0,0 +1,36 @@ + + * + * 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 Andorra subdivision code. + * + * ISO 3166-1 alpha-2: AD + * + * @link http://www.geonames.org/AD/administrative-division-andorra.html + */ +class AdSubdivisionCode extends AbstractSearcher +{ + public $haystack = array( + '02', // Canillo + '03', // Encamp + '04', // La Massana + '05', // Ordino + '06', // Sant Julia de Lòria + '07', // Andorra la Vella + '08', // Escaldes-Engordany + ); + + public $compareIdentical = true; +}