]> gitweb.factorcode.org Git - factor.git/commitdiff
Adding a checkbox validator
authorJames Cash <james.nvc@gmail.com>
Sun, 11 Jan 2009 05:53:23 +0000 (00:53 -0500)
committerJames Cash <james.nvc@gmail.com>
Sun, 11 Jan 2009 05:55:47 +0000 (00:55 -0500)
basis/validators/validators-docs.factor
basis/validators/validators.factor

index 4f03fa915b8b53b2672bb5115cb624141af0361c..42503a7155007a370a0d1b1932da373124da88e6 100644 (file)
@@ -2,6 +2,10 @@ USING: help.markup help.syntax io.streams.string quotations
 strings math regexp regexp.backend ;
 IN: validators
 
+HEPL: v-checkbox
+{ $values { "str" string } }
+{ $description "Converts the string value of a checkbox component (either \"on\" or \"off\") to a boolean value." } ;
+
 HELP: v-captcha
 { $values { "str" string } }
 { $description "Throws a validation error if the string is non-empty. This is used to create bait fields for spam-bots to fill in." } ;
@@ -99,6 +103,7 @@ $nl
 { $subsection v-one-line    }
 { $subsection v-one-word    }
 { $subsection v-captcha     }
+{ $subsection v-checkbox    }
 "More complex validators:"
 { $subsection v-email       }
 { $subsection v-url         }
index 78e01fdaf7854a89cb608239068ffa115c693828..755c9f9111380d47799586e3a0caf344cc0ce4bc 100644 (file)
@@ -5,6 +5,9 @@ math.parser math.ranges assocs regexp unicode.categories arrays
 hashtables words classes quotations xmode.catalog ;
 IN: validators
 
+: v-checkbox ( str -- ? )
+    "on" = ;
+
 : v-default ( str def -- str/def )
     over empty? spin ? ;