From 4a413e0281f4f8022b4351a93ea58ba370bb0cb1 Mon Sep 17 00:00:00 2001 From: Henrique Moody Date: Mon, 21 Sep 2015 13:27:27 -0300 Subject: [PATCH] Create "NcSubdivisionCode" rule --- .../NcSubdivisionCodeException.php | 31 ++++++++++++++++++ .../SubdivisionCode/NcSubdivisionCode.php | 32 +++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 library/Exceptions/SubdivisionCode/NcSubdivisionCodeException.php create mode 100644 library/Rules/SubdivisionCode/NcSubdivisionCode.php diff --git a/library/Exceptions/SubdivisionCode/NcSubdivisionCodeException.php b/library/Exceptions/SubdivisionCode/NcSubdivisionCodeException.php new file mode 100644 index 00000000..a1a901b5 --- /dev/null +++ b/library/Exceptions/SubdivisionCode/NcSubdivisionCodeException.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 Caledonia subdivision code. + * + * ISO 3166-1 alpha-2: NC + */ +class NcSubdivisionCodeException extends SubdivisionCodeException +{ + public static $defaultTemplates = array( + self::MODE_DEFAULT => array( + self::STANDARD => '{{name}} must be a subdivision code of New Caledonia', + ), + self::MODE_NEGATIVE => array( + self::STANDARD => '{{name}} must not be a subdivision code of New Caledonia', + ), + ); +} diff --git a/library/Rules/SubdivisionCode/NcSubdivisionCode.php b/library/Rules/SubdivisionCode/NcSubdivisionCode.php new file mode 100644 index 00000000..7535a2b7 --- /dev/null +++ b/library/Rules/SubdivisionCode/NcSubdivisionCode.php @@ -0,0 +1,32 @@ + + * + * 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 Caledonia subdivision code. + * + * ISO 3166-1 alpha-2: NC + * + * @link http://www.geonames.org/NC/administrative-division-new-caledonia.html + */ +class NcSubdivisionCode extends AbstractSearcher +{ + public $haystack = array( + 'L', // Iles Loyaute + 'N', // Nord + 'S', // Sud + ); + + public $compareIdentical = true; +}