api

Core classes for validation.


Attributes

a Identity

validators.Identity

Functions

f is_validator(obj) ...

Classes

C NoDefault(...) ...

C Invalid(...) ...

This is raised in response to invalid input. It has several public attributes:

msg:
The message, without values substituted. For instance, if you want HTML quoting of values, you can apply that.
substituteArgs:
The arguments (a dictionary) to go with msg .
str(self):
The message describing the error, with values substituted.
value:
The offending (invalid) value.
state:
The state that went with this validator. This is an application-specific object.
error_list:
If this was a compound validator that takes a repeating value, and sub-validator(s) had errors, then this is a list of those exceptions. The list will be the same length as the number of values -- valid values will have None instead of an exception.
error_dict:
Like error_list , but for dictionary compound validators.

This class contains 3 members.

C Validator(...) ...

The base class of most validators. See IValidator for more, and FancyValidator for the more common (and more featureful) class.

Messages

This class contains 20 members.

C FancyValidator(...) ...

FancyValidator is the (abstract) superclass for various validators and converters. A subclass can validate, convert, or do both. There is no formal distinction made here.

Validators have two important external methods:

There are five important methods for subclasses to override, however none of these have to be overridden, only the ones that are appropriate for the validator:

Validators should have no internal state besides the values given at instantiation. They should be reusable and reentrant.

All subclasses can take the arguments/instance variables:

Messages

badType:
The input must be a string (not a %(type)s: %(value)r)
empty:
Please enter a value
noneType:
The input must be a string (not None)

This class contains 32 members.

See the source for more information.