From c45e7f144b4ba2dec32da289670e4a1e249a6a15 Mon Sep 17 00:00:00 2001 From: Henrique Moody Date: Mon, 21 Sep 2015 13:26:40 -0300 Subject: [PATCH] Create "BiSubdivisionCode" rule --- .../BiSubdivisionCodeException.php | 31 +++++++++++++ .../SubdivisionCode/BiSubdivisionCode.php | 46 +++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 library/Exceptions/SubdivisionCode/BiSubdivisionCodeException.php create mode 100644 library/Rules/SubdivisionCode/BiSubdivisionCode.php diff --git a/library/Exceptions/SubdivisionCode/BiSubdivisionCodeException.php b/library/Exceptions/SubdivisionCode/BiSubdivisionCodeException.php new file mode 100644 index 00000000..902c398f --- /dev/null +++ b/library/Exceptions/SubdivisionCode/BiSubdivisionCodeException.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 Burundi subdivision code. + * + * ISO 3166-1 alpha-2: BI + */ +class BiSubdivisionCodeException extends SubdivisionCodeException +{ + public static $defaultTemplates = array( + self::MODE_DEFAULT => array( + self::STANDARD => '{{name}} must be a subdivision code of Burundi', + ), + self::MODE_NEGATIVE => array( + self::STANDARD => '{{name}} must not be a subdivision code of Burundi', + ), + ); +} diff --git a/library/Rules/SubdivisionCode/BiSubdivisionCode.php b/library/Rules/SubdivisionCode/BiSubdivisionCode.php new file mode 100644 index 00000000..36eb0553 --- /dev/null +++ b/library/Rules/SubdivisionCode/BiSubdivisionCode.php @@ -0,0 +1,46 @@ + + * + * 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 Burundi subdivision code. + * + * ISO 3166-1 alpha-2: BI + * + * @link http://www.geonames.org/BI/administrative-division-burundi.html + */ +class BiSubdivisionCode extends AbstractSearcher +{ + public $haystack = array( + 'BB', // Bubanza + 'BL', // Bujumbura Rural + 'BM', // Bujumbura Mairie + 'BR', // Bururi + 'CA', // Cankuzo + 'CI', // Cibitoke + 'GI', // Gitega + 'KI', // Kirundo + 'KR', // Karuzi + 'KY', // Kayanza + 'MA', // Makamba + 'MU', // Muramvya + 'MW', // Mwaro + 'MY', // Muyinga + 'NG', // Ngozi + 'RT', // Rutana + 'RY', // Ruyigi + ); + + public $compareIdentical = true; +}