From a42d26169e81065ccbd6ea39b461cb58318d4891 Mon Sep 17 00:00:00 2001 From: Henrique Moody Date: Mon, 21 Sep 2015 13:28:00 -0300 Subject: [PATCH] Create "ZmSubdivisionCode" rule --- .../ZmSubdivisionCodeException.php | 31 +++++++++++++++ .../SubdivisionCode/ZmSubdivisionCode.php | 38 +++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 library/Exceptions/SubdivisionCode/ZmSubdivisionCodeException.php create mode 100644 library/Rules/SubdivisionCode/ZmSubdivisionCode.php diff --git a/library/Exceptions/SubdivisionCode/ZmSubdivisionCodeException.php b/library/Exceptions/SubdivisionCode/ZmSubdivisionCodeException.php new file mode 100644 index 00000000..c3d574a9 --- /dev/null +++ b/library/Exceptions/SubdivisionCode/ZmSubdivisionCodeException.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 Zambia subdivision code. + * + * ISO 3166-1 alpha-2: ZM + */ +class ZmSubdivisionCodeException extends SubdivisionCodeException +{ + public static $defaultTemplates = array( + self::MODE_DEFAULT => array( + self::STANDARD => '{{name}} must be a subdivision code of Zambia', + ), + self::MODE_NEGATIVE => array( + self::STANDARD => '{{name}} must not be a subdivision code of Zambia', + ), + ); +} diff --git a/library/Rules/SubdivisionCode/ZmSubdivisionCode.php b/library/Rules/SubdivisionCode/ZmSubdivisionCode.php new file mode 100644 index 00000000..000f4bd5 --- /dev/null +++ b/library/Rules/SubdivisionCode/ZmSubdivisionCode.php @@ -0,0 +1,38 @@ + + * + * 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 Zambia subdivision code. + * + * ISO 3166-1 alpha-2: ZM + * + * @link http://www.geonames.org/ZM/administrative-division-zambia.html + */ +class ZmSubdivisionCode extends AbstractSearcher +{ + public $haystack = array( + '01', // Western Province + '02', // Central Province + '03', // Eastern Province + '04', // Luapula Province + '05', // Northern Province + '06', // North-Western Province + '07', // Southern Province + '08', // Copperbelt Province + '09', // Lusaka Province + ); + + public $compareIdentical = true; +}