Package zope :: Package schema :: Module _field
[show private | hide private]
[frames | no frames]

Module zope.schema._field

Schema Fields

$Id: _field.py,v 1.2 2005/06/24 16:52:59 nyergler Exp $


Classes
AbstractCollection  
ASCII  
Bytes  
BytesLine A Text field with no newlines.
Choice Choice fields can have a value found in a constant or dynamic set of values given by the field definition.
Date  
Datetime  
Dict A field representing a Dict.
DottedName Dotted name field.
Float  
Id Id field
InterfaceField  
List A field representing a List.
Object  
Set A field representing a set.
SourceText  
Timedelta  
Tuple A field representing a Tuple.
URI URI schema field

Function Summary
  _validate_fields(schema, value, errors)
  _validate_sequence(value_type, value, errors)
Validates a sequence value.
  _validate_uniqueness(value)

Function Details

_validate_sequence(value_type, value, errors=None)

Validates a sequence value.

Returns a list of validation errors generated during the validation. If no errors are generated, returns an empty list.

value_type is a field. value is the sequence being validated. errors is an optional list of errors that will be prepended to the return value.

To illustrate, we'll use a text value type. All values must be unicode.

>>> field = TextLine(required=True)

To validate a sequence of various values:

>>> errors = _validate_sequence(field, ('foo', u'bar', 1))
>>> errors
[foo <type 'unicode'>, 1 <type 'unicode'>]

The only valid value in the sequence is the second item. The others generated errors.

We can use the optional errors argument to collect additional errors for a new sequence:

>>> errors = _validate_sequence(field, (2, u'baz'), errors)
>>> errors
[foo <type 'unicode'>, 1 <type 'unicode'>, 2 <type 'unicode'>]

Generated by Epydoc 2.1 on Fri Jun 24 12:01:26 2005 http://epydoc.sf.net