template::data::validate::float (public)

 template::data::validate::float value_ref message_ref

Defined in packages/acs-templating/tcl/data-procs.tcl

Validate that a submitted fla contains only an optional sign, and a whole part and fractional part.

Parameters:
value_ref (required)
Reference variable to the submitted value
message_ref (required)
Reference variable for returning an error message
Returns:
True (1) if valid, false (0) if not

Partial Call Graph (max 5 caller/called nodes):
%3 test_validate_float validate_float (test acs-templating) template::data::validate::float template::data::validate::float test_validate_float->template::data::validate::float _ _ (public) template::data::validate::float->_

Testcases:
validate_float
Source code:

    upvar 2 $message_ref message $value_ref value

    # Not allowing for scientific notation. Would the databases swallow it?
    set result [regexp {^([+-]?)(?=\d|\.\d)\d*(\.\d*)?$} $value]

    if { ! $result } {
        set message "[_ acs-templating.Invalid_decimal_number] \"[ns_quotehtml $value]\""
    }

    return $result
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: