Skip to content

Validation Module

Validation of configuration.

validate_config(config, schema, config_type)

Validate configuration.

Parameters

config : dict Config dictionary imported by read_yaml() and parsed through clean_config(). schema : Schema A schema against which the configuration is to be compared. config_type : str Description of of configuration being validated.

Source code in topostats/validation.py
def validate_config(config: dict, schema: Schema, config_type: str) -> None:
    """
    Validate configuration.

    Parameters
    ----------
    config : dict
        Config dictionary imported by read_yaml() and parsed through clean_config().
    schema : Schema
        A schema against which the configuration is to be compared.
    config_type : str
        Description of of configuration being validated.
    """
    try:
        schema.validate(config)
        LOGGER.info(f"The {config_type} is valid.")
    except SchemaError as schema_error:
        raise SchemaError(
            f"There is an error in your {config_type} configuration. "
            "Please refer to the first error message above for details"
        ) from schema_error

handler: python options: docstring_style: numpy rendering: show_signature_annotations: true