Skip to content

Commit

Permalink
Make Object a bootstrapfield and share the logic between Object valid…
Browse files Browse the repository at this point in the history
…ation and the public functions get[Schema]ValidationErrors.

Fixes #57

This makes Object bind all fields (not just choices) before
validation. This fixes #17 in a backwards compatible way.

Binding all attributes, not just Choices, reduced the dependencies of
Object and facilitated making it a bootstrap field. Making it a
bootstrap field in turn let us use it in more places in interfaces.py,
which fixes #13.

Switch from just repeating attribute names in interfaces.py to a real
__all__ attribute that linters can warn about.

Change ..autoclass:: in api.rst to ..autointerface:: so we get the
actual member documentation and not lots of warnings about missing
__mro__. (This is unrelated, I was just tired of the warnings.)
  • Loading branch information
jamadden committed Sep 5, 2018
1 parent e163d53 commit 3c49bac
Show file tree
Hide file tree
Showing 9 changed files with 602 additions and 349 deletions.
11 changes: 11 additions & 0 deletions CHANGES.rst
Expand Up @@ -107,6 +107,17 @@
- Make ``SimpleVocabulary`` and ``SimpleTerm`` have value-based
equality and hashing methods.

- All fields of the schema of an ``Object`` field are bound to the
top-level value being validated before attempting validation of
their particular attribute. Previously only ``IChoice`` fields were
bound. See `issue 17
<https://github.com/zopefoundation/zope.schema/issues/17>`_.

- Share the internal logic of ``Object`` field validation and
``zope.schema.getValidationErrors``. See `issue 57
<https://github.com/zopefoundation/zope.schema/issues/57>`_.


4.5.0 (2017-07-10)
==================

Expand Down
128 changes: 64 additions & 64 deletions docs/api.rst
Expand Up @@ -9,97 +9,97 @@ better guide to the intended usage.
Interfaces
==========

.. autoclass:: zope.schema.interfaces.IField
.. autoclass:: zope.schema.interfaces.IFromUnicode
.. autoclass:: zope.schema.interfaces.IChoice
.. autoclass:: zope.schema.interfaces.IContextAwareDefaultFactory
.. autoclass:: zope.schema.interfaces.IOrderable
.. autoclass:: zope.schema.interfaces.ILen
.. autoclass:: zope.schema.interfaces.IMinMax
.. autoclass:: zope.schema.interfaces.IMinMaxLen
.. autoclass:: zope.schema.interfaces.IInterfaceField
.. autoclass:: zope.schema.interfaces.IBool
.. autoclass:: zope.schema.interfaces.IObject
.. autoclass:: zope.schema.interfaces.IDict
.. autointerface:: zope.schema.interfaces.IField
.. autointerface:: zope.schema.interfaces.IFromUnicode
.. autointerface:: zope.schema.interfaces.IChoice
.. autointerface:: zope.schema.interfaces.IContextAwareDefaultFactory
.. autointerface:: zope.schema.interfaces.IOrderable
.. autointerface:: zope.schema.interfaces.ILen
.. autointerface:: zope.schema.interfaces.IMinMax
.. autointerface:: zope.schema.interfaces.IMinMaxLen
.. autointerface:: zope.schema.interfaces.IInterfaceField
.. autointerface:: zope.schema.interfaces.IBool
.. autointerface:: zope.schema.interfaces.IObject
.. autointerface:: zope.schema.interfaces.IDict

Strings
-------

.. autoclass:: zope.schema.interfaces.IBytes
.. autoclass:: zope.schema.interfaces.IBytesLine
.. autoclass:: zope.schema.interfaces.IText
.. autoclass:: zope.schema.interfaces.ITextLine
.. autoclass:: zope.schema.interfaces.IASCII
.. autoclass:: zope.schema.interfaces.IASCIILine
.. autointerface:: zope.schema.interfaces.IBytes
.. autointerface:: zope.schema.interfaces.IBytesLine
.. autointerface:: zope.schema.interfaces.IText
.. autointerface:: zope.schema.interfaces.ITextLine
.. autointerface:: zope.schema.interfaces.IASCII
.. autointerface:: zope.schema.interfaces.IASCIILine

.. autoclass:: zope.schema.interfaces.IPassword
.. autoclass:: zope.schema.interfaces.IURI
.. autoclass:: zope.schema.interfaces.IId
.. autoclass:: zope.schema.interfaces.IDottedName
.. autointerface:: zope.schema.interfaces.IPassword
.. autointerface:: zope.schema.interfaces.IURI
.. autointerface:: zope.schema.interfaces.IId
.. autointerface:: zope.schema.interfaces.IDottedName


Numbers
-------

.. autoclass:: zope.schema.interfaces.INumber
.. autoclass:: zope.schema.interfaces.IComplex
.. autoclass:: zope.schema.interfaces.IReal
.. autoclass:: zope.schema.interfaces.IRational
.. autoclass:: zope.schema.interfaces.IIntegral
.. autointerface:: zope.schema.interfaces.INumber
.. autointerface:: zope.schema.interfaces.IComplex
.. autointerface:: zope.schema.interfaces.IReal
.. autointerface:: zope.schema.interfaces.IRational
.. autointerface:: zope.schema.interfaces.IIntegral

.. autoclass:: zope.schema.interfaces.IInt
.. autoclass:: zope.schema.interfaces.IFloat
.. autoclass:: zope.schema.interfaces.IDecimal
.. autointerface:: zope.schema.interfaces.IInt
.. autointerface:: zope.schema.interfaces.IFloat
.. autointerface:: zope.schema.interfaces.IDecimal

