diff --git a/library/Exceptions/SubdivisionCode/HkSubdivisionCodeException.php b/library/Exceptions/SubdivisionCode/HkSubdivisionCodeException.php new file mode 100644 index 00000000..a5b1a8b2 --- /dev/null +++ b/library/Exceptions/SubdivisionCode/HkSubdivisionCodeException.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 Hong Kong subdivision code. + * + * ISO 3166-1 alpha-2: HK + */ +class HkSubdivisionCodeException extends SubdivisionCodeException +{ + public static $defaultTemplates = array( + self::MODE_DEFAULT => array( + self::STANDARD => '{{name}} must be a subdivision code of Hong Kong', + ), + self::MODE_NEGATIVE => array( + self::STANDARD => '{{name}} must not be a subdivision code of Hong Kong', + ), + ); +} diff --git a/library/Rules/SubdivisionCode/HkSubdivisionCode.php b/library/Rules/SubdivisionCode/HkSubdivisionCode.php new file mode 100644 index 00000000..5ae0f553 --- /dev/null +++ b/library/Rules/SubdivisionCode/HkSubdivisionCode.php @@ -0,0 +1,47 @@ + + * + * 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 Hong Kong subdivision code. + * + * ISO 3166-1 alpha-2: HK + * + * @link http://www.geonames.org/HK/administrative-division-hong-kong.html + */ +class HkSubdivisionCode extends AbstractSearcher +{ + public $haystack = array( + 'HCW', // Central and Western Hong Kong Island + 'HEA', // Eastern Hong Kong Island + 'HSO', // Southern Hong Kong Island + 'HWC', // Wan Chai Hong Kong Island + 'KKC', // Kowloon City Kowloon + 'KKT', // Kwun Tong Kowloon + 'KSS', // Sham Shui Po Kowloon + 'KWT', // Wong Tai Sin Kowloon + 'KYT', // Yau Tsim Mong Kowloon + 'NIS', // Islands New Territories + 'NKT', // Kwai Tsing New Territories + 'NNO', // North New Territories + 'NSK', // Sai Kung New Territories + 'NST', // Sha Tin New Territories + 'NTM', // Tuen Mun New Territories + 'NTP', // Tai Po New Territories + 'NTW', // Tsuen Wan New Territories + 'NYL', // Yuen Long New Territories + ); + + public $compareIdentical = true; +}