Core classes for validation.
Check whether the given value should be considered “empty”.
Check whether obj is a Validator instance or class.
A dummy value used for parameters with no default.
This is raised in response to invalid input. It has several public attributes:
The base class of most validators. See IValidator for more, and FancyValidator for the more common (and more featureful) class.
Messages
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:
These two external methods make use of the following four important internal methods that can be overridden. However, none of these have to be overridden, only the ones that are appropriate for the validator.
You should make sure that all possible validation errors are raised in at least one these four methods, not matter which.
Subclasses can also override the __init__() method if the declarative.Declarative model doesn’t work for this.
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:
These parameters are handled at the level of the external methods .to_python() and .from_python already; if you overwrite one of the internal methods, you usually don’t need to care about them.
Messages