Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Validata
validata-ui
Commits
485adb55
Commit
485adb55
authored
Oct 03, 2018
by
Pierre Dittgen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Contextualize errors on 'row-number' attr presence
parent
0c0c95c2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
37 deletions
+42
-37
validata_ui_next/views.py
validata_ui_next/views.py
+42
-37
No files found.
validata_ui_next/views.py
View file @
485adb55
...
...
@@ -52,42 +52,42 @@ def extract_source_data(source: ValidataSource, preview_rows_nb=5):
'preview_rows'
:
rows
[:
preview_rows_nb
]}
ERR_CODE_TO_CONTEXT
=
dict
([
# TODO: gets it from spec.json
(
'duplicate-header'
,
'head'
),
(
'extra-value'
,
'body'
),
(
'missing-value'
,
'body'
),
(
'source-error'
,
'table'
),
(
'schema-error'
,
'table'
),
(
'non-matching-header'
,
'head'
),
(
'blank-row'
,
'body'
),
(
'blank-header'
,
'head'
),
(
'enumerable-constraint'
,
'body'
),
(
'http-error'
,
'table'
),
(
'scheme-error'
,
'table'
),
(
'type-or-format-error'
,
'body'
),
(
'format-error'
,
'table'
),
(
'extra-header'
,
'head'
),
(
'pattern-constraint'
,
'body'
),
(
'required-constraint'
,
'body'
),
(
'missing-header'
,
'head'
),
(
'maximum-length-constraint'
,
'body'
),
(
'maximum-constraint'
,
'body'
),
(
'minimum-length-constraint'
,
'body'
),
(
'encoding-error'
,
'table'
),
(
'io-error'
,
'table'
),
(
'unique-constraint'
,
'body'
),
(
'duplicate-row'
,
'body'
),
(
'minimum-constraint'
,
'body'
),
# TODO: get it from validata_validate
(
'invalid-column-delimiter'
,
'table'
),
(
'missing-headers'
,
'table'
),
(
'wrong-headers-order'
,
'table'
),
(
'extra-headers'
,
'table'
),
# Custom checks fall in default case: body
])
#
ERR_CODE_TO_CONTEXT = dict([
#
# TODO: gets it from spec.json
#
('duplicate-header', 'head'),
#
('extra-value', 'body'),
#
('missing-value', 'body'),
#
('source-error', 'table'),
#
('schema-error', 'table'),
#
('non-matching-header', 'head'),
#
('blank-row', 'body'),
#
('blank-header', 'head'),
#
('enumerable-constraint', 'body'),
#
('http-error', 'table'),
#
('scheme-error', 'table'),
#
('type-or-format-error', 'body'),
#
('format-error', 'table'),
#
('extra-header', 'head'),
#
('pattern-constraint', 'body'),
#
('required-constraint', 'body'),
#
('missing-header', 'head'),
#
('maximum-length-constraint', 'body'),
#
('maximum-constraint', 'body'),
#
('minimum-length-constraint', 'body'),
#
('encoding-error', 'table'),
#
('io-error', 'table'),
#
('unique-constraint', 'body'),
#
('duplicate-row', 'body'),
#
('minimum-constraint', 'body'),
#
# TODO: get it from validata_validate
#
('invalid-column-delimiter', 'table'),
#
('missing-headers', 'table'),
#
('wrong-headers-order', 'table'),
#
('extra-headers', 'table'),
#
# Custom checks fall in default case: body
#
])
ERROR_MESSAGE_FUNC
=
{
...
...
@@ -133,7 +133,12 @@ def improve_messages(errors, headers, schema):
def
contextualize
(
errors
):
""" add context to errors """
return
[{
**
err
,
'context'
:
ERR_CODE_TO_CONTEXT
.
get
(
err
[
'code'
],
'body'
)}
for
err
in
errors
]
def
add_context
(
err
):
""" Adds context info based on row-nb presence """
context
=
'body'
if
'row-number'
in
err
else
'table'
return
{
**
err
,
'context'
:
context
}
return
list
(
map
(
add_context
,
errors
))
def
create_validata_report
(
goodtables_report
,
schema
):
...
...
Write
Preview
Markdown
is supported
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