Schema

A schema validates a dictionary of values, applying different validators (be key) to the different values. If allow_extra_fields=True, keys without validators will be allowed; otherwise they will raise Invalid. If filter_extra_fields is set to true, then extra fields are not passed back in the results.

Validators are associated with keys either with a class syntax, or as keyword arguments (class syntax is usually easier). Something like:

class MySchema(Schema):
    name = Validators.PlainText()
    phone = Validators.PhoneNumber()

These will not be available as actual instance variables, but will be collected in a dictionary. To remove a validator in a subclass that is present in a superclass, set it to None, like:

class MySubSchema(MySchema):
    name = None

Note that missing fields are handled at the Schema level. Missing fields can have the 'missing' message set to specify the error message, or if that does not exist the schema message 'missingValue' is used.

Messages

badDictType:
The input must be dict-like (not a %(type)s: %(value)r)
badType:
The input must be a string (not a %(type)s: %(value)r)
empty:
Please enter a value
missingValue:
Missing value
noneType:
The input must be a string (not None)
notExpected:
The input field %(name)s was not expected.

Attributes

a pre_validators

[]

a gettextargs

{}

a ignore_key_missing

False

a strip

False

a use_builtins_gettext

True

a accept_python

True

a __singletonmethods__

('to_python', 'from_python', 'message', 'all_messages', 'subvalidators')

a declarative_count

5

a allow_extra_fields

False

a __unpackargs__

()

a add_field

<bound class method Schema.add_field>

a compound

True

a not_empty

False

a add_chained_validator

<bound class method Schema.add_chained_validator>

a filter_extra_fields

False

a add_pre_validator

<bound class method Schema.add_pre_validator>

a fields

{}

a __mutableattributes__

('fields', 'chained_validators', 'pre_validators')

a repeating

False

a chained_validators

[]

a order

[]

Methods

f __classinit__(cls, new_attrs) ...

f __initargs__(self, new_attrs) ...

f assert_dict(self, value, state) ...

Helper to assure we have proper input

f __call__(self, *args, **kw) ...

f __init__(self, *args, **kw) ...

f __sourcerepr__(self, source, binding=None) ...

f __classsourcerepr__(cls, source, binding=None) ...

f subvalidators(self) ...

f is_empty(self, value) ...

f empty_value(self, value) ...

See the source for more information.