ad_page_contract_filter_proc_naturalnum (public)
ad_page_contract_filter_proc_naturalnum name value_varname
Defined in packages/acs-tcl/tcl/tcl-documentation-procs.tcl
Checks whether the value is a valid integer >= 0, and removes any leading zeros so as not to confuse Tcl into thinking it's octal.
- Parameters:
- name
value_varname
- Author:
- Lars Pind <lars@pinds.com>
- Created:
- 25 July 2000
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- ad_page_contract_filters
Source code: upvar $value_varname value # We can't really use "string is integer -strict", since it allows # numbers, which are invalid for e.g. SQL... e.g. "0x40". # # First a simple quick check to avoid the slow regexp # if {[string is integer -strict $value] && $value >= 0} { # return 1 # } # Check with leading zeros, but no "-" allowed, so it must be positive if { [regexp {^(0*)([1-9][0-9]*|0)$} $value match zeros value] } { if {[string is integer -strict $value]} { return 1 } } ad_complain [_ acs-tcl.lt_name_is_not_a_natural] return 0XQL Not present: Generic, PostgreSQL, Oracle