From 3b4a94bf4e99b4731d3b5ec1089371e81eea1640 Mon Sep 17 00:00:00 2001 From: Henrique Moody Date: Mon, 21 Sep 2015 13:27:32 -0300 Subject: [PATCH] Create "PfSubdivisionCode" rule --- .../PfSubdivisionCodeException.php | 31 +++++++++++++++++ .../SubdivisionCode/PfSubdivisionCode.php | 34 +++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 library/Exceptions/SubdivisionCode/PfSubdivisionCodeException.php create mode 100644 library/Rules/SubdivisionCode/PfSubdivisionCode.php diff --git a/library/Exceptions/SubdivisionCode/PfSubdivisionCodeException.php b/library/Exceptions/SubdivisionCode/PfSubdivisionCodeException.php new file mode 100644 index 00000000..2b9c4a4c --- /dev/null +++ b/library/Exceptions/SubdivisionCode/PfSubdivisionCodeException.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 French Polynesia subdivision code. + * + * ISO 3166-1 alpha-2: PF + */ +class PfSubdivisionCodeException extends SubdivisionCodeException +{ + public static $defaultTemplates = array( + self::MODE_DEFAULT => array( + self::STANDARD => '{{name}} must be a subdivision code of French Polynesia', + ), + self::MODE_NEGATIVE => array( + self::STANDARD => '{{name}} must not be a subdivision code of French Polynesia', + ), + ); +} diff --git a/library/Rules/SubdivisionCode/PfSubdivisionCode.php b/library/Rules/SubdivisionCode/PfSubdivisionCode.php new file mode 100644 index 00000000..df11cc4a --- /dev/null +++ b/library/Rules/SubdivisionCode/PfSubdivisionCode.php @@ -0,0 +1,34 @@ + + * + * 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 French Polynesia subdivision code. + * + * ISO 3166-1 alpha-2: PF + * + * @link http://www.geonames.org/PF/administrative-division-french-polynesia.html + */ +class PfSubdivisionCode extends AbstractSearcher +{ + public $haystack = array( + 'I', // Austral Islands + 'M', // Marquesas Islands + 'S', // Iles Sous-le-Vent + 'T', // Tuamotu-Gambier + 'V', // Iles du Vent + ); + + public $compareIdentical = true; +}