Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Validata
Validata Core
Commits
9d387437
Commit
9d387437
authored
Nov 09, 2021
by
Pierre Dittgen
Browse files
Emit check error if an unknown custom check is used
parent
c425a888
Changes
1
Show whitespace changes
Inline
Side-by-side
validata_core/__init__.py
View file @
9d387437
...
...
@@ -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,9 +110,14 @@ 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
:
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
))
...
...
@@ -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"
]]
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment