From 65a6bfeec6deba8abae4b5f3318215f42fe4fdf5 Mon Sep 17 00:00:00 2001 From: Henrique Moody Date: Mon, 21 Sep 2015 13:26:41 -0300 Subject: [PATCH] Create "BmSubdivisionCode" rule --- .../BmSubdivisionCodeException.php | 31 ++++++++++++++ .../SubdivisionCode/BmSubdivisionCode.php | 40 +++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 library/Exceptions/SubdivisionCode/BmSubdivisionCodeException.php create mode 100644 library/Rules/SubdivisionCode/BmSubdivisionCode.php diff --git a/library/Exceptions/SubdivisionCode/BmSubdivisionCodeException.php b/library/Exceptions/SubdivisionCode/BmSubdivisionCodeException.php new file mode 100644 index 00000000..e8b1056a --- /dev/null +++ b/library/Exceptions/SubdivisionCode/BmSubdivisionCodeException.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 Bermuda subdivision code. + * + * ISO 3166-1 alpha-2: BM + */ +class BmSubdivisionCodeException extends SubdivisionCodeException +{ + public static $defaultTemplates = array( + self::MODE_DEFAULT => array( + self::STANDARD => '{{name}} must be a subdivision code of Bermuda', + ), + self::MODE_NEGATIVE => array( + self::STANDARD => '{{name}} must not be a subdivision code of Bermuda', + ), + ); +} diff --git a/library/Rules/SubdivisionCode/BmSubdivisionCode.php b/library/Rules/SubdivisionCode/BmSubdivisionCode.php new file mode 100644 index 00000000..cfae34a6 --- /dev/null +++ b/library/Rules/SubdivisionCode/BmSubdivisionCode.php @@ -0,0 +1,40 @@ + + * + * 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 Bermuda subdivision code. + * + * ISO 3166-1 alpha-2: BM + * + * @link http://www.geonames.org/BM/administrative-division-bermuda.html + */ +class BmSubdivisionCode extends AbstractSearcher +{ + public $haystack = array( + 'DS', // Devonshire + 'GC', // Saint George + 'HA', // Hamilton + 'HC', // Hamilton City + 'PB', // Pembroke + 'PG', // Paget + 'SA', // Sandys + 'SG', // Saint George's + 'SH', // Southampton + 'SM', // Smith's + 'WA', // Warwick + ); + + public $compareIdentical = true; +}