From 099da20ce159756c0050b579a69dbd58f3a96081 Mon Sep 17 00:00:00 2001 From: Henrique Moody Date: Mon, 21 Sep 2015 13:27:36 -0300 Subject: [PATCH] Create "PwSubdivisionCode" rule --- .../PwSubdivisionCodeException.php | 31 +++++++++++++ .../SubdivisionCode/PwSubdivisionCode.php | 45 +++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 library/Exceptions/SubdivisionCode/PwSubdivisionCodeException.php create mode 100644 library/Rules/SubdivisionCode/PwSubdivisionCode.php diff --git a/library/Exceptions/SubdivisionCode/PwSubdivisionCodeException.php b/library/Exceptions/SubdivisionCode/PwSubdivisionCodeException.php new file mode 100644 index 00000000..9bf5d5ad --- /dev/null +++ b/library/Exceptions/SubdivisionCode/PwSubdivisionCodeException.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 Palau subdivision code. + * + * ISO 3166-1 alpha-2: PW + */ +class PwSubdivisionCodeException extends SubdivisionCodeException +{ + public static $defaultTemplates = array( + self::MODE_DEFAULT => array( + self::STANDARD => '{{name}} must be a subdivision code of Palau', + ), + self::MODE_NEGATIVE => array( + self::STANDARD => '{{name}} must not be a subdivision code of Palau', + ), + ); +} diff --git a/library/Rules/SubdivisionCode/PwSubdivisionCode.php b/library/Rules/SubdivisionCode/PwSubdivisionCode.php new file mode 100644 index 00000000..67a43b97 --- /dev/null +++ b/library/Rules/SubdivisionCode/PwSubdivisionCode.php @@ -0,0 +1,45 @@ + + * + * 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 Palau subdivision code. + * + * ISO 3166-1 alpha-2: PW + * + * @link http://www.geonames.org/PW/administrative-division-palau.html + */ +class PwSubdivisionCode extends AbstractSearcher +{ + public $haystack = array( + '002', // Aimeliik + '004', // Airai + '010', // Angaur + '050', // Hatohobei + '100', // Kayangel + '150', // Koror + '212', // Melekeok + '214', // Ngaraard + '218', // Ngarchelong + '222', // Ngardmau + '224', // Ngatpang + '226', // Ngchesar + '227', // Ngeremlengui + '228', // Ngiwal + '350', // Peleliu + '370', // Sonsorol + ); + + public $compareIdentical = true; +}