From ffd8155fc9ff5fe3669f5a943123bb8195402e1e Mon Sep 17 00:00:00 2001 From: Henrique Moody Date: Mon, 21 Sep 2015 13:27:41 -0300 Subject: [PATCH] Create "SbSubdivisionCode" rule --- .../SbSubdivisionCodeException.php | 31 +++++++++++++++ .../SubdivisionCode/SbSubdivisionCode.php | 39 +++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 library/Exceptions/SubdivisionCode/SbSubdivisionCodeException.php create mode 100644 library/Rules/SubdivisionCode/SbSubdivisionCode.php diff --git a/library/Exceptions/SubdivisionCode/SbSubdivisionCodeException.php b/library/Exceptions/SubdivisionCode/SbSubdivisionCodeException.php new file mode 100644 index 00000000..e01afdf5 --- /dev/null +++ b/library/Exceptions/SubdivisionCode/SbSubdivisionCodeException.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 Solomon Islands subdivision code. + * + * ISO 3166-1 alpha-2: SB + */ +class SbSubdivisionCodeException extends SubdivisionCodeException +{ + public static $defaultTemplates = array( + self::MODE_DEFAULT => array( + self::STANDARD => '{{name}} must be a subdivision code of Solomon Islands', + ), + self::MODE_NEGATIVE => array( + self::STANDARD => '{{name}} must not be a subdivision code of Solomon Islands', + ), + ); +} diff --git a/library/Rules/SubdivisionCode/SbSubdivisionCode.php b/library/Rules/SubdivisionCode/SbSubdivisionCode.php new file mode 100644 index 00000000..21f7a915 --- /dev/null +++ b/library/Rules/SubdivisionCode/SbSubdivisionCode.php @@ -0,0 +1,39 @@ + + * + * 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 Solomon Islands subdivision code. + * + * ISO 3166-1 alpha-2: SB + * + * @link http://www.geonames.org/SB/administrative-division-solomon-islands.html + */ +class SbSubdivisionCode extends AbstractSearcher +{ + public $haystack = array( + 'CE', // Central + 'CH', // Choiseul + 'CT', // Capital Territory + 'GU', // Guadalcanal + 'IS', // Isabel + 'MK', // Makira + 'ML', // Malaita + 'RB', // Rennell and Bellona + 'TE', // Temotu + 'WE', // Western + ); + + public $compareIdentical = true; +}