JacksonRiver/springboard_modules — pull request #338 by patobrien (2013-10-25 15:02:51+00:00)
Title: 7.x 4.x t560 - Allowing the extension and override of zipcode validation (region or country-specific)

This update allows clients to extend or override the zipcode component validation.

They can do this by adding additional objects to the Drupal.settings.zipRegExp object with the property as the region and the value as the regex with escaped backslashes.

Ex.
Drupal.settings.zipRegExp = {
countryCode: '^\\d{2}$', // would match any 2 digits
countryCodeRegex: new RegExp('123') // would create a new regexp type and match 123
}

These values would then be added to the regular validation codes for US, AU and CA (current defaults).

For further customization, the buildZipRegex() function can be entirely overridden by creating a handler function at Drupal.settings.buildZipRegex(). The only condition is that the returned value must be a valid regex *string* that will be assigned to 'zipcodeRegex' and turned into a RegExp type:

new RegExp(zipcodeRegex,'i');

This will then be tested against user-input values within the zipcode validation.