A custom check to be done on Data Package metadata.
Attributes
jsonpath:str
The location of the field or fields the custom check applies to, expressed in JSON path notation (e.g., $.resources[*].name).
message:str
The message shown when the check is violated.
check:Callable[[Any], bool]
A function that expresses the custom check. It takes the value at the jsonpath location as input and returns true if the check is met, false if it isn’t.
type:str
The type of the custom check (e.g., a JSON schema type such as “required”, “type”, “pattern”, or “format”, or a custom type). It will be shown in error messages and can be used in an Exclusion object to exclude the check. Each custom check should have a unique type.
Examples
import check_datapackage as cdplicense_check = cdp.CustomCheck(type="only-mit", jsonpath="$.licenses[*].name", message="Data Packages may only be licensed under MIT.", check=lambda license_name: license_name =="mit",)config = cdp.Config( extensions=cdp.Extensions( custom_checks=[license_check] ))cdp.check(cdp.example_package_properties(), config=config)
[Issue(jsonpath='$.licenses[0].name', type='only-mit', message='Data Packages may only be licensed under MIT.', instance=None)]