Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Carlos Ramos Carreño
erp5
Commits
5625fcce
Commit
5625fcce
authored
Nov 04, 2021
by
Cédric Le Ninivin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_json_type: fix validate local json to not rise when no data is available
parent
9d1be6f1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
4 deletions
+5
-4
bt5/erp5_json_type/DocumentTemplateItem/portal_components/document.erp5.JSONType.py
...tTemplateItem/portal_components/document.erp5.JSONType.py
+5
-4
No files found.
bt5/erp5_json_type/DocumentTemplateItem/portal_components/document.erp5.JSONType.py
View file @
5625fcce
...
@@ -60,11 +60,12 @@ class JSONType(XMLObject):
...
@@ -60,11 +60,12 @@ class JSONType(XMLObject):
Validate contained JSON with the Schema defined in the Portal Type.
Validate contained JSON with the Schema defined in the Portal Type.
"""
"""
portal
=
self
.
getPortalObject
()
portal
=
self
.
getPortalObject
()
defined_schema
=
json
.
loads
(
portal
.
portal_types
[
self
.
getPortalType
()].
asJSONText
()
)
defined_schema
=
portal
.
portal_types
[
self
.
getPortalType
()].
getTextContent
(
)
text_content
=
self
.
asJSONText
()
text_content
=
self
.
asJSONText
()
if
not
defined_schema
or
text_content
is
None
:
if
text_content
is
None
:
# No errors if nothing is defined
return
False
return
True
defined_schema
=
json
.
loads
(
defined_schema
)
current_schema
=
json
.
loads
(
text_content
)
current_schema
=
json
.
loads
(
text_content
)
try
:
try
:
jsonschema
.
validate
(
current_schema
,
defined_schema
,
format_checker
=
jsonschema
.
FormatChecker
())
jsonschema
.
validate
(
current_schema
,
defined_schema
,
format_checker
=
jsonschema
.
FormatChecker
())
...
...
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