From af0ae3f7d97b06d872bd7c7a2744f11dfd9cf16b Mon Sep 17 00:00:00 2001 From: Henrique Moody Date: Mon, 21 Sep 2015 13:27:32 -0300 Subject: [PATCH] Create "PaSubdivisionCode" rule --- .../PaSubdivisionCodeException.php | 31 ++++++++++++++ .../SubdivisionCode/PaSubdivisionCode.php | 41 +++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 library/Exceptions/SubdivisionCode/PaSubdivisionCodeException.php create mode 100644 library/Rules/SubdivisionCode/PaSubdivisionCode.php diff --git a/library/Exceptions/SubdivisionCode/PaSubdivisionCodeException.php b/library/Exceptions/SubdivisionCode/PaSubdivisionCodeException.php new file mode 100644 index 00000000..21845f9b --- /dev/null +++ b/library/Exceptions/SubdivisionCode/PaSubdivisionCodeException.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 Panama subdivision code. + * + * ISO 3166-1 alpha-2: PA + */ +class PaSubdivisionCodeException extends SubdivisionCodeException +{ + public static $defaultTemplates = array( + self::MODE_DEFAULT => array( + self::STANDARD => '{{name}} must be a subdivision code of Panama', + ), + self::MODE_NEGATIVE => array( + self::STANDARD => '{{name}} must not be a subdivision code of Panama', + ), + ); +} diff --git a/library/Rules/SubdivisionCode/PaSubdivisionCode.php b/library/Rules/SubdivisionCode/PaSubdivisionCode.php new file mode 100644 index 00000000..7212e09e --- /dev/null +++ b/library/Rules/SubdivisionCode/PaSubdivisionCode.php @@ -0,0 +1,41 @@ + + * + * 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 Panama subdivision code. + * + * ISO 3166-1 alpha-2: PA + * + * @link http://www.geonames.org/PA/administrative-division-panama.html + */ +class PaSubdivisionCode extends AbstractSearcher +{ + public $haystack = array( + '1', // Bocas del Toro + '2', // Cocle + '3', // Colon + '4', // Chiriqui + '5', // Darien + '6', // Herrera + '7', // Los Santos + '8', // Panama + '9', // Veraguas + 'EM', // Comarca Emberá-Wounaan + 'KY', // Comarca de Kuna Yala + 'NB', // Ngöbe-Buglé + ); + + public $compareIdentical = true; +}