xo::validate_parameter_constraints (public)

 xo::validate_parameter_constraints name constraint value

Defined in packages/xotcl-core/tcl/context-procs.tcl

Validate the provided value against the constraints. In case of failure, return with ad_return_complaint when there is a connection, otherwise raise an error.

Parameters:
name
constraint
value

Partial Call Graph (max 5 caller/called nodes):
%3 xo::ConnectionContext instproc form_parameter xo::ConnectionContext instproc form_parameter xo::validate_parameter_constraints xo::validate_parameter_constraints xo::ConnectionContext instproc form_parameter->xo::validate_parameter_constraints xo::ConnectionContext instproc query_parameter xo::ConnectionContext instproc query_parameter (public) xo::ConnectionContext instproc query_parameter->xo::validate_parameter_constraints xowiki::Package instproc get_parameter xowiki::Package instproc get_parameter (public) xowiki::Package instproc get_parameter->xo::validate_parameter_constraints acs::icanuse acs::icanuse (public) xo::validate_parameter_constraints->acs::icanuse ad_return_complaint ad_return_complaint (public) xo::validate_parameter_constraints->ad_return_complaint ad_script_abort ad_script_abort (public) xo::validate_parameter_constraints->ad_script_abort

Testcases:
No testcase defined.
Source code:
    #
    # If we have a value-constraint, we check for empty values only in
    # cases, where multiplicity is specified. This means effectively
    # that the default multiplicity is "0..1".
    #
    #ns_log notice "::xo::validate_parameter_constraints $name $constraint input '$value'"
    if {[string first . $constraint] > -1 || $value ne ""} {
      try {
        #
        # Use parseargs with "-asdict" option when it is available,
        # since it does not globber the variable namespace. For legacy
        # applications, lets hope that no query parameter named
        # "__name" is used with a value constraint.
        #
        if {[::acs::icanuse "nsf::parseargs -asdict"]} {
          #
          # Newer versions will use this branch
          #
          set value [dict get  [nsf::parseargs -asdict ${name}:$constraint [list $value]]  $name]
        } else {
          #
          # This is the legacy branch.  nsf::parseargs might clobber
          # "name", therefore, save it in an highly unlikely variable
          # name.
          #
          set { name } $name
          nsf::parseargs ${name}:$constraint [list $value]
          set value [set ${ name }]
        }
      } on error {errorMsg} {
        #ns_log notice ".... nsf::parseargs error '$errorMsg'"
        if {[ns_conn isconnected] && ![info exists ::aa_test_noabort]} {
          ad_return_complaint 1 [ns_quotehtml $errorMsg]
          ad_script_abort
        } else {
          throw $::errorInfo $errorMsg
        }
      }
    }
    #ns_log notice "::xo::validate_parameter_constraints $name $constraint -> '$value'"
    return $value
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: