Commit 9d387437 authored by Pierre Dittgen's avatar Pierre Dittgen
Browse files

Emit check error if an unknown custom check is used

parent c425a888
......@@ -5,6 +5,8 @@ from typing import Optional
import frictionless
from validata_core.custom_checks.utils import build_check_error
from .custom_checks import MissingRequiredHeader, available_checks
from .error_messages import error_translate
from .helpers import (
......@@ -108,12 +110,17 @@ def validate(source, schema, **options):
]
# Dynamically add custom check based on schema needs
check_errors = []
for cc_conf in schema.get("custom_checks", []):
cc_name = cc_conf["name"]
if cc_name in available_checks:
cc_class = available_checks[cc_name]
cc_descriptor = cc_conf["params"]
extra_checks.append(cc_class(cc_descriptor))
if cc_name not in available_checks:
check_errors.append(
build_check_error(cc_name, note="custom check inconnu.")
)
continue
cc_class = available_checks[cc_name]
cc_descriptor = cc_conf["params"]
extra_checks.append(cc_class(cc_descriptor))
# Merge options to pass to frictionless
validate_options = {
......@@ -159,6 +166,9 @@ def validate(source, schema, **options):
source_header, required_field_names, original_schema
)
)
if check_errors:
table["errors"].extend(check_errors)
report["valid"] = False
# translate errors
report["errors"] = [error_translate(err, schema) for err in report["errors"]]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment