Commit d388ca3b authored by Cédric Le Ninivin's avatar Cédric Le Ninivin

erp5_json_type: fix validate local json to not rise when no data is available

parent ec77a5f5
......@@ -60,11 +60,12 @@ class JSONType(XMLObject):
Validate contained JSON with the Schema defined in the Portal Type.
"""
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()
if text_content is None:
return False
if not defined_schema or text_content is None:
# No errors if nothing is defined
return True
defined_schema = json.loads(defined_schema)
current_schema = json.loads(text_content)
try:
jsonschema.validate(current_schema, defined_schema, format_checker=jsonschema.FormatChecker())
......
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