From ede3b123643520a8989a791dfd85c551c5f0e2a7 Mon Sep 17 00:00:00 2001 From: Henrique Moody Date: Mon, 21 Sep 2015 13:26:37 -0300 Subject: [PATCH] Create "BbSubdivisionCode" rule --- .../BbSubdivisionCodeException.php | 31 ++++++++++++++ .../SubdivisionCode/BbSubdivisionCode.php | 40 +++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 library/Exceptions/SubdivisionCode/BbSubdivisionCodeException.php create mode 100644 library/Rules/SubdivisionCode/BbSubdivisionCode.php diff --git a/library/Exceptions/SubdivisionCode/BbSubdivisionCodeException.php b/library/Exceptions/SubdivisionCode/BbSubdivisionCodeException.php new file mode 100644 index 00000000..a1e831b9 --- /dev/null +++ b/library/Exceptions/SubdivisionCode/BbSubdivisionCodeException.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 Barbados subdivision code. + * + * ISO 3166-1 alpha-2: BB + */ +class BbSubdivisionCodeException extends SubdivisionCodeException +{ + public static $defaultTemplates = array( + self::MODE_DEFAULT => array( + self::STANDARD => '{{name}} must be a subdivision code of Barbados', + ), + self::MODE_NEGATIVE => array( + self::STANDARD => '{{name}} must not be a subdivision code of Barbados', + ), + ); +} diff --git a/library/Rules/SubdivisionCode/BbSubdivisionCode.php b/library/Rules/SubdivisionCode/BbSubdivisionCode.php new file mode 100644 index 00000000..4b560cf3 --- /dev/null +++ b/library/Rules/SubdivisionCode/BbSubdivisionCode.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 Barbados subdivision code. + * + * ISO 3166-1 alpha-2: BB + * + * @link http://www.geonames.org/BB/administrative-division-barbados.html + */ +class BbSubdivisionCode extends AbstractSearcher +{ + public $haystack = array( + '01', // Christ Church + '02', // Saint Andrew + '03', // Saint George + '04', // Saint James + '05', // Saint John + '06', // Saint Joseph + '07', // Saint Lucy + '08', // Saint Michael + '09', // Saint Peter + '10', // Saint Philip + '11', // Saint Thomas + ); + + public $compareIdentical = true; +}