Implementation details

Implementation details#

The schemata for the lattice_validator are generated by functions of the schemata module. The easiest way to learn how the schema definitions work is to look at the python sources in the schemata module.

The two most important features of the cerberus package which are used in the schema definitions are:

coerce:

Specifies a function to normalize user input. These "normalization" functions are implemented in the normalizer module of the lattice_validator. Normalization functions aim at providing some flexibility in interpreting user input, e.g., the user can specify a complex value in the input either as a tuple of two real numbers or anything which can be casted into a complex number by python's complex() function.

check_with:

Specifies a function to validate user input beyond the on-board tools of cerberus. These "checker" functions are implemented in the checker module of the lattice_validator. normalization

Furthermore there are two more modules related to input validation. The setter module implements customized functions to set default values and the converter module implements functions able to convert input adhering to the conventions employed in the legacy version of the lattice_builder. Finally the schemaGenerator module provides conveniece functions to setup schema definitions, which are used in the schemata module to define the input schemata for the Validator class to generate the schemata during initialization.