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
Alexandre Bulté
Validata Core
Commits
5f92b8a2
Commit
5f92b8a2
authored
Apr 01, 2019
by
Alexandre Bulté
Browse files
Improved string errors are now specific to format, if any
parent
9f83a7f8
Pipeline
#718
passed with stage
in 34 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
validata_core/messages.py
View file @
5f92b8a2
...
...
@@ -142,6 +142,7 @@ def type_or_format_error(err, schema):
"""type-or-format-error"""
err_type
=
err
[
'message-data'
][
'field_type'
]
err_value
=
err
[
'message-data'
][
'value'
]
err_format
=
err
[
'message-data'
].
get
(
'field_format'
)
# Date
if
err_type
==
'date'
:
...
...
@@ -178,7 +179,16 @@ def type_or_format_error(err, schema):
# String
elif
err_type
==
'string'
:
return
u_err
(
err
,
'Format de chaîne incorrect'
,
'La valeur doit être une chaîne de caractères.'
)
if
err_format
==
'uri'
:
return
u_err
(
err
,
'Format de chaîne incorrect'
,
'La valeur doit être une adresse de site ou de page internet (URL).'
)
elif
err_format
==
'email'
:
return
u_err
(
err
,
'Format de chaîne incorrect'
,
'La valeur doit être une adresse email.'
)
elif
err_format
==
'binary'
:
return
u_err
(
err
,
'Format de chaîne incorrect'
,
'La valeur doit être une chaîne encodée en base64.'
)
elif
err_format
==
'uuid'
:
return
u_err
(
err
,
'Format de chaîne incorrect'
,
'La valeur doit être un UUID.'
)
else
:
return
u_err
(
err
,
'Format de chaîne incorrect'
,
'La valeur doit être une chaîne de caractères.'
)
# Boolean
elif
err_type
==
'boolean'
:
...
...
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