Interfaces¶
- colander.interfaces.Preparer(value)¶
A preparer is called after deserialization of a value but before that value is validated.
Any modifications to
value
required should be made by returning the modified value rather than modifying in-place.If no modification is required, then
value
should be returned as-is.
- colander.interfaces.Validator(node, value)¶
A validator is called after preparation of the deserialized value.
If
value
is not valid, raise acolander.Invalid
instance as an exception after.node
is acolander.SchemaNode
instance, for use when raising acolander.Invalid
exception.
- class colander.interfaces.Type¶
- deserialize(node, cstruct)¶
Deserialze the cstruct represented by
cstruct
to an appstruct. The deserialization should be composed of one or more objects which can be serialized by thecolander.interfaces.Type.serialize()
method of this type.node
is acolander.SchemaNode
instance.cstruct
is a cstruct.If the object cannot be deserialized for any reason, a
colander.Invalid
exception should be raised.
- serialize(node, appstruct)¶
Serialize the appstruct represented by
appstruct
to a cstruct. The serialization should be composed of one or more objects which can be deserialized by thecolander.interfaces.Type.deserialize()
method of this type.node
is acolander.SchemaNode
instance.appstruct
is an appstruct.If
appstruct
is the special valuecolander.null
, the type should serialize a null value.If the object cannot be serialized for any reason, a
colander.Invalid
exception should be raised.