validate_zip_code

one of the documented procedures in this installation of the ACS
Usage:
validate_zip_code   field_name   db   zip_string   country_code
What it does:
Given a string, signals an error if it's not a legal zip code
Defined 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


philg@mit.edu