From 5adcbaeff82df12772e1bf64ec92e03408e9c49c Mon Sep 17 00:00:00 2001 From: Henrique Moody Date: Mon, 21 Sep 2015 13:27:09 -0300 Subject: [PATCH] Create "JeSubdivisionCode" rule --- .../JeSubdivisionCodeException.php | 31 +++++++++++++++++++ .../SubdivisionCode/JeSubdivisionCode.php | 28 +++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 library/Exceptions/SubdivisionCode/JeSubdivisionCodeException.php create mode 100644 library/Rules/SubdivisionCode/JeSubdivisionCode.php diff --git a/library/Exceptions/SubdivisionCode/JeSubdivisionCodeException.php b/library/Exceptions/SubdivisionCode/JeSubdivisionCodeException.php new file mode 100644 index 00000000..8e4aab0c --- /dev/null +++ b/library/Exceptions/SubdivisionCode/JeSubdivisionCodeException.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 Jersey subdivision code. + * + * ISO 3166-1 alpha-2: JE + */ +class JeSubdivisionCodeException extends SubdivisionCodeException +{ + public static $defaultTemplates = array( + self::MODE_DEFAULT => array( + self::STANDARD => '{{name}} must be a subdivision code of Jersey', + ), + self::MODE_NEGATIVE => array( + self::STANDARD => '{{name}} must not be a subdivision code of Jersey', + ), + ); +} diff --git a/library/Rules/SubdivisionCode/JeSubdivisionCode.php b/library/Rules/SubdivisionCode/JeSubdivisionCode.php new file mode 100644 index 00000000..c85881d2 --- /dev/null +++ b/library/Rules/SubdivisionCode/JeSubdivisionCode.php @@ -0,0 +1,28 @@ + + * + * 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 Jersey subdivision code. + * + * ISO 3166-1 alpha-2: JE + * + * @link http://www.geonames.org/JE/administrative-division-jersey.html + */ +class JeSubdivisionCode extends AbstractSearcher +{ + public $haystack = array(null, ''); + + public $compareIdentical = true; +}