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

Module aquarium.util.FormValid

This module contains classes to help validate user input.

Example usage, a simple one element form:

from aquarium.util.FormValid import Form, Field

(values, errors) = self.createValidator()(ctx.form)
if errors:
    ctx.actionResults("Failed validation.")
    return
# Now, use values instead of ctx.form, and continue on your merry way.

def createValidator():
    return Form([
        Field("source_ip", "IP is invalid",
              regex=re.compile(r"\d+\.\d+\.\d+\.\d+"))
    ])

Classes
Field This class does the majority of the work.
FieldGroup This class allows you to group fields together and do validation based on the results of the validation of those fields
Form This class uses the member variable "constraints" as a list to store elements of type class Field.

Exceptions
FieldInvalid Raise this when a field does not meet the proper type.

Function Summary
  validateMessageBody(values)
  validatePassword(values)

Variable Summary
SRE_Pattern reAlphaNum = [\w\d_-]
SRE_Pattern reLettersOnly = [\w_-]
SRE_Pattern reNumbersOnly = \d

Variable Details

reAlphaNum

Type:
SRE_Pattern
Value:
[\w\d_-]                                                               

reLettersOnly

Type:
SRE_Pattern
Value:
[\w_-]                                                                 

reNumbersOnly

Type:
SRE_Pattern
Value:
\d                                                                     

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