From 7a78e7e6316006aa7e1e634121c9657cffe705b7 Mon Sep 17 00:00:00 2001 From: Henrique Moody Date: Mon, 21 Sep 2015 13:26:46 -0300 Subject: [PATCH] Create "BySubdivisionCode" rule --- .../BySubdivisionCodeException.php | 31 ++++++++++++++++ .../SubdivisionCode/BySubdivisionCode.php | 36 +++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 library/Exceptions/SubdivisionCode/BySubdivisionCodeException.php create mode 100644 library/Rules/SubdivisionCode/BySubdivisionCode.php diff --git a/library/Exceptions/SubdivisionCode/BySubdivisionCodeException.php b/library/Exceptions/SubdivisionCode/BySubdivisionCodeException.php new file mode 100644 index 00000000..e7329aa0 --- /dev/null +++ b/library/Exceptions/SubdivisionCode/BySubdivisionCodeException.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 Belarus subdivision code. + * + * ISO 3166-1 alpha-2: BY + */ +class BySubdivisionCodeException extends SubdivisionCodeException +{ + public static $defaultTemplates = array( + self::MODE_DEFAULT => array( + self::STANDARD => '{{name}} must be a subdivision code of Belarus', + ), + self::MODE_NEGATIVE => array( + self::STANDARD => '{{name}} must not be a subdivision code of Belarus', + ), + ); +} diff --git a/library/Rules/SubdivisionCode/BySubdivisionCode.php b/library/Rules/SubdivisionCode/BySubdivisionCode.php new file mode 100644 index 00000000..8715272c --- /dev/null +++ b/library/Rules/SubdivisionCode/BySubdivisionCode.php @@ -0,0 +1,36 @@ + + * + * 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 Belarus subdivision code. + * + * ISO 3166-1 alpha-2: BY + * + * @link http://www.geonames.org/BY/administrative-division-belarus.html + */ +class BySubdivisionCode extends AbstractSearcher +{ + public $haystack = array( + 'BR', // Brest voblast + 'HM', // Horad Minsk + 'HO', // Homyel voblast + 'HR', // Hrodna voblast + 'MA', // Mahilyow voblast + 'MI', // Minsk voblast + 'VI', // Vitsebsk voblast + ); + + public $compareIdentical = true; +}