validate_zip_code (public, deprecated)
validate_zip_code field_name zip_string country_code
Defined in packages/acs-tcl/tcl/deprecated-procs.tcl
Deprecated. Invoking this procedure generates a warning.
Given a string, signals an error if it's not a legal zip code
validate via ad_page_contract
- Parameters:
- field_name (required)
- zip_string (required)
- country_code (required)
- See Also:
- Testcases:
- No testcase defined.
Source code: ad_log_deprecated proc validate_zip_code if { $country_code eq "" || [string toupper $country_code] eq "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] if { ![db_0or1row zip_code_exists { select 1 from dual where exists (select 1 from zip_codes where zip_code like :zip_5) }] } { 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 ne "" } { error "Zip code is not needed outside the US" } } return $zip_stringXQL Not present: PostgreSQL, Oracle Generic XQL file: <fullquery name="validate_zip_code.zip_code_exists"> <querytext> select 1 from dual where exists (select 1 from zip_codes where zip_code like :zip_5) </querytext> </fullquery>packages/acs-tcl/tcl/deprecated-procs.xql