Hi
I noticed an odd bug in template::data::validate::boolean. It always returns 1 because when it calls "string tolower", it seems to be calling the "string" command in the template::data::validate namespace, rather than the standard TCL one.
One fix is to prefix the call to "string tolower" with :: but I'd like opinions if that is the best fix.
Here's my fixed version:
ad_proc -public template::data::validate::boolean {
value_ref
message_ref
} {
Validates boolean data types.
@author Roberto Mello <rmello at fslc.usu.edu>
@param value_ref Reference variable to the submitted value
@param message_ref Reference variable for returning an error message
@return True (1) if valid, false (0) if not
} {
upvar 2 $message_ref message $value_ref value
set result ""
set value [::string tolower $value]
switch $value {
0 -
1 -
f -
t -
n -
y -
no -
yes -
false -
true {
set result 1
}
default {
set result 0
set message "Invalid choice \"$value\""
}
}
return $result
}