From ecfe8c5c343e33e9f11385bdc76cf56b2185c2b2 Mon Sep 17 00:00:00 2001 From: Henrique Moody Date: Mon, 21 Sep 2015 13:27:47 -0300 Subject: [PATCH] Create "SsSubdivisionCode" rule --- .../SsSubdivisionCodeException.php | 31 +++++++++++++++ .../SubdivisionCode/SsSubdivisionCode.php | 39 +++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 library/Exceptions/SubdivisionCode/SsSubdivisionCodeException.php create mode 100644 library/Rules/SubdivisionCode/SsSubdivisionCode.php diff --git a/library/Exceptions/SubdivisionCode/SsSubdivisionCodeException.php b/library/Exceptions/SubdivisionCode/SsSubdivisionCodeException.php new file mode 100644 index 00000000..9d5bbe24 --- /dev/null +++ b/library/Exceptions/SubdivisionCode/SsSubdivisionCodeException.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 South Sudan subdivision code. + * + * ISO 3166-1 alpha-2: SS + */ +class SsSubdivisionCodeException extends SubdivisionCodeException +{ + public static $defaultTemplates = array( + self::MODE_DEFAULT => array( + self::STANDARD => '{{name}} must be a subdivision code of South Sudan', + ), + self::MODE_NEGATIVE => array( + self::STANDARD => '{{name}} must not be a subdivision code of South Sudan', + ), + ); +} diff --git a/library/Rules/SubdivisionCode/SsSubdivisionCode.php b/library/Rules/SubdivisionCode/SsSubdivisionCode.php new file mode 100644 index 00000000..209c1fb7 --- /dev/null +++ b/library/Rules/SubdivisionCode/SsSubdivisionCode.php @@ -0,0 +1,39 @@ + + * + * 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 South Sudan subdivision code. + * + * ISO 3166-1 alpha-2: SS + * + * @link http://www.geonames.org/SS/administrative-division-south-sudan.html + */ +class SsSubdivisionCode extends AbstractSearcher +{ + public $haystack = array( + 'BN', // Northern Bahr el Ghazal + 'BW', // Western Bahr el Ghazal + 'EC', // Central Equatoria + 'EE', // Eastern Equatoria + 'EW', // Western Equatoria + 'JG', // Jonglei + 'LK', // Lakes + 'NU', // Upper Nile + 'UY', // Unity + 'WR', // Warrap + ); + + public $compareIdentical = true; +}