From 9cf8ba13bab0c6eeeb8be11d41d7ba44b9d01417 Mon Sep 17 00:00:00 2001 From: Henrique Moody Date: Mon, 21 Sep 2015 13:27:23 -0300 Subject: [PATCH] Create "MnSubdivisionCode" rule --- .../MnSubdivisionCodeException.php | 31 +++++++++++ .../SubdivisionCode/MnSubdivisionCode.php | 51 +++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 library/Exceptions/SubdivisionCode/MnSubdivisionCodeException.php create mode 100644 library/Rules/SubdivisionCode/MnSubdivisionCode.php diff --git a/library/Exceptions/SubdivisionCode/MnSubdivisionCodeException.php b/library/Exceptions/SubdivisionCode/MnSubdivisionCodeException.php new file mode 100644 index 00000000..e3401aa3 --- /dev/null +++ b/library/Exceptions/SubdivisionCode/MnSubdivisionCodeException.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 Mongolia subdivision code. + * + * ISO 3166-1 alpha-2: MN + */ +class MnSubdivisionCodeException extends SubdivisionCodeException +{ + public static $defaultTemplates = array( + self::MODE_DEFAULT => array( + self::STANDARD => '{{name}} must be a subdivision code of Mongolia', + ), + self::MODE_NEGATIVE => array( + self::STANDARD => '{{name}} must not be a subdivision code of Mongolia', + ), + ); +} diff --git a/library/Rules/SubdivisionCode/MnSubdivisionCode.php b/library/Rules/SubdivisionCode/MnSubdivisionCode.php new file mode 100644 index 00000000..12c54c5e --- /dev/null +++ b/library/Rules/SubdivisionCode/MnSubdivisionCode.php @@ -0,0 +1,51 @@ + + * + * 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 Mongolia subdivision code. + * + * ISO 3166-1 alpha-2: MN + * + * @link http://www.geonames.org/MN/administrative-division-mongolia.html + */ +class MnSubdivisionCode extends AbstractSearcher +{ + public $haystack = array( + '035', // Orhon + '037', // Darhan uul + '039', // Hentiy + '041', // Hovsgol + '043', // Hovd + '046', // Uvs + '047', // Tov + '049', // Selenge + '051', // Suhbaatar + '053', // Omnogovi + '055', // Ovorhangay + '057', // Dzavhan + '059', // DundgovL + '061', // Dornod + '063', // Dornogov + '064', // Govi-Sumber + '065', // Govi-Altay + '067', // Bulgan + '069', // Bayanhongor + '071', // Bayan-Olgiy + '073', // Arhangay + '1', // Ulanbaatar + ); + + public $compareIdentical = true; +}