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)
|
reAlphaNum
-
- Type:
-
SRE_Pattern
- Value:
|
reLettersOnly
-
- Type:
-
SRE_Pattern
- Value:
|
reNumbersOnly
-
- Type:
-
SRE_Pattern
- Value:
|