From db246cea5abd8dfd7fed0592cf5b5b46bf6589d2 Mon Sep 17 00:00:00 2001 From: Henrique Moody Date: Mon, 21 Sep 2015 13:27:23 -0300 Subject: [PATCH] Create "MpSubdivisionCode" rule --- .../MpSubdivisionCodeException.php | 31 +++++++++++++++++ .../SubdivisionCode/MpSubdivisionCode.php | 33 +++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 library/Exceptions/SubdivisionCode/MpSubdivisionCodeException.php create mode 100644 library/Rules/SubdivisionCode/MpSubdivisionCode.php diff --git a/library/Exceptions/SubdivisionCode/MpSubdivisionCodeException.php b/library/Exceptions/SubdivisionCode/MpSubdivisionCodeException.php new file mode 100644 index 00000000..4006ce28 --- /dev/null +++ b/library/Exceptions/SubdivisionCode/MpSubdivisionCodeException.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 Northern Mariana Islands subdivision code. + * + * ISO 3166-1 alpha-2: MP + */ +class MpSubdivisionCodeException extends SubdivisionCodeException +{ + public static $defaultTemplates = array( + self::MODE_DEFAULT => array( + self::STANDARD => '{{name}} must be a subdivision code of Northern Mariana Islands', + ), + self::MODE_NEGATIVE => array( + self::STANDARD => '{{name}} must not be a subdivision code of Northern Mariana Islands', + ), + ); +} diff --git a/library/Rules/SubdivisionCode/MpSubdivisionCode.php b/library/Rules/SubdivisionCode/MpSubdivisionCode.php new file mode 100644 index 00000000..13dff905 --- /dev/null +++ b/library/Rules/SubdivisionCode/MpSubdivisionCode.php @@ -0,0 +1,33 @@ + + * + * 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 Northern Mariana Islands subdivision code. + * + * ISO 3166-1 alpha-2: MP + * + * @link http://www.geonames.org/MP/administrative-division-northern-mariana-islands.html + */ +class MpSubdivisionCode extends AbstractSearcher +{ + public $haystack = array( + 'N', // Northern Islands + 'R', // Rota + 'S', // Saipan + 'T', // Tinian + ); + + public $compareIdentical = true; +}