From 2be2120b20d6a014cc95770a4bac1b20ffef4f95 Mon Sep 17 00:00:00 2001 From: Henrique Moody Date: Mon, 21 Sep 2015 13:27:31 -0300 Subject: [PATCH] Create "NzSubdivisionCode" rule --- .../NzSubdivisionCodeException.php | 31 ++++++++++++ .../SubdivisionCode/NzSubdivisionCode.php | 48 +++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 library/Exceptions/SubdivisionCode/NzSubdivisionCodeException.php create mode 100644 library/Rules/SubdivisionCode/NzSubdivisionCode.php diff --git a/library/Exceptions/SubdivisionCode/NzSubdivisionCodeException.php b/library/Exceptions/SubdivisionCode/NzSubdivisionCodeException.php new file mode 100644 index 00000000..a5deadfa --- /dev/null +++ b/library/Exceptions/SubdivisionCode/NzSubdivisionCodeException.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 New Zealand subdivision code. + * + * ISO 3166-1 alpha-2: NZ + */ +class NzSubdivisionCodeException extends SubdivisionCodeException +{ + public static $defaultTemplates = array( + self::MODE_DEFAULT => array( + self::STANDARD => '{{name}} must be a subdivision code of New Zealand', + ), + self::MODE_NEGATIVE => array( + self::STANDARD => '{{name}} must not be a subdivision code of New Zealand', + ), + ); +} diff --git a/library/Rules/SubdivisionCode/NzSubdivisionCode.php b/library/Rules/SubdivisionCode/NzSubdivisionCode.php new file mode 100644 index 00000000..a26d1c2b --- /dev/null +++ b/library/Rules/SubdivisionCode/NzSubdivisionCode.php @@ -0,0 +1,48 @@ + + * + * 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 New Zealand subdivision code. + * + * ISO 3166-1 alpha-2: NZ + * + * @link http://www.geonames.org/NZ/administrative-division-new-zealand.html + */ +class NzSubdivisionCode extends AbstractSearcher +{ + public $haystack = array( + 'N', // North Island + 'S', // South Island + 'AUK', // Auckland + 'BOP', // Bay of Plenty + 'CAN', // Canterbury + 'CIT', // Chatham Islands + 'GIS', // Gisborne + 'HKB', // Hawke's Bay + 'MBH', // Marlborough + 'MWT', // Manawatu-Wanganui + 'NSN', // Nelson + 'NTL', // Northland + 'OTA', // Otago + 'STL', // Southland + 'TAS', // Tasman + 'TKI', // Taranaki + 'WGN', // Wellington + 'WKO', // Waikato + 'WTC', // West Coast + ); + + public $compareIdentical = true; +}