Loading TOC...


   $node as node(),
   $schema as xs:string,
   $mode as xs:string
) as node()


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.

$node JSON node to be validated.
$schema URI of the JSON schema to use for validation.
$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.


(: Assuming the following JSON schema is in the schema database at
   "/schemas/example.json" :
      "language": "zxx",
      "$schema": "http://json-schema.org/draft-07/schema#",
      "properties": {
         "count": { "type":"integer", "minimum":0 },
         "items": { "type":"array", "items": {"type":"string", "minLength":1 } }
     object-node{ "count": 3, "items": array-node{12} }, "/schemas/example.json" )

=> XDMP-JSVALIDATEINVTYPE: Invalid node type: Expected node of type text, found number at number-node{12} using schema "/schemas/example.json"
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.


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