Extensions

Extensions(
    required_checks: list[RequiredCheck] = list[RequiredCheck](),
    custom_checks: list[CustomCheck] = list[CustomCheck](),
)

Extensions to the standard checks.

This sub-item of Config defines extensions, i.e., additional checks that supplement those specified by the Data Package standard. It contains sub-items that store additional checks. This Extensions class can be expanded to include more types of extensions.

Each extension class must implement its own apply() method that takes the datapackage.json properties dict as input and outputs an Issue list that contains the issues found by that extension.

Attributes

required_checks : list[RequiredCheck]

A list of RequiredCheck objects defining properties to set as required.

custom_checks : list[CustomCheck]

A list of CustomCheck objects defining extra, custom checks to run alongside the standard checks.

Examples

import check_datapackage as cdp

extensions = cdp.Extensions(
    required_checks=[
        cdp.RequiredCheck(
            jsonpath="$.description",
            message="Data Packages must include a description.",
        ),
        cdp.RequiredCheck(
            jsonpath="$.contributors[*].email",
            message="All contributors must have an email address.",
        ),
    ],
    custom_checks=[
        cdp.CustomCheck(
            type="only-mit",
            jsonpath="$.licenses[*].name",
            message="Data Packages may only be licensed under MIT.",
            check=lambda license_name: license_name == "mit",
        )
    ],
)
# check(properties, config=cdp.Config(extensions=extensions))