From d067e735b2fd77541b17b01f8bc9b11f2c814f8a Mon Sep 17 00:00:00 2001 From: Henrique Moody Date: Mon, 21 Sep 2015 13:27:27 -0300 Subject: [PATCH] Create "MzSubdivisionCode" rule --- .../MzSubdivisionCodeException.php | 31 ++++++++++++++ .../SubdivisionCode/MzSubdivisionCode.php | 40 +++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 library/Exceptions/SubdivisionCode/MzSubdivisionCodeException.php create mode 100644 library/Rules/SubdivisionCode/MzSubdivisionCode.php diff --git a/library/Exceptions/SubdivisionCode/MzSubdivisionCodeException.php b/library/Exceptions/SubdivisionCode/MzSubdivisionCodeException.php new file mode 100644 index 00000000..009a6f1c --- /dev/null +++ b/library/Exceptions/SubdivisionCode/MzSubdivisionCodeException.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 Mozambique subdivision code. + * + * ISO 3166-1 alpha-2: MZ + */ +class MzSubdivisionCodeException extends SubdivisionCodeException +{ + public static $defaultTemplates = array( + self::MODE_DEFAULT => array( + self::STANDARD => '{{name}} must be a subdivision code of Mozambique', + ), + self::MODE_NEGATIVE => array( + self::STANDARD => '{{name}} must not be a subdivision code of Mozambique', + ), + ); +} diff --git a/library/Rules/SubdivisionCode/MzSubdivisionCode.php b/library/Rules/SubdivisionCode/MzSubdivisionCode.php new file mode 100644 index 00000000..90be0d44 --- /dev/null +++ b/library/Rules/SubdivisionCode/MzSubdivisionCode.php @@ -0,0 +1,40 @@ + + * + * 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 Mozambique subdivision code. + * + * ISO 3166-1 alpha-2: MZ + * + * @link http://www.geonames.org/MZ/administrative-division-mozambique.html + */ +class MzSubdivisionCode extends AbstractSearcher +{ + public $haystack = array( + 'A', // Niassa + 'B', // Manica + 'G', // Gaza + 'I', // Inhambane + 'L', // Maputo + 'MPM', // Maputo (city) + 'N', // Nampula + 'P', // Cabo Delgado + 'Q', // Zambezia + 'S', // Sofala + 'T', // Tete + ); + + public $compareIdentical = true; +}