Date/Time
---------

.. autoclass:: zope.schema.interfaces.IDatetime
.. autoclass:: zope.schema.interfaces.IDate
.. autoclass:: zope.schema.interfaces.ITimedelta
.. autoclass:: zope.schema.interfaces.ITime
.. autointerface:: zope.schema.interfaces.IDatetime
.. autointerface:: zope.schema.interfaces.IDate
.. autointerface:: zope.schema.interfaces.ITimedelta
.. autointerface:: zope.schema.interfaces.ITime


Collections
-----------
.. autoclass:: zope.schema.interfaces.IIterable
.. autoclass:: zope.schema.interfaces.IContainer
.. autoclass:: zope.schema.interfaces.ICollection
.. autoclass:: zope.schema.interfaces.ISequence
.. autoclass:: zope.schema.interfaces.IMutableSequence
.. autoclass:: zope.schema.interfaces.IUnorderedCollection
.. autoclass:: zope.schema.interfaces.IAbstractSet
.. autoclass:: zope.schema.interfaces.IAbstractBag

.. autoclass:: zope.schema.interfaces.ITuple
.. autoclass:: zope.schema.interfaces.IList
.. autoclass:: zope.schema.interfaces.ISet
.. autoclass:: zope.schema.interfaces.IFrozenSet
.. autointerface:: zope.schema.interfaces.IIterable
.. autointerface:: zope.schema.interfaces.IContainer
.. autointerface:: zope.schema.interfaces.ICollection
.. autointerface:: zope.schema.interfaces.ISequence
.. autointerface:: zope.schema.interfaces.IMutableSequence
.. autointerface:: zope.schema.interfaces.IUnorderedCollection
.. autointerface:: zope.schema.interfaces.IAbstractSet
.. autointerface:: zope.schema.interfaces.IAbstractBag

.. autointerface:: zope.schema.interfaces.ITuple
.. autointerface:: zope.schema.interfaces.IList
.. autointerface:: zope.schema.interfaces.ISet
.. autointerface:: zope.schema.interfaces.IFrozenSet

Events
------

.. autoclass:: zope.schema.interfaces.IBeforeObjectAssignedEvent
.. autoclass:: zope.schema.interfaces.IFieldEvent
.. autoclass:: zope.schema.interfaces.IFieldUpdatedEvent
.. autointerface:: zope.schema.interfaces.IBeforeObjectAssignedEvent
.. autointerface:: zope.schema.interfaces.IFieldEvent
.. autointerface:: zope.schema.interfaces.IFieldUpdatedEvent

Vocabularies
------------

.. autoclass:: zope.schema.interfaces.ITerm
.. autoclass:: zope.schema.interfaces.ITokenizedTerm
.. autoclass:: zope.schema.interfaces.ITitledTokenizedTerm
.. autoclass:: zope.schema.interfaces.ISource
.. autoclass:: zope.schema.interfaces.ISourceQueriables
.. autoclass:: zope.schema.interfaces.IContextSourceBinder
.. autoclass:: zope.schema.interfaces.IBaseVocabulary
.. autoclass:: zope.schema.interfaces.IIterableVocabulary
.. autoclass:: zope.schema.interfaces.IIterableSource
.. autoclass:: zope.schema.interfaces.IVocabulary
.. autoclass:: zope.schema.interfaces.IVocabularyTokenized
.. autoclass:: zope.schema.interfaces.ITreeVocabulary
.. autoclass:: zope.schema.interfaces.IVocabularyRegistry
.. autoclass:: zope.schema.interfaces.IVocabularyFactory
.. autointerface:: zope.schema.interfaces.ITerm
.. autointerface:: zope.schema.interfaces.ITokenizedTerm
.. autointerface:: zope.schema.interfaces.ITitledTokenizedTerm
.. autointerface:: zope.schema.interfaces.ISource
.. autointerface:: zope.schema.interfaces.ISourceQueriables
.. autointerface:: zope.schema.interfaces.IContextSourceBinder
.. autointerface:: zope.schema.interfaces.IBaseVocabulary
.. autointerface:: zope.schema.interfaces.IIterableVocabulary
.. autointerface:: zope.schema.interfaces.IIterableSource
.. autointerface:: zope.schema.interfaces.IVocabulary
.. autointerface:: zope.schema.interfaces.IVocabularyTokenized
.. autointerface:: zope.schema.interfaces.ITreeVocabulary
.. autointerface:: zope.schema.interfaces.IVocabularyRegistry
.. autointerface:: zope.schema.interfaces.IVocabularyFactory

Exceptions
----------
Expand Down
10 changes: 4 additions & 6 deletions docs/validation.rst
Expand Up @@ -4,13 +4,11 @@ Schema Validation

There are two helper methods to verify schemas and interfaces:

:func:`~.getValidationErrors`
first validates via the zope.schema field validators. If that succeeds the
invariants are checked.
:func:`~.getSchemaValidationErrors`
*only* validates via the zope.schema field validators. The invariants are
*not* checked.
.. autofunction:: zope.schema.getValidationErrors
.. autofunction:: zope.schema.getSchemaValidationErrors

Invariants are `documented by zope.interface
<https://zopeinterface.readthedocs.io/en/latest/README.html#invariants>`_.

Create an interface to validate against:

Expand Down

0 comments on commit 3c49bac

Please sign in to comment.