MarkLogic 9 Product Documentation
xdmp.jsonValidateNode

xdmp.jsonValidateNode(
   node as Node,
   schema as Node,
   options as 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.jsonValidateNode(
     { "count": 3, "items": [12] }, 
     {
       "properties": {
          "count": { "type":"integer", "minimum":0 },
          "items": { "type":"array", "items": {"type":"string", "minLength":1 } }
        }
     })
=> XDMP-JSVALIDATEINVTYPE: xdmp.jsonValidateNode( -- Invalid node type: Expected node of type text, found number at NumberNode(12) using schema ""
Powered by MarkLogic Server | Terms of Use | Privacy Policy