From eda0167c91bc2618790202c6da74a9435b682870 Mon Sep 17 00:00:00 2001 From: Henrique Moody Date: Mon, 21 Sep 2015 13:27:25 -0300 Subject: [PATCH] Create "MwSubdivisionCode" rule --- .../MwSubdivisionCodeException.php | 31 ++++++++++ .../SubdivisionCode/MwSubdivisionCode.php | 60 +++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 library/Exceptions/SubdivisionCode/MwSubdivisionCodeException.php create mode 100644 library/Rules/SubdivisionCode/MwSubdivisionCode.php diff --git a/library/Exceptions/SubdivisionCode/MwSubdivisionCodeException.php b/library/Exceptions/SubdivisionCode/MwSubdivisionCodeException.php new file mode 100644 index 00000000..70c8f0cf --- /dev/null +++ b/library/Exceptions/SubdivisionCode/MwSubdivisionCodeException.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 Malawi subdivision code. + * + * ISO 3166-1 alpha-2: MW + */ +class MwSubdivisionCodeException extends SubdivisionCodeException +{ + public static $defaultTemplates = array( + self::MODE_DEFAULT => array( + self::STANDARD => '{{name}} must be a subdivision code of Malawi', + ), + self::MODE_NEGATIVE => array( + self::STANDARD => '{{name}} must not be a subdivision code of Malawi', + ), + ); +} diff --git a/library/Rules/SubdivisionCode/MwSubdivisionCode.php b/library/Rules/SubdivisionCode/MwSubdivisionCode.php new file mode 100644 index 00000000..80e78cfc --- /dev/null +++ b/library/Rules/SubdivisionCode/MwSubdivisionCode.php @@ -0,0 +1,60 @@ + + * + * 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 Malawi subdivision code. + * + * ISO 3166-1 alpha-2: MW + * + * @link http://www.geonames.org/MW/administrative-division-malawi.html + */ +class MwSubdivisionCode extends AbstractSearcher +{ + public $haystack = array( + 'C', // Central + 'N', // Northern + 'S', // Southern + 'BA', // Balaka + 'BL', // Blantyre + 'CK', // Chikwawa + 'CR', // Chiradzulu + 'CT', // Chitipa + 'DE', // Dedza + 'DO', // Dowa + 'KR', // Karonga + 'KS', // Kasungu + 'LI', // Lilongwe + 'LK', // Likoma + 'MC', // Mchinji + 'MG', // Mangochi + 'MH', // Machinga + 'MU', // Mulanje + 'MW', // Mwanza + 'MZ', // Mzimba + 'NB', // Nkhata Bay + 'NE', // Neno + 'NI', // Ntchisi + 'NK', // Nkhotakota + 'NS', // Nsanje + 'NU', // Ntcheu + 'PH', // Phalombe + 'RU', // Rumphi + 'SA', // Salima + 'TH', // Thyolo + 'ZO', // Zomba + ); + + public $compareIdentical = true; +}