From 7eabda4d8f08f691322bbc9ea554b646ee3395ea Mon Sep 17 00:00:00 2001 From: Henrique Moody Date: Mon, 21 Sep 2015 13:27:34 -0300 Subject: [PATCH] Create "PmSubdivisionCode" rule --- .../PmSubdivisionCodeException.php | 31 +++++++++++++++++++ .../SubdivisionCode/PmSubdivisionCode.php | 31 +++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 library/Exceptions/SubdivisionCode/PmSubdivisionCodeException.php create mode 100644 library/Rules/SubdivisionCode/PmSubdivisionCode.php diff --git a/library/Exceptions/SubdivisionCode/PmSubdivisionCodeException.php b/library/Exceptions/SubdivisionCode/PmSubdivisionCodeException.php new file mode 100644 index 00000000..7dc3f78f --- /dev/null +++ b/library/Exceptions/SubdivisionCode/PmSubdivisionCodeException.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 Saint Pierre and Miquelon subdivision code. + * + * ISO 3166-1 alpha-2: PM + */ +class PmSubdivisionCodeException extends SubdivisionCodeException +{ + public static $defaultTemplates = array( + self::MODE_DEFAULT => array( + self::STANDARD => '{{name}} must be a subdivision code of Saint Pierre and Miquelon', + ), + self::MODE_NEGATIVE => array( + self::STANDARD => '{{name}} must not be a subdivision code of Saint Pierre and Miquelon', + ), + ); +} diff --git a/library/Rules/SubdivisionCode/PmSubdivisionCode.php b/library/Rules/SubdivisionCode/PmSubdivisionCode.php new file mode 100644 index 00000000..1f2a8c53 --- /dev/null +++ b/library/Rules/SubdivisionCode/PmSubdivisionCode.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\Rules\SubdivisionCode; + +use Respect\Validation\Rules\AbstractSearcher; + +/** + * Validator for Saint Pierre and Miquelon subdivision code. + * + * ISO 3166-1 alpha-2: PM + * + * @link http://www.geonames.org/PM/administrative-division-saint-pierre-and-miquelon.html + */ +class PmSubdivisionCode extends AbstractSearcher +{ + public $haystack = array( + 'M', // Miquelon + 'P', // Saint Pierre + ); + + public $compareIdentical = true; +}