Best practices

Best practices#

Validation of input dictionaries by the lattice_validator carries out three distinct operations:

  • Validation of the input dictionary (ensuring that the input adheres to the schemata)

  • Normalization of the input dictionary (bringing the input into a canonical form, which can be used by the lattice_builder)

  • Setting of default values (supporting the user to explore configuration options)

We strongly suggest to follow the guidelines below when using the lattice_validator:

serialization:

The validateConfiguration method of the Validator object returns a boolean indicating whether the input is valid and the normalized configuration, which can be passed to the lattice_builder (provided the input dictionary has been successfully validated!). If you want to serialize the input dictionary as a yaml file, it is recommended to serialize the original input dictionary and not the normalized configuration, after you have made sure that the original configuration passes validation. In this way the serialized input corresponds to the original input and does not contain default settings generated during the validation process or a normalized representation of the original input. This makes the file more readable by humans.

deserialization:

If you load a configuration from a yaml file, it is recommended to always run the validateConfiguration method of the Validator in order to ensure that the deserialized input is valid. Furthermore, this ensures that the input is properly normalized to be used by the lattice_builder.