From e43c415cd90b9cc80a83e186eb857bcf7ff58845 Mon Sep 17 00:00:00 2001 From: Henrique Moody Date: Mon, 21 Sep 2015 13:27:06 -0300 Subject: [PATCH] Create "IlSubdivisionCode" rule --- .../IlSubdivisionCodeException.php | 31 ++++++++++++++++ .../SubdivisionCode/IlSubdivisionCode.php | 35 +++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 library/Exceptions/SubdivisionCode/IlSubdivisionCodeException.php create mode 100644 library/Rules/SubdivisionCode/IlSubdivisionCode.php diff --git a/library/Exceptions/SubdivisionCode/IlSubdivisionCodeException.php b/library/Exceptions/SubdivisionCode/IlSubdivisionCodeException.php new file mode 100644 index 00000000..c332c80b --- /dev/null +++ b/library/Exceptions/SubdivisionCode/IlSubdivisionCodeException.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 Israel subdivision code. + * + * ISO 3166-1 alpha-2: IL + */ +class IlSubdivisionCodeException extends SubdivisionCodeException +{ + public static $defaultTemplates = array( + self::MODE_DEFAULT => array( + self::STANDARD => '{{name}} must be a subdivision code of Israel', + ), + self::MODE_NEGATIVE => array( + self::STANDARD => '{{name}} must not be a subdivision code of Israel', + ), + ); +} diff --git a/library/Rules/SubdivisionCode/IlSubdivisionCode.php b/library/Rules/SubdivisionCode/IlSubdivisionCode.php new file mode 100644 index 00000000..f86d745d --- /dev/null +++ b/library/Rules/SubdivisionCode/IlSubdivisionCode.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 Israel subdivision code. + * + * ISO 3166-1 alpha-2: IL + * + * @link http://www.geonames.org/IL/administrative-division-israel.html + */ +class IlSubdivisionCode extends AbstractSearcher +{ + public $haystack = array( + 'D', // Southern + 'HA', // Haifa + 'JM', // Jerusalem + 'M', // Central + 'TA', // Tel Aviv + 'Z', // Northern + ); + + public $compareIdentical = true; +}