-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Currently, creating a custom check that is required involves the invocation of two different classes and the repetition of the message and path string for both:
import check_datapackage as cdp
license_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",
)
license_required = cdp.RequiredCheck(
jsonpath="$.licenses[*].name",
message="Data Packages may only be licensed under MIT.",
)
package_properties = cdp.example_package_properties()
config = cdp.Config(
extensions=cdp.Extensions(
custom_checks=[license_check], required_checks=[license_required]
)
)
cdp.check(properties=package_properties, config=config, error=True)We could of course assign the message and path strings to variables beforehand, but it is still a bit clunky. I saw that the 'required' type is explicitly disabled for the custom class, so I take it as there was some issue, but maybe this is still something to do here to make the workflow easier.
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
Todo