template::data::validate::h5date (public)

 template::data::validate::h5date value_ref message_ref

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

Validate a date submitted via HTML 5 input type "date". The submitted value is also checked against any "min" and "max" constraint set on the input element itself.

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 _ _ (public) template::data::validate::h5date template::data::validate::h5date template::data::validate::h5date->_

Testcases:
No testcase defined.
Source code:
    upvar 2 $message_ref message $value_ref value

    # get the elements definition
    upvar 2 element element

    if {$value ne ""} {
        set invalid_date_p [catch {
            set supplied_date [clock scan $value -format "%Y-%m-%d"]
        }]

        if {$invalid_date_p} {
            lappend message [_ acs-templating.Invalid_date]
            return 0
        }

        if {[info exists element(min)]} {
            set invalid_date_p [catch {
                set min [clock scan $element(min) -format "%Y-%m-%d"]
            }]
            if {$invalid_date_p || $min > $supplied_date} {
                lappend message [_ acs-templating.Date_must_be_after_min_date  [list min_date $element(min)]]
                return 0
            }
        }

        if {[info exists element(max)]} {
            set invalid_date_p [catch {
                set max [clock scan $element(max) -format "%Y-%m-%d"]
            }]
            if {$invalid_date_p || $supplied_date > $max} {
                lappend message [_ acs-templating.Date_must_be_before_max_date  [list max_date $element(max)]]
                return 0
            }
        }
    }

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