zendframework/zf2 — pull request #4142 by mwillbanks (2013-03-29 06:34:11+00:00)
Title: New I18n Validator: CountryCode with companion CountryDb

This PR is based off of PR #3884 with the feedback taken into account. I've separated each component off individually to make it easier to review and make feedback.

@marc-mabe and @weierophinney please review to see if all feedback was incorporated to your expectations.

## Overview

## CountryDb
This is a static class for the most part in that it only contains static variables and methods. There are two methods:
1. getTypes that gives you an array of the ISO3611-1 Alpha 2 types
2. getCountries which accepts a type to retrieve a list of countries (key = 2 letter alpha code, value is the name).

### CountryCode
The Country validator is based on ISO-3611 country codes. I needed this for actually integration into other systems that require an ISO-3611 country code. The key is the country code where as the value is the country name.
*Basic Usage:*
```php
$validator = new \Zend\I18n\Validator\CountryCode();
$validator->isValid('US');

// input filter with context
$filter = new InputFilter();
$factory = new InputFactory();
$filter->add($factory->createInput(array(
'name' => 'country',
'required' => true,
'validators' => array(
'name' => 'Zend\I18n\Validator\Country',
),
)));
```

*Advanced Usage*
```php
$validator = new \Zend\I18n\Validator\CountryCode();

// Specify ISO3611-1 Alpha 2 types to load - default is official
$validator->loadCountryTypes(array('official', 'transition', 'userAssigned'));

// Load your own countries
$validator->setCountries(array('CA', 'TX')); // states most likely their own country in the US
```