template::data::validate::enumeration (public)

 template::data::validate::enumeration value_ref message_ref

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

Validate enumeration as a unique csv alphanum list.

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_enumeration validate_enumeration (test acs-templating) template::data::validate::enumeration template::data::validate::enumeration test_validate_enumeration->template::data::validate::enumeration _ _ (public) template::data::validate::enumeration->_

Testcases:
validate_enumeration
Source code:

    upvar 2 $message_ref message $value_ref value

    # alphanumeric csv
    set result [regexp {^([A-z0-9]+,?)+$} $value]

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

    # unique list
    set list [split $value ,]
    set result [expr {[llength $list] == [llength [lsort -unique $list]]}]

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

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