From 48fcdbdb549222fe5ce5bdbebd40b558572f87b3 Mon Sep 17 00:00:00 2001 From: Henrique Moody Date: Mon, 21 Sep 2015 13:27:18 -0300 Subject: [PATCH] Create "LySubdivisionCode" rule --- .../LySubdivisionCodeException.php | 31 +++++++++++ .../SubdivisionCode/LySubdivisionCode.php | 51 +++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 library/Exceptions/SubdivisionCode/LySubdivisionCodeException.php create mode 100644 library/Rules/SubdivisionCode/LySubdivisionCode.php diff --git a/library/Exceptions/SubdivisionCode/LySubdivisionCodeException.php b/library/Exceptions/SubdivisionCode/LySubdivisionCodeException.php new file mode 100644 index 00000000..0e20c569 --- /dev/null +++ b/library/Exceptions/SubdivisionCode/LySubdivisionCodeException.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 Libya subdivision code. + * + * ISO 3166-1 alpha-2: LY + */ +class LySubdivisionCodeException extends SubdivisionCodeException +{ + public static $defaultTemplates = array( + self::MODE_DEFAULT => array( + self::STANDARD => '{{name}} must be a subdivision code of Libya', + ), + self::MODE_NEGATIVE => array( + self::STANDARD => '{{name}} must not be a subdivision code of Libya', + ), + ); +} diff --git a/library/Rules/SubdivisionCode/LySubdivisionCode.php b/library/Rules/SubdivisionCode/LySubdivisionCode.php new file mode 100644 index 00000000..41224ee8 --- /dev/null +++ b/library/Rules/SubdivisionCode/LySubdivisionCode.php @@ -0,0 +1,51 @@ + + * + * 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 Libya subdivision code. + * + * ISO 3166-1 alpha-2: LY + * + * @link http://www.geonames.org/LY/administrative-division-libya.html + */ +class LySubdivisionCode extends AbstractSearcher +{ + public $haystack = array( + 'BA', // Banghazi + 'BU', // Al Buţnān + 'DR', // Darnah + 'GT', // Ghāt + 'JA', // Al Jabal al Akhdar + 'JG', // Al Jabal al Gharbī + 'JI', // Al Jifārah + 'JU', // Al Jufrah + 'KF', // Al Kufrah + 'MB', // Al Marqab + 'MI', // Misratah + 'MJ', // Al Maraj + 'MQ', // Murzuq + 'NL', // Nālūt + 'NQ', // An Nuqat al Khams + 'SB', // Sabha + 'SR', // Surt + 'TB', // Ţarābulus + 'WA', // Al Wāḩāt + 'WD', // Wādī al Ḩayāt + 'WS', // Wādī ash Shāţi´ + 'ZA', // Az Zawiyah + ); + + public $compareIdentical = true; +}