From 31377a974d817c277eab663c195327fb9594f266 Mon Sep 17 00:00:00 2001 From: Henrique Moody Date: Mon, 21 Sep 2015 13:27:06 -0300 Subject: [PATCH] Create "IeSubdivisionCode" rule --- .../IeSubdivisionCodeException.php | 31 ++++++++++ .../SubdivisionCode/IeSubdivisionCode.php | 59 +++++++++++++++++++ 2 files changed, 90 insertions(+) create mode 100644 library/Exceptions/SubdivisionCode/IeSubdivisionCodeException.php create mode 100644 library/Rules/SubdivisionCode/IeSubdivisionCode.php diff --git a/library/Exceptions/SubdivisionCode/IeSubdivisionCodeException.php b/library/Exceptions/SubdivisionCode/IeSubdivisionCodeException.php new file mode 100644 index 00000000..44a051d0 --- /dev/null +++ b/library/Exceptions/SubdivisionCode/IeSubdivisionCodeException.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 Ireland subdivision code. + * + * ISO 3166-1 alpha-2: IE + */ +class IeSubdivisionCodeException extends SubdivisionCodeException +{ + public static $defaultTemplates = array( + self::MODE_DEFAULT => array( + self::STANDARD => '{{name}} must be a subdivision code of Ireland', + ), + self::MODE_NEGATIVE => array( + self::STANDARD => '{{name}} must not be a subdivision code of Ireland', + ), + ); +} diff --git a/library/Rules/SubdivisionCode/IeSubdivisionCode.php b/library/Rules/SubdivisionCode/IeSubdivisionCode.php new file mode 100644 index 00000000..79d7a2eb --- /dev/null +++ b/library/Rules/SubdivisionCode/IeSubdivisionCode.php @@ -0,0 +1,59 @@ + + * + * 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 Ireland subdivision code. + * + * ISO 3166-1 alpha-2: IE + * + * @link http://www.geonames.org/IE/administrative-division-ireland.html + */ +class IeSubdivisionCode extends AbstractSearcher +{ + public $haystack = array( + 'C', // Connaught + 'L', // Leinster + 'M', // Munster + 'U', // Ulster + 'C', // Cork + 'CE', // Clare + 'CN', // Cavan + 'CW', // Carlow + 'D', // Dublin + 'DL', // Donegal + 'G', // Galway + 'KE', // Kildare + 'KK', // Kilkenny + 'KY', // Kerry + 'LD', // Longford + 'LH', // Louth + 'LK', // Limerick + 'LM', // Leitrim + 'LS', // Laois + 'MH', // Meath + 'MN', // Monaghan + 'MO', // Mayo + 'OY', // Offaly + 'RN', // Roscommon + 'SO', // Sligo + 'TA', // Tipperary + 'WD', // Waterford + 'WH', // Westmeath + 'WW', // Wicklow + 'WX', // Wexford + ); + + public $compareIdentical = true; +}