From db2ff066243f4df021fcde07b6672397579e9fe7 Mon Sep 17 00:00:00 2001 From: Henrique Moody Date: Mon, 21 Sep 2015 13:27:15 -0300 Subject: [PATCH] Create "LkSubdivisionCode" rule --- .../LkSubdivisionCodeException.php | 31 +++++++++ .../SubdivisionCode/LkSubdivisionCode.php | 63 +++++++++++++++++++ 2 files changed, 94 insertions(+) create mode 100644 library/Exceptions/SubdivisionCode/LkSubdivisionCodeException.php create mode 100644 library/Rules/SubdivisionCode/LkSubdivisionCode.php diff --git a/library/Exceptions/SubdivisionCode/LkSubdivisionCodeException.php b/library/Exceptions/SubdivisionCode/LkSubdivisionCodeException.php new file mode 100644 index 00000000..a34d46de --- /dev/null +++ b/library/Exceptions/SubdivisionCode/LkSubdivisionCodeException.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 Sri Lanka subdivision code. + * + * ISO 3166-1 alpha-2: LK + */ +class LkSubdivisionCodeException extends SubdivisionCodeException +{ + public static $defaultTemplates = array( + self::MODE_DEFAULT => array( + self::STANDARD => '{{name}} must be a subdivision code of Sri Lanka', + ), + self::MODE_NEGATIVE => array( + self::STANDARD => '{{name}} must not be a subdivision code of Sri Lanka', + ), + ); +} diff --git a/library/Rules/SubdivisionCode/LkSubdivisionCode.php b/library/Rules/SubdivisionCode/LkSubdivisionCode.php new file mode 100644 index 00000000..a83ef99c --- /dev/null +++ b/library/Rules/SubdivisionCode/LkSubdivisionCode.php @@ -0,0 +1,63 @@ + + * + * 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 Sri Lanka subdivision code. + * + * ISO 3166-1 alpha-2: LK + * + * @link http://www.geonames.org/LK/administrative-division-sri-lanka.html + */ +class LkSubdivisionCode extends AbstractSearcher +{ + public $haystack = array( + '1', // Western + '2', // Central + '3', // Southern + '4', // Northern + '5', // Eastern + '6', // North Western + '7', // North Central + '8', // Uva + '9', // Sabaragamuwa + '11', // Kŏḷamba + '12', // Gampaha + '13', // Kaḷutara + '21', // Mahanuvara + '22', // Mātale + '23', // Nuvara Ĕliya + '31', // Gālla + '32', // Mātara + '33', // Hambantŏṭa + '41', // Yāpanaya + '42', // Kilinŏchchi + '43', // Mannārama + '44', // Vavuniyāva + '45', // Mulativ + '51', // Maḍakalapuva + '52', // Ampāra + '53', // Trikuṇāmalaya + '61', // Kuruṇægala + '62', // Puttalama + '71', // Anurādhapura + '72', // Pŏḷŏnnaruva + '81', // Badulla + '82', // Mŏṇarāgala + '91', // Ratnapura + '92', // Kægalla + ); + + public $compareIdentical = true; +}