From 57a79900111cd530003832e786b211d05ebf55aa Mon Sep 17 00:00:00 2001 From: Henrique Moody Date: Mon, 21 Sep 2015 13:27:14 -0300 Subject: [PATCH] Create "LbSubdivisionCode" rule --- .../LbSubdivisionCodeException.php | 31 ++++++++++++++++ .../SubdivisionCode/LbSubdivisionCode.php | 37 +++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 library/Exceptions/SubdivisionCode/LbSubdivisionCodeException.php create mode 100644 library/Rules/SubdivisionCode/LbSubdivisionCode.php diff --git a/library/Exceptions/SubdivisionCode/LbSubdivisionCodeException.php b/library/Exceptions/SubdivisionCode/LbSubdivisionCodeException.php new file mode 100644 index 00000000..727dea1a --- /dev/null +++ b/library/Exceptions/SubdivisionCode/LbSubdivisionCodeException.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 Lebanon subdivision code. + * + * ISO 3166-1 alpha-2: LB + */ +class LbSubdivisionCodeException extends SubdivisionCodeException +{ + public static $defaultTemplates = array( + self::MODE_DEFAULT => array( + self::STANDARD => '{{name}} must be a subdivision code of Lebanon', + ), + self::MODE_NEGATIVE => array( + self::STANDARD => '{{name}} must not be a subdivision code of Lebanon', + ), + ); +} diff --git a/library/Rules/SubdivisionCode/LbSubdivisionCode.php b/library/Rules/SubdivisionCode/LbSubdivisionCode.php new file mode 100644 index 00000000..9e466692 --- /dev/null +++ b/library/Rules/SubdivisionCode/LbSubdivisionCode.php @@ -0,0 +1,37 @@ + + * + * 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 Lebanon subdivision code. + * + * ISO 3166-1 alpha-2: LB + * + * @link http://www.geonames.org/LB/administrative-division-lebanon.html + */ +class LbSubdivisionCode extends AbstractSearcher +{ + public $haystack = array( + 'AK', // Aakkâr + 'AS', // Liban-Nord + 'BA', // Beyrouth + 'BH', // Baalbek-Hermel + 'BI', // Béqaa + 'JA', // Liban-Sud + 'JL', // Mont-Liban + 'NA', // Nabatîyé + ); + + public $compareIdentical = true; +}