From 455939f4c68ec5d2a79c598ddfea0fff75087117 Mon Sep 17 00:00:00 2001 From: Henrique Moody Date: Mon, 21 Sep 2015 13:27:35 -0300 Subject: [PATCH] Create "PrSubdivisionCode" rule --- .../PrSubdivisionCodeException.php | 31 +++++++++++++++++++ .../SubdivisionCode/PrSubdivisionCode.php | 28 +++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 library/Exceptions/SubdivisionCode/PrSubdivisionCodeException.php create mode 100644 library/Rules/SubdivisionCode/PrSubdivisionCode.php diff --git a/library/Exceptions/SubdivisionCode/PrSubdivisionCodeException.php b/library/Exceptions/SubdivisionCode/PrSubdivisionCodeException.php new file mode 100644 index 00000000..5184d2b0 --- /dev/null +++ b/library/Exceptions/SubdivisionCode/PrSubdivisionCodeException.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 Puerto Rico subdivision code. + * + * ISO 3166-1 alpha-2: PR + */ +class PrSubdivisionCodeException extends SubdivisionCodeException +{ + public static $defaultTemplates = array( + self::MODE_DEFAULT => array( + self::STANDARD => '{{name}} must be a subdivision code of Puerto Rico', + ), + self::MODE_NEGATIVE => array( + self::STANDARD => '{{name}} must not be a subdivision code of Puerto Rico', + ), + ); +} diff --git a/library/Rules/SubdivisionCode/PrSubdivisionCode.php b/library/Rules/SubdivisionCode/PrSubdivisionCode.php new file mode 100644 index 00000000..5adbb16e --- /dev/null +++ b/library/Rules/SubdivisionCode/PrSubdivisionCode.php @@ -0,0 +1,28 @@ + + * + * 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 Puerto Rico subdivision code. + * + * ISO 3166-1 alpha-2: PR + * + * @link http://www.geonames.org/PR/administrative-division-puerto-rico.html + */ +class PrSubdivisionCode extends AbstractSearcher +{ + public $haystack = array(null, ''); + + public $compareIdentical = true; +}