Package aquarium :: Package util :: Module FormValid :: Class Form
[show private | hide private]
[frames | no frames]

Class Form


This class uses the member variable "constraints" as a list to store elements of type class Field. The form then represents a form of user input controls, perhaps an HTML form. Add fields to this class, call the validate() method and let the magic begin.

It is expected that you will usually just subclass this class and modify self.constraints at that time. Obviously you don't need to do this.

Setting up rules is done when you add a Field and is documented there


Method Summary
  __init__(self, constraints)
A Default constructor that is not often called.
  __call__(self, values)
  flattenResults(self)
  isValid(self)
Call this after doing a validate().
  validate(self, values)
The main magic worker.

Method Details

__init__(self, constraints)
(Constructor)

A Default constructor that is not often called.

isValid(self)

Call this after doing a validate(). Returns true if the form is 100% valid and false otherwise

validate(self, values)

The main magic worker. Loops over each of the field elements stored in self.constraints and calls its validate() method. Takes the results returned by the validation and updates its results dict.

Returns a dictionary containing all of the fields we validated, indexed by field name.


Generated by Epydoc 2.1 on Mon Jan 1 16:34:19 2007 http://epydoc.sf.net