From b42f0e8088d97bdf8108ba765bbd76f367c05cd4 Mon Sep 17 00:00:00 2001 From: Henrique Moody Date: Mon, 21 Sep 2015 13:27:12 -0300 Subject: [PATCH] Create "KrSubdivisionCode" rule --- .../KrSubdivisionCodeException.php | 31 +++++++++++++ .../SubdivisionCode/KrSubdivisionCode.php | 45 +++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 library/Exceptions/SubdivisionCode/KrSubdivisionCodeException.php create mode 100644 library/Rules/SubdivisionCode/KrSubdivisionCode.php diff --git a/library/Exceptions/SubdivisionCode/KrSubdivisionCodeException.php b/library/Exceptions/SubdivisionCode/KrSubdivisionCodeException.php new file mode 100644 index 00000000..7311a28b --- /dev/null +++ b/library/Exceptions/SubdivisionCode/KrSubdivisionCodeException.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 Korea subdivision code. + * + * ISO 3166-1 alpha-2: KR + */ +class KrSubdivisionCodeException extends SubdivisionCodeException +{ + public static $defaultTemplates = array( + self::MODE_DEFAULT => array( + self::STANDARD => '{{name}} must be a subdivision code of South Korea', + ), + self::MODE_NEGATIVE => array( + self::STANDARD => '{{name}} must not be a subdivision code of South Korea', + ), + ); +} diff --git a/library/Rules/SubdivisionCode/KrSubdivisionCode.php b/library/Rules/SubdivisionCode/KrSubdivisionCode.php new file mode 100644 index 00000000..94edc146 --- /dev/null +++ b/library/Rules/SubdivisionCode/KrSubdivisionCode.php @@ -0,0 +1,45 @@ + + * + * 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 Korea subdivision code. + * + * ISO 3166-1 alpha-2: KR + * + * @link http://www.geonames.org/KR/administrative-division-south-korea.html + */ +class KrSubdivisionCode extends AbstractSearcher +{ + public $haystack = array( + '11', // Seoul Special City + '26', // Busan Metropolitan City + '27', // Daegu Metropolitan City + '28', // Incheon Metropolitan City + '29', // Gwangju Metropolitan City + '30', // Daejeon Metropolitan City + '31', // Ulsan Metropolitan City + '41', // Gyeonggi-do + '42', // Gangwon-do + '43', // Chungcheongbuk-do + '44', // Chungcheongnam-do + '45', // Jeollabuk-do + '46', // Jeollanam-do + '47', // Gyeongsangbuk-do + '48', // Gyeongsangnam-do + '49', // Jeju-do + ); + + public $compareIdentical = true; +}