validate_zip_code field_name db zip_string country_codeWhat it does:
Given a string, signals an error if it's not a legal zip codeDefined in: /web/philip/packages/acs-core/utilities-procs.tcl
Source code:
if { $country_code == "" || [string toupper $country_code] == "US" } {
if { [regexp {^[0-9][0-9][0-9][0-9][0-9](-[0-9][0-9][0-9][0-9])?$} $zip_string] } {
set zip_5 [string range $zip_string 0 4]
set selection [ns_db 0or1row $db "select 1 from dual where exists
(select 1 from zip_codes where zip_code like '$zip_5%')"]
if { $selection == "" } {
error "The entry for $field_name, \"$zip_string\" is not a recognized zip code"
}
} else {
error "The entry for $field_name, \"$zip_string\" does not look like a zip code"
}
} else {
if { $zip_string != "" } {
error "Zip code is not needed outside the US"
}
}
return $zip_string