Loading TOC...

xdmp:json-validate-node

xdmp:json-validate-node(
   $node as node(),
   $schema as node(),
   $mode 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.
$mode Validation mode, either "full" or "strict". When the mode is "full", keep trying to find errors. The default is "strict", which stops on the first error.

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.

Comments

The commenting feature on this page is enabled by a third party. Comments posted to this page are publicly visible.