Index: openacs-4/packages/acs-templating/tcl/data-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/tcl/data-procs.tcl,v diff -u -r1.9 -r1.10 --- openacs-4/packages/acs-templating/tcl/data-procs.tcl 17 May 2003 10:05:27 -0000 1.9 +++ openacs-4/packages/acs-templating/tcl/data-procs.tcl 22 Sep 2003 19:55:30 -0000 1.10 @@ -40,6 +40,23 @@ return $result } +ad_proc -public template::data::validate::naturalnum { value_ref message_ref } { + Validates natural numbers data types + Will trim leading 0 in order to avoid TCL interpreting it as octal in the future + (code borrowed from ad_page_contract_filter_proc_naturalnum) + @author Rocael Hernandez +} { + upvar 2 $message_ref message $value_ref value + + set result [regexp {^(0*)(([1-9][0-9]*|0))$} $value match zeros value] + + if { ! $result } { + set message "Invalid natural number \"$value\"" + } + + return $result +} + ad_proc -public template::data::validate::float { value_ref message_ref } { upvar 2 $message_ref message $value_ref value