Loading TOC...

MarkLogic Server 11.0 Product Documentation
xdmp:json-validate-node

xdmp:json-validate-node(
   $node as node(),
   $schema as node(),
   $options as xs:string*
) as node()

Summary

Validate a JSON node against a JSON Schema. If the node is not valid per the schema, raise an error. Otherwise, return the input node.

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

Example

  xdmp:json-validate-node(
     object-node{ "count": 3, "items": array-node{12} }, 
     object-node{
       "properties": object-node{
          "count": object-node{ "type":"integer", "minimum":0 },
          "items": object-node{ "type":"array", "items": object-node{"type":"string", "minLength":1 } }
        }
     })

=> XDMP-JSVALIDATEINVTYPE: Invalid node type: Expected node of type text, found number at number-node{12} using schema ""
at 1:0 [1.0-ml]

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