diff --git a/library/Exceptions/SubdivisionCode/NoSubdivisionCodeException.php b/library/Exceptions/SubdivisionCode/NoSubdivisionCodeException.php new file mode 100644 index 00000000..6e6c3815 --- /dev/null +++ b/library/Exceptions/SubdivisionCode/NoSubdivisionCodeException.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 Norway subdivision code. + * + * ISO 3166-1 alpha-2: NO + */ +class NoSubdivisionCodeException extends SubdivisionCodeException +{ + public static $defaultTemplates = array( + self::MODE_DEFAULT => array( + self::STANDARD => '{{name}} must be a subdivision code of Norway', + ), + self::MODE_NEGATIVE => array( + self::STANDARD => '{{name}} must not be a subdivision code of Norway', + ), + ); +} diff --git a/library/Rules/SubdivisionCode/NoSubdivisionCode.php b/library/Rules/SubdivisionCode/NoSubdivisionCode.php new file mode 100644 index 00000000..60b685de --- /dev/null +++ b/library/Rules/SubdivisionCode/NoSubdivisionCode.php @@ -0,0 +1,50 @@ + + * + * 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 Norway subdivision code. + * + * ISO 3166-1 alpha-2: NO + * + * @link http://www.geonames.org/NO/administrative-division-norway.html + */ +class NoSubdivisionCode extends AbstractSearcher +{ + public $haystack = array( + '01', // Ostfold + '02', // Akershus + '03', // Oslo + '04', // Hedmark + '05', // Oppland + '06', // Buskerud + '07', // Vestfold + '08', // Telemark + '09', // Aust-Agder + '10', // Vest-Agder + '11', // Rogaland + '12', // Hordaland + '14', // Sogn og Fjordane + '15', // More og Romdal + '16', // Sor-Trondelag + '17', // Nord-Trondelag + '18', // Nordland + '19', // Troms + '20', // Finnmark + '21', // Svalbard + '22', // Jan Mayen + ); + + public $compareIdentical = true; +}