From 5bd1fbe04dc1394615f5334ecbdf8566b28a38d2 Mon Sep 17 00:00:00 2001 From: Henrique Moody Date: Mon, 21 Sep 2015 13:26:33 -0300 Subject: [PATCH] Create "AsSubdivisionCode" rule --- .../AsSubdivisionCodeException.php | 31 +++++++++++++++++ .../SubdivisionCode/AsSubdivisionCode.php | 34 +++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 library/Exceptions/SubdivisionCode/AsSubdivisionCodeException.php create mode 100644 library/Rules/SubdivisionCode/AsSubdivisionCode.php diff --git a/library/Exceptions/SubdivisionCode/AsSubdivisionCodeException.php b/library/Exceptions/SubdivisionCode/AsSubdivisionCodeException.php new file mode 100644 index 00000000..81b5b91a --- /dev/null +++ b/library/Exceptions/SubdivisionCode/AsSubdivisionCodeException.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 American Samoa subdivision code. + * + * ISO 3166-1 alpha-2: AS + */ +class AsSubdivisionCodeException extends SubdivisionCodeException +{ + public static $defaultTemplates = array( + self::MODE_DEFAULT => array( + self::STANDARD => '{{name}} must be a subdivision code of American Samoa', + ), + self::MODE_NEGATIVE => array( + self::STANDARD => '{{name}} must not be a subdivision code of American Samoa', + ), + ); +} diff --git a/library/Rules/SubdivisionCode/AsSubdivisionCode.php b/library/Rules/SubdivisionCode/AsSubdivisionCode.php new file mode 100644 index 00000000..7bbf5f92 --- /dev/null +++ b/library/Rules/SubdivisionCode/AsSubdivisionCode.php @@ -0,0 +1,34 @@ + + * + * 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 American Samoa subdivision code. + * + * ISO 3166-1 alpha-2: AS + * + * @link http://www.geonames.org/AS/administrative-division-american-samoa.html + */ +class AsSubdivisionCode extends AbstractSearcher +{ + public $haystack = array( + 'E', // Eastern + 'M', // Manu'a + 'R', // Rose Island + 'S', // Swains Island + 'W', // Western + ); + + public $compareIdentical = true; +}