Loading TOC...

MarkLogic 10 Product Documentation
xdmp.jsonValidateReportNode

xdmp.jsonValidateReportNode(
   node as Node,
   schema as Node,
   options as String[]
) as map:map

Summary

Validate a JSON node against a JSON Schema and return an error report.

Parameters
node JSON node to be validate-reportd.
schema A JSON schema node use for validatation.
options Validation options. Supported options:
"full"
Keep trying to find all the errors. (Default)
"strict"
Stop after the first error.

Example

  xdmp.jsonValidateReportNode(
     { "count": 3, "items": [12] }, 
     {
       "properties": {
          "count": { "type":"integer", "minimum":0 },
          "items": { "type":"array", "items": {"type":"string", "minLength":1 } }
        }
     })
=>
{"errors":["XDMP-JSVALIDATEINVTYPE: Invalid node type: Expected node of type text, found number at NumberNode(12) using schema \"\"", "XDMP-JSVALIDATEINVNODE: Invalid node: Node NumberNode(12) not valid against property 'items' expected {type: string, minLength: 1} using schema \"\"", "XDMP-JSVALIDATEINVNODE: Invalid node: Node ObjectNode({\"count\":3, \"items\":[12]}) not valid against property 'properties' expected {properties: {count:{...}, items:{...}}} using schema \"\""]}

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.