Module metavalidation
source code
Meta information validation.
The idea is that you define certain assertions about the meta
information of a given object type. Defined assertions are
-
MetaExists -- a key is present
-
MetaIsAtomic -- a key is present and a "leaf", i.e., has a
single value
-
MetaAtomicExistsOnSelf -- a key is present even without meta
inheritance, and has a single value
Validators are usually built using model descriptions. These are
enumerations of meta keys, separated by commata, with an optional code in
parenteses. Whitespace is ignored. Codes allowed in parens are:
-
empty (default): plain existence
-
!: atomic existance on self
-
1: atomic existance
An example for a valid model description:
"publisher.name,creator.email(), identifier (!),
dateUpdated(1)"
These model descriptions can come in metaModel attributes of
structures. If they are, you can use the validateStructure function below
to validate an entire structure tree.
|
__package__ = ' gavo.base '
|
returns a MetaValidator for a model description.
model descriptions are covered in the module docstring.
|
does a meta validation for a base.Structure.
This works by traversing the children of the structure, looking for
nodes with a metaModel attribute. For all these, a validation is carried
out. The first node failing the validation determines the return
value.
The function raises a MetaValidationError if aStruct is invalid.
|