esm-tools / pymorize

A Python based Tool to CMORize NetCDF Data
https://pymorize.readthedocs.io
MIT License
2 stars 1 forks source link

Validation of User Configuration #28

Closed pgierz closed 2 months ago

pgierz commented 3 months ago

This adds a collection of validators that can be run against the user supplied dictionaries to check for errors.

Closes #27

pgierz commented 3 months ago

This looks promising for capturing user errors, just need some nice formatting:

        if "rules" in data:
            if not RULES_VALIDATOR.validate({"rules": data["rules"]}):
>               raise ValueError(RULES_VALIDATOR.errors)
E               ValueError: {'rules': [{0: [{'description': ['unknown field'], 'enabled': ['unknown field'], 'pipelines': ['unknown field']}], 1: [{'cmor_units': ['unknown field'], 'description': ['unknown field'], 'enabled': ['unknown field'], 'pipelines': ['unknown field']}], 2: [{'cmor_variable': ['null value not allowed'], 'enabled': ['unknown field']}], 3: [{'cmor_variable': ['null value not allowed'], 'pipelines': ['unknown field']}]}]}