From 3d02ab2ef0a52dd5f2b62def83181de2e7dea563 Mon Sep 17 00:00:00 2001 From: Henrique Moody Date: Mon, 21 Sep 2015 13:27:05 -0300 Subject: [PATCH] Create "IdSubdivisionCode" rule --- .../IdSubdivisionCodeException.php | 31 ++++++++ .../SubdivisionCode/IdSubdivisionCode.php | 70 +++++++++++++++++++ 2 files changed, 101 insertions(+) create mode 100644 library/Exceptions/SubdivisionCode/IdSubdivisionCodeException.php create mode 100644 library/Rules/SubdivisionCode/IdSubdivisionCode.php diff --git a/library/Exceptions/SubdivisionCode/IdSubdivisionCodeException.php b/library/Exceptions/SubdivisionCode/IdSubdivisionCodeException.php new file mode 100644 index 00000000..04df18ea --- /dev/null +++ b/library/Exceptions/SubdivisionCode/IdSubdivisionCodeException.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 Indonesia subdivision code. + * + * ISO 3166-1 alpha-2: ID + */ +class IdSubdivisionCodeException extends SubdivisionCodeException +{ + public static $defaultTemplates = array( + self::MODE_DEFAULT => array( + self::STANDARD => '{{name}} must be a subdivision code of Indonesia', + ), + self::MODE_NEGATIVE => array( + self::STANDARD => '{{name}} must not be a subdivision code of Indonesia', + ), + ); +} diff --git a/library/Rules/SubdivisionCode/IdSubdivisionCode.php b/library/Rules/SubdivisionCode/IdSubdivisionCode.php new file mode 100644 index 00000000..9a13cefd --- /dev/null +++ b/library/Rules/SubdivisionCode/IdSubdivisionCode.php @@ -0,0 +1,70 @@ + + * + * 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 Indonesia subdivision code. + * + * ISO 3166-1 alpha-2: ID + * + * @link http://www.geonames.org/ID/administrative-division-indonesia.html + */ +class IdSubdivisionCode extends AbstractSearcher +{ + public $haystack = array( + 'IJ', // Papua + 'JW', // Java + 'KA', // Kalimantan + 'MA', // Maluku + 'NU', // Nusa Tenggara + 'SL', // Sulawesi + 'SM', // Sumatera + 'AC', // Aceh + 'BA', // Bali + 'BB', // Bangka-Belitung + 'BE', // Bengkulu + 'BT', // Banten + 'GO', // Gorontalo + 'JA', // Jambi + 'JB', // Jawa Barat + 'JI', // Jawa Timur + 'JK', // Jakarta Raya + 'JT', // Jawa Tengah + 'KB', // Kalimantan Barat + 'KI', // Kalimantan Timur + 'KI', // Kalimantan Utara + 'KR', // Kepulauan Riau + 'KS', // Kalimantan Selatan + 'KT', // Kalimantan Tengah + 'LA', // Lampung + 'MA', // Maluku + 'MU', // Maluku Utara + 'NB', // Nusa Tenggara Barat + 'NT', // Nusa Tenggara Timur + 'PA', // Papua + 'PB', // Papua Barat + 'RI', // Riau + 'SA', // Sulawesi Utara + 'SB', // Sumatera Barat + 'SG', // Sulawesi Tenggara + 'SN', // Sulawesi Selatan + 'SR', // Sulawesi Barat + 'SS', // Sumatera Selatan + 'ST', // Sulawesi Tengah + 'SU', // Sumatera Utara + 'YO', // Yogyakarta + ); + + public $compareIdentical = true; +}