From 264cd1bdd98984ed0de0acd727304b432d976fc7 Mon Sep 17 00:00:00 2001 From: Henrique Moody Date: Mon, 21 Sep 2015 13:27:45 -0300 Subject: [PATCH] Create "SkSubdivisionCode" rule --- .../SkSubdivisionCodeException.php | 31 ++++++++++++++++ .../SubdivisionCode/SkSubdivisionCode.php | 37 +++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 library/Exceptions/SubdivisionCode/SkSubdivisionCodeException.php create mode 100644 library/Rules/SubdivisionCode/SkSubdivisionCode.php diff --git a/library/Exceptions/SubdivisionCode/SkSubdivisionCodeException.php b/library/Exceptions/SubdivisionCode/SkSubdivisionCodeException.php new file mode 100644 index 00000000..b2b0f15f --- /dev/null +++ b/library/Exceptions/SubdivisionCode/SkSubdivisionCodeException.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 Slovakia subdivision code. + * + * ISO 3166-1 alpha-2: SK + */ +class SkSubdivisionCodeException extends SubdivisionCodeException +{ + public static $defaultTemplates = array( + self::MODE_DEFAULT => array( + self::STANDARD => '{{name}} must be a subdivision code of Slovakia', + ), + self::MODE_NEGATIVE => array( + self::STANDARD => '{{name}} must not be a subdivision code of Slovakia', + ), + ); +} diff --git a/library/Rules/SubdivisionCode/SkSubdivisionCode.php b/library/Rules/SubdivisionCode/SkSubdivisionCode.php new file mode 100644 index 00000000..6982771d --- /dev/null +++ b/library/Rules/SubdivisionCode/SkSubdivisionCode.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 Slovakia subdivision code. + * + * ISO 3166-1 alpha-2: SK + * + * @link http://www.geonames.org/SK/administrative-division-slovakia.html + */ +class SkSubdivisionCode extends AbstractSearcher +{ + public $haystack = array( + 'BC', // Banskobystricky + 'BL', // Bratislavsky + 'KI', // Kosicky + 'NI', // Nitriansky + 'PV', // Presovsky + 'TA', // Trnavsky + 'TC', // Trenciansky + 'ZI', // Zilinsky + ); + + public $compareIdentical = true; +}