From e0501c32647ae0bcfc4776f8cacbad0ca7aedc69 Mon Sep 17 00:00:00 2001 From: Henrique Moody Date: Mon, 21 Sep 2015 13:27:44 -0300 Subject: [PATCH] Create "SjSubdivisionCode" rule --- .../SjSubdivisionCodeException.php | 31 +++++++++++++++++++ .../SubdivisionCode/SjSubdivisionCode.php | 31 +++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 library/Exceptions/SubdivisionCode/SjSubdivisionCodeException.php create mode 100644 library/Rules/SubdivisionCode/SjSubdivisionCode.php diff --git a/library/Exceptions/SubdivisionCode/SjSubdivisionCodeException.php b/library/Exceptions/SubdivisionCode/SjSubdivisionCodeException.php new file mode 100644 index 00000000..87c9b8ba --- /dev/null +++ b/library/Exceptions/SubdivisionCode/SjSubdivisionCodeException.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 Svalbard and Jan Mayen subdivision code. + * + * ISO 3166-1 alpha-2: SJ + */ +class SjSubdivisionCodeException extends SubdivisionCodeException +{ + public static $defaultTemplates = array( + self::MODE_DEFAULT => array( + self::STANDARD => '{{name}} must be a subdivision code of Svalbard and Jan Mayen', + ), + self::MODE_NEGATIVE => array( + self::STANDARD => '{{name}} must not be a subdivision code of Svalbard and Jan Mayen', + ), + ); +} diff --git a/library/Rules/SubdivisionCode/SjSubdivisionCode.php b/library/Rules/SubdivisionCode/SjSubdivisionCode.php new file mode 100644 index 00000000..00c7eded --- /dev/null +++ b/library/Rules/SubdivisionCode/SjSubdivisionCode.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\Rules\SubdivisionCode; + +use Respect\Validation\Rules\AbstractSearcher; + +/** + * Validator for Svalbard and Jan Mayen subdivision code. + * + * ISO 3166-1 alpha-2: SJ + * + * @link http://www.geonames.org/SJ/administrative-division-svalbard-and-jan-mayen.html + */ +class SjSubdivisionCode extends AbstractSearcher +{ + public $haystack = array( + '21', // Svalbard + '22', // Jan Mayen + ); + + public $compareIdentical = true; +}