2008-09-24 01:45:39 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								USING:  help.markup  help.syntax  io.streams.string  quotations   
						 
					
						
							
								
									
										
										
										
											2008-11-15 00:01:12 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								strings math regexp regexp.backend ;
 
							 
						 
					
						
							
								
									
										
										
										
											2008-09-24 01:45:39 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								IN:  validators  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-01-11 00:58:00 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								HELP:  v-checkbox  
						 
					
						
							
								
									
										
										
										
											2009-01-13 22:58:39 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $values { "str"  string  } {  "?"  "a boolean"  } }
							 
						 
					
						
							
								
									
										
										
										
											2009-01-11 00:53:23 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $description "Converts the string value of a checkbox component (either \"on\" or \"off\") to a boolean value."  } ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2008-09-24 01:45:39 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								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."  } ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  v-credit-card  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values { "str"  string  } { "n"  integer  } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $description "If the credit card number passes the Luhn algorithm, converts it to an integer, otherwise throws an error."  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $notes "See "  { $url "http://en.wikipedia.org/wiki/Luhn_algorithm"  } " for a description of this algorithm."  } ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  v-default  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values { "str"  string  } { "def"  string  } { "str/def"  string  } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $description "If the input string is not specified, replaces it with the default value."  } ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  v-email  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values { "str"  string  } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $description "Throws a validation error if the string is not a valid e-mail address, as determined by a regular expression."  } ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  v-integer  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values { "str"  string  } { "n"  integer  } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $description "Converts the string into an integer, throwing a validation error if the string is not a valid integer."  } ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  v-min-length  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values { "str"  string  } { "n"  integer  } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $description "Throws a validation error if the string is shorter than "  { $snippet "n"  } " characters."  } ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  v-max-length  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values { "str"  string  } { "n"  integer  } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $description "Throws a validation error if the string is longer than "  { $snippet "n"  } " characters."  } ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  v-max-value  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values { "x"  integer  } { "n"  integer  } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $description "Throws an error if "  { $snippet "x"  } " is larger than "  { $snippet "n"  } "."  } ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  v-min-value  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values { "x"  integer  } { "n"  integer  } }  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $description "Throws an error if "  { $snippet "x"  } " is smaller than "  { $snippet "n"  } "."  } ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  v-mode  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values { "str"  string  } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $description "Throws an error if "  { $snippet "str"  } " is not a valid XMode mode name."  } ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  v-number  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values { "str"  string  } { "n"  real  } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $description "Converts the string into a real number, throwing a validation error if the string is not a valid real number."  } ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  v-one-line  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values { "str"  string  } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $description "Throws a validation error if the string contains line breaks."  } ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  v-one-word  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values { "str"  string  } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $description "Throws a validation error if the string contains word breaks."  } ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  v-optional  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values { "str"  string  } { "quot"  quotation } { "result"  string  } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $description "If the string is non-empty, applies the quotation to the string, otherwise outputs the empty string."  } ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  v-password  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values { "str"  string  } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $description "A reasonable default validator for passwords."  } ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  v-regexp  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values { "str"  string  } { "what"  string  } { "regexp"  regexp } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $description "Throws a validation error that "  { $snippet "what"  } " failed if the string does not match the regular expression."  } ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  v-required  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values { "str"  string  } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $description "Throws a validation error if the string is empty."  } ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  v-url  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values { "str"  string  } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $description "Throws an error if the string is not a valid URL, as determined by a regular expression."  } ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  v-username  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values { "str"  string  } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $description "A reasonable default validator for usernames."  } ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								ARTICLE: "validators"  "Form validators" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								"The "  { $vocab-link "validators"  } " vocabulary provides a set of words which are intended to be used with the form validation functionality offered by "  { $vocab-link "furnace.actions"  } ". They can also be used independently of the web framework."  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								$nl
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								"Note that validators which take numbers must be preceded by "  { $link v-integer } " or "  { $link v-number } " if the original input is a string."  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								$nl
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								"Higher-order validators which require additional parameters:"  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $subsection v-default     }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $subsection v-optional    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $subsection v-min-length  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $subsection v-max-length  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $subsection v-min-value   }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $subsection v-max-value   }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $subsection v-regexp      }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								"Simple validators:"  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $subsection v-required    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $subsection v-number      }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $subsection v-integer     }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $subsection v-one-line    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $subsection v-one-word    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $subsection v-captcha     }
							 
						 
					
						
							
								
									
										
										
										
											2009-01-11 00:53:23 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $subsection v-checkbox    }
							 
						 
					
						
							
								
									
										
										
										
											2008-09-24 01:45:39 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								"More complex validators:"  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $subsection v-email       }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $subsection v-url         }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $subsection v-username    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $subsection v-password    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $subsection v-credit-card }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $subsection v-mode        } ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								ABOUT: "validators"