You are viewing a plain text version of this content. The canonical link for it is here.
Posted to site-cvs@tcl.apache.org by mx...@apache.org on 2017/02/10 22:30:44 UTC

svn commit: r1782537 - in /tcl/rivet/branches/2.3: ChangeLog rivet/packages/formbroker/formbroker.tcl

Author: mxmanghi
Date: Fri Feb 10 22:30:44 2017
New Revision: 1782537

URL: http://svn.apache.org/viewvc?rev=1782537&view=rev
Log:
    * rivet/packages/formbroker/formbroker.tcl: now
    handling natively also boolean in the form y|n or
    0|1


Modified:
    tcl/rivet/branches/2.3/ChangeLog
    tcl/rivet/branches/2.3/rivet/packages/formbroker/formbroker.tcl

Modified: tcl/rivet/branches/2.3/ChangeLog
URL: http://svn.apache.org/viewvc/tcl/rivet/branches/2.3/ChangeLog?rev=1782537&r1=1782536&r2=1782537&view=diff
==============================================================================
--- tcl/rivet/branches/2.3/ChangeLog (original)
+++ tcl/rivet/branches/2.3/ChangeLog Fri Feb 10 22:30:44 2017
@@ -1,3 +1,8 @@
+2017-02-10 Massimo Manghi <mx...@apache.org>
+    * rivet/packages/formbroker/formbroker.tcl: now
+    handling natively also boolean in the form y|n or
+    0|1
+
 2016-12-07 Massimo Manghi <mx...@apache.org>
     * rivet/packages/session/session-class.tcl: fully qualifying
     ::rivet::* command names in this packages. Add method

Modified: tcl/rivet/branches/2.3/rivet/packages/formbroker/formbroker.tcl
URL: http://svn.apache.org/viewvc/tcl/rivet/branches/2.3/rivet/packages/formbroker/formbroker.tcl?rev=1782537&r1=1782536&r2=1782537&view=diff
==============================================================================
--- tcl/rivet/branches/2.3/rivet/packages/formbroker/formbroker.tcl (original)
+++ tcl/rivet/branches/2.3/rivet/packages/formbroker/formbroker.tcl Fri Feb 10 22:30:44 2017
@@ -256,6 +256,19 @@ namespace eval FormBroker {
         }
     }
 
+    proc validate_boolean {_var_d} {
+        upvar $_var_d var_d
+
+        dict with var_d {
+            if {[regexp -nocase {Y|N|0|1} $var]} {
+                return FB_OK
+            } else {
+                return FB_INVALID_BOOLEAN
+            }
+        }
+    }
+
+
     proc validate_variable_representation {_var_d} {
         upvar $_var_d var_d
         variable form_definitions
@@ -669,11 +682,14 @@ namespace eval FormBroker {
 
             # the 'vars' dictionary field stores the
             # order of form fields in which they are processed
-            # (in general this order is destroyed by the Tcl's hash
-            # tables algorithm)
+            # (in general this order would be destroyed by the Tcl's hash
+            # tables)
 
             dict with form_list $form_name {::lappend vars $field_name}
 
+            # this test would handle the case of the most simple possible
+            # variable definition (just the variable name)
+
             if {$field_type == ""} {
                 set field_type string
             }
@@ -698,6 +714,9 @@ namespace eval FormBroker {
                     email {
                         set validator [namespace current]::validate_email
                     }
+                    boolean {
+                        set validator [namespace current]::validate_boolean
+                    }
                     string -
                     default {
                         set validator [namespace current]::validate_string



---------------------------------------------------------------------
To unsubscribe, e-mail: site-cvs-unsubscribe@tcl.apache.org
For additional commands, e-mail: site-cvs-help@tcl.apache.org