strings math regexp regexp.backend ;
IN: validators
+HELP: 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." } ;
{ $subsection v-one-line }
{ $subsection v-one-word }
{ $subsection v-captcha }
+{ $subsection v-checkbox }
"More complex validators:"
{ $subsection v-email }
{ $subsection v-url }
[ "hello" ] [ "hello" v-one-word ] unit-test
[ "hello world" v-one-word ] must-fail
+[ t ] [ "on" v-checkbox ] unit-test
+[ f ] [ "off" v-checkbox ] unit-test
+
[ "foo" v-number ] must-fail
[ 123 ] [ "123" v-number ] unit-test
[ 123 ] [ "123" v-integer ] unit-test