diff --git a/404.html b/404.html index 6d40b27f6..434848d7b 100644 --- a/404.html +++ b/404.html @@ -18,13 +18,13 @@ - + -

404

Looks like we've got some broken links.
+ - + diff --git a/api.html b/api.html index 380bf6c5b..2d3c3e5a1 100644 --- a/api.html +++ b/api.html @@ -18,7 +18,7 @@ - + @@ -361,6 +361,6 @@ →

- + diff --git a/assets/js/47.927459bf.js b/assets/js/47.927459bf.js new file mode 100644 index 000000000..8f0ed54cd --- /dev/null +++ b/assets/js/47.927459bf.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[47],{393:function(e,t,o){"use strict";o.r(t);var a=o(14),r=Object(a.a)({},(function(){var e=this,t=e._self._c;return t("ContentSlotsDistributor",{attrs:{"slot-key":e.$parent.slotKey}},[t("h1",{attrs:{id:"type-coercion-rules"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#type-coercion-rules"}},[e._v("#")]),e._v(" Type coercion rules")]),e._v(" "),t("p",[e._v("To enable type coercion pass option "),t("code",[e._v("coerceTypes")]),e._v(" to Ajv with "),t("code",[e._v("true")]),e._v(" or "),t("code",[e._v("array")]),e._v(" (it is "),t("code",[e._v("false")]),e._v(" by default). See "),t("RouterLink",{attrs:{to:"/guide/modifying-data.html#coercing-data-types"}},[e._v("example")]),e._v(".")],1),e._v(" "),t("p",[e._v("The coercion rules are different from JavaScript:")]),e._v(" "),t("ul",[t("li",[e._v("to validate user input as expected")]),e._v(" "),t("li",[e._v("to have the coercion reversible")]),e._v(" "),t("li",[e._v("to correctly validate cases where different types are required in subschemas (e.g., in "),t("code",[e._v("anyOf")]),e._v(").")])]),e._v(" "),t("p",[e._v("Type coercion only happens if there is "),t("code",[e._v("type")]),e._v(" keyword and if without coercion the validation would have failed. If coercion to the required type succeeds then the validation continues to other keywords, otherwise the validation fails.")]),e._v(" "),t("p",[e._v("If there are multiple types allowed in "),t("code",[e._v("type")]),e._v(" keyword the coercion will only happen if none of the types match the data and some of the scalar types are present (coercion to/from "),t("code",[e._v("object")]),e._v("/"),t("code",[e._v("array")]),e._v(" is not possible). In this case the validating function will try coercing the data to each type in order until some of them succeeds.")]),e._v(" "),t("p",[e._v("Application of these rules can have some unexpected consequences. Ajv may coerce the same value multiple times (this is why coercion reversibility is required) as needed at different points in the schema. This is particularly evident when using "),t("code",[e._v("oneOf")]),e._v(", which must test all of the subschemas. Ajv will coerce the type for each subschema, possibly resulting in unexpected failure if it can coerce to match more than one of the subschemas. Even if it succeeds, Ajv will not backtrack, so you'll get the type of the final coercion even if that's not the one that allowed the data to pass validation. If possible, structure your schema with "),t("code",[e._v("anyOf")]),e._v(", which won't validate subsequent subschemas as soon as it encounters one subschema that matches.")]),e._v(" "),t("p",[e._v("Possible type coercions:")]),e._v(" "),t("table",[t("thead",[t("tr",[t("th",[e._v("from type →"),t("br"),e._v("to type ↓")]),e._v(" "),t("th",{staticStyle:{"text-align":"center"}},[e._v("string")]),e._v(" "),t("th",{staticStyle:{"text-align":"center"}},[e._v("number")]),e._v(" "),t("th",{staticStyle:{"text-align":"center"}},[e._v("boolean")]),e._v(" "),t("th",{staticStyle:{"text-align":"center"}},[e._v("null")]),e._v(" "),t("th",{staticStyle:{"text-align":"center"}},[e._v("array*")])])]),e._v(" "),t("tbody",[t("tr",[t("td",[e._v("string")]),e._v(" "),t("td",{staticStyle:{"text-align":"center"}},[e._v("-")]),e._v(" "),t("td",{staticStyle:{"text-align":"center"}},[t("code",[e._v("x")]),e._v("→"),t("code",[e._v('""+x')])]),e._v(" "),t("td",{staticStyle:{"text-align":"center"}},[t("code",[e._v("false")]),e._v("→"),t("code",[e._v('"false"')]),t("br"),t("code",[e._v("true")]),e._v("→"),t("code",[e._v('"true"')])]),e._v(" "),t("td",{staticStyle:{"text-align":"center"}},[t("code",[e._v("null")]),e._v("→"),t("code",[e._v('""')])]),e._v(" "),t("td",{staticStyle:{"text-align":"center"}},[t("code",[e._v("[x]")]),e._v("→"),t("code",[e._v("x")])])]),e._v(" "),t("tr",[t("td",[e._v("number /"),t("br"),e._v("integer")]),e._v(" "),t("td",{staticStyle:{"text-align":"center"}},[e._v("Valid number /"),t("br"),e._v("integer: "),t("code",[e._v("x")]),e._v("→"),t("code",[e._v("+x")]),t("br")]),e._v(" "),t("td",{staticStyle:{"text-align":"center"}},[e._v("-")]),e._v(" "),t("td",{staticStyle:{"text-align":"center"}},[t("code",[e._v("false")]),e._v("→"),t("code",[e._v("0")]),t("br"),t("code",[e._v("true")]),e._v("→"),t("code",[e._v("1")])]),e._v(" "),t("td",{staticStyle:{"text-align":"center"}},[t("code",[e._v("null")]),e._v("→"),t("code",[e._v("0")])]),e._v(" "),t("td",{staticStyle:{"text-align":"center"}},[t("code",[e._v("[x]")]),e._v("→"),t("code",[e._v("x")])])]),e._v(" "),t("tr",[t("td",[e._v("boolean")]),e._v(" "),t("td",{staticStyle:{"text-align":"center"}},[t("code",[e._v('"false"')]),e._v("→"),t("code",[e._v("false")]),t("br"),t("code",[e._v('"true"')]),e._v("→"),t("code",[e._v("true")]),t("br"),t("code",[e._v('"abc"')]),e._v("⇸"),t("br"),t("code",[e._v('""')]),e._v("⇸")]),e._v(" "),t("td",{staticStyle:{"text-align":"center"}},[t("code",[e._v("0")]),e._v("→"),t("code",[e._v("false")]),t("br"),t("code",[e._v("1")]),e._v("→"),t("code",[e._v("true")]),t("br"),t("code",[e._v("x")]),e._v("⇸")]),e._v(" "),t("td",{staticStyle:{"text-align":"center"}},[e._v("-")]),e._v(" "),t("td",{staticStyle:{"text-align":"center"}},[t("code",[e._v("null")]),e._v("→"),t("code",[e._v("false")])]),e._v(" "),t("td",{staticStyle:{"text-align":"center"}},[t("code",[e._v("[false]")]),e._v("→"),t("code",[e._v("false")]),t("br"),t("code",[e._v("[true]")]),e._v("→"),t("code",[e._v("true")])])]),e._v(" "),t("tr",[t("td",[e._v("null")]),e._v(" "),t("td",{staticStyle:{"text-align":"center"}},[t("code",[e._v('""')]),e._v("→"),t("code",[e._v("null")]),t("br"),t("code",[e._v('"null"')]),e._v("⇸"),t("br"),t("code",[e._v('"abc"')]),e._v("⇸")]),e._v(" "),t("td",{staticStyle:{"text-align":"center"}},[t("code",[e._v("0")]),e._v("→"),t("code",[e._v("null")]),t("br"),t("code",[e._v("x")]),e._v("⇸")]),e._v(" "),t("td",{staticStyle:{"text-align":"center"}},[t("code",[e._v("false")]),e._v("→"),t("code",[e._v("null")]),t("br"),t("code",[e._v("true")]),e._v("⇸")]),e._v(" "),t("td",{staticStyle:{"text-align":"center"}},[e._v("-")]),e._v(" "),t("td",{staticStyle:{"text-align":"center"}},[t("code",[e._v("[null]")]),e._v("→"),t("code",[e._v("null")])])]),e._v(" "),t("tr",[t("td",[e._v("array*")]),e._v(" "),t("td",{staticStyle:{"text-align":"center"}},[t("code",[e._v("x")]),e._v("→"),t("code",[e._v("[x]")])]),e._v(" "),t("td",{staticStyle:{"text-align":"center"}},[t("code",[e._v("x")]),e._v("→"),t("code",[e._v("[x]")])]),e._v(" "),t("td",{staticStyle:{"text-align":"center"}},[t("code",[e._v("false")]),e._v("→"),t("code",[e._v("[false]")]),t("br"),t("code",[e._v("true")]),e._v("→"),t("code",[e._v("[true]")])]),e._v(" "),t("td",{staticStyle:{"text-align":"center"}},[t("code",[e._v("null")]),e._v("→"),t("code",[e._v("[null]")])]),e._v(" "),t("td",{staticStyle:{"text-align":"center"}},[e._v("-")])])])]),e._v(" "),t("p",[e._v("* Requires option "),t("code",[e._v('{coerceTypes: "array"}')])]),e._v(" "),t("h2",{attrs:{id:"coercion-from-string-values"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#coercion-from-string-values"}},[e._v("#")]),e._v(" Coercion from string values")]),e._v(" "),t("h4",{attrs:{id:"to-number-type"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#to-number-type"}},[e._v("#")]),e._v(" To number type")]),e._v(" "),t("p",[e._v("Coercion to "),t("code",[e._v("number")]),e._v(" is possible if the string is a valid number, "),t("code",[e._v("+data")]),e._v(" is used.")]),e._v(" "),t("h4",{attrs:{id:"to-integer-type"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#to-integer-type"}},[e._v("#")]),e._v(" To integer type")]),e._v(" "),t("p",[e._v("Coercion to "),t("code",[e._v("integer")]),e._v(" is possible if the string is a valid number without fractional part ("),t("code",[e._v("data % 1 === 0")]),e._v(").")]),e._v(" "),t("h4",{attrs:{id:"to-boolean-type"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#to-boolean-type"}},[e._v("#")]),e._v(" To boolean type")]),e._v(" "),t("p",[e._v("Unlike JavaScript, only these strings can be coerced to "),t("code",[e._v("boolean")]),e._v(":")]),e._v(" "),t("ul",[t("li",[t("code",[e._v('"true"')]),e._v(" -> "),t("code",[e._v("true")])]),e._v(" "),t("li",[t("code",[e._v('"false"')]),e._v(" -> "),t("code",[e._v("false")])])]),e._v(" "),t("h4",{attrs:{id:"to-null-type"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#to-null-type"}},[e._v("#")]),e._v(" To null type")]),e._v(" "),t("p",[e._v("Empty string is coerced to "),t("code",[e._v("null")]),e._v(", other strings can't be coerced.")]),e._v(" "),t("h2",{attrs:{id:"coercion-from-number-values"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#coercion-from-number-values"}},[e._v("#")]),e._v(" Coercion from number values")]),e._v(" "),t("h4",{attrs:{id:"to-string-type"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#to-string-type"}},[e._v("#")]),e._v(" To string type")]),e._v(" "),t("p",[e._v("Always possible, "),t("code",[e._v("'' + data")]),e._v(" is used")]),e._v(" "),t("h4",{attrs:{id:"to-boolean-type-2"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#to-boolean-type-2"}},[e._v("#")]),e._v(" To boolean type")]),e._v(" "),t("p",[e._v("Unlike JavaScript, only these numbers can be coerced to "),t("code",[e._v("boolean")]),e._v(":")]),e._v(" "),t("ul",[t("li",[t("code",[e._v("1")]),e._v(" -> "),t("code",[e._v("true")])]),e._v(" "),t("li",[t("code",[e._v("0")]),e._v(" -> "),t("code",[e._v("false")])])]),e._v(" "),t("h4",{attrs:{id:"to-null-type-2"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#to-null-type-2"}},[e._v("#")]),e._v(" To null type")]),e._v(" "),t("p",[t("code",[e._v("0")]),e._v(" coerces to "),t("code",[e._v("null")]),e._v(", other numbers can't be coerced.")]),e._v(" "),t("h2",{attrs:{id:"coercion-from-boolean-values"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#coercion-from-boolean-values"}},[e._v("#")]),e._v(" Coercion from boolean values")]),e._v(" "),t("h4",{attrs:{id:"to-string-type-2"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#to-string-type-2"}},[e._v("#")]),e._v(" To string type")]),e._v(" "),t("ul",[t("li",[t("code",[e._v("true")]),e._v(" -> "),t("code",[e._v('"true"')])]),e._v(" "),t("li",[t("code",[e._v("false")]),e._v(" -> "),t("code",[e._v('"false"')])])]),e._v(" "),t("h4",{attrs:{id:"to-number-integer-types"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#to-number-integer-types"}},[e._v("#")]),e._v(" To number/integer types")]),e._v(" "),t("ul",[t("li",[t("code",[e._v("true")]),e._v(" -> "),t("code",[e._v("1")])]),e._v(" "),t("li",[t("code",[e._v("false")]),e._v(" -> "),t("code",[e._v("0")])])]),e._v(" "),t("h4",{attrs:{id:"to-null-type-3"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#to-null-type-3"}},[e._v("#")]),e._v(" To null type")]),e._v(" "),t("p",[t("code",[e._v("false")]),e._v(" coerces to "),t("code",[e._v("null")]),e._v(", "),t("code",[e._v("true")]),e._v(" can't be coerced.")]),e._v(" "),t("h2",{attrs:{id:"coercion-from-null"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#coercion-from-null"}},[e._v("#")]),e._v(" Coercion from null")]),e._v(" "),t("h4",{attrs:{id:"to-string-type-3"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#to-string-type-3"}},[e._v("#")]),e._v(" To string type")]),e._v(" "),t("p",[t("code",[e._v("null")]),e._v(" coerces to the empty string.")]),e._v(" "),t("h4",{attrs:{id:"to-number-integer-types-2"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#to-number-integer-types-2"}},[e._v("#")]),e._v(" To number/integer types")]),e._v(" "),t("p",[t("code",[e._v("null")]),e._v(" coerces to "),t("code",[e._v("0")])]),e._v(" "),t("h4",{attrs:{id:"to-boolean-type-3"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#to-boolean-type-3"}},[e._v("#")]),e._v(" To boolean type")]),e._v(" "),t("p",[t("code",[e._v("null")]),e._v(" coerces to "),t("code",[e._v("false")])]),e._v(" "),t("h2",{attrs:{id:"coercion-to-and-from-array"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#coercion-to-and-from-array"}},[e._v("#")]),e._v(" Coercion to and from array")]),e._v(" "),t("p",[e._v("These coercions require that the option "),t("code",[e._v("coerceTypes")]),e._v(" is "),t("code",[e._v('"array"')]),e._v(".")]),e._v(" "),t("p",[e._v("If a scalar data is present and array is required, Ajv wraps scalar data in an array.")]),e._v(" "),t("p",[e._v("If an array with one item is present and a scalar is required, Ajv coerces array into its item.")]),e._v(" "),t("ul",[t("li",[t("code",[e._v('"foo"')]),e._v(" -> "),t("code",[e._v('[ "foo" ]')])]),e._v(" "),t("li",[t("code",[e._v('[ "foo" ]')]),e._v(" -> "),t("code",[e._v('"foo"')])])])])}),[],!1,null,null,null);t.default=r.exports}}]); \ No newline at end of file diff --git a/assets/js/55.3d3328bf.js b/assets/js/55.3d3328bf.js new file mode 100644 index 000000000..fafa30c7c --- /dev/null +++ b/assets/js/55.3d3328bf.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[55],{415:function(t,a,s){"use strict";s.r(a);var n=s(14),e=Object(n.a)({},(function(){var t=this,a=t._self._c;return a("ContentSlotsDistributor",{attrs:{"slot-key":t.$parent.slotKey}},[a("h1",{attrs:{id:"getting-started"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#getting-started"}},[t._v("#")]),t._v(" Getting started")]),t._v(" "),a("p"),a("div",{staticClass:"table-of-contents"},[a("ul",[a("li",[a("a",{attrs:{href:"#install"}},[t._v("Install")])]),a("li",[a("a",{attrs:{href:"#basic-data-validation"}},[t._v("Basic data validation")])]),a("li",[a("a",{attrs:{href:"#parsing-and-serializing-json"}},[t._v("Parsing and serializing JSON "),a("Badge",{attrs:{text:"New"}})],1)])])]),a("p"),t._v(" "),a("h2",{attrs:{id:"install"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#install"}},[t._v("#")]),t._v(" Install")]),t._v(" "),a("div",{staticClass:"custom-block tip"},[a("p",{staticClass:"custom-block-title"},[t._v("Node REPL")]),t._v(" "),a("p",[t._v("You can try Ajv without installing it in the Node.js REPL: "),a("a",{attrs:{href:"https://runkit.com/npm/ajv",target:"_blank",rel:"noopener noreferrer"}},[t._v("https://runkit.com/npm/ajv"),a("OutboundLink")],1)])]),t._v(" "),a("p",[t._v("To install Ajv version 8:")]),t._v(" "),a("div",{staticClass:"language-bash extra-class"},[a("pre",{pre:!0,attrs:{class:"language-bash"}},[a("code",[a("span",{pre:!0,attrs:{class:"token function"}},[t._v("npm")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("install")]),t._v(" ajv\n")])])]),a("p",[t._v("If you need to use Ajv with "),a("a",{attrs:{href:"./schema-language#draft-04"}},[t._v("JSON Schema draft-04")]),t._v(", you need to install Ajv version 6:")]),t._v(" "),a("div",{staticClass:"language-bash extra-class"},[a("pre",{pre:!0,attrs:{class:"language-bash"}},[a("code",[a("span",{pre:!0,attrs:{class:"token function"}},[t._v("npm")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("install")]),t._v(" ajv@6\n")])])]),a("p",[t._v("See "),a("RouterLink",{attrs:{to:"/CONTRIBUTING.html"}},[t._v("Contributing")]),t._v(" on how to run the tests locally")],1),t._v(" "),a("h2",{attrs:{id:"basic-data-validation"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#basic-data-validation"}},[t._v("#")]),t._v(" Basic data validation")]),t._v(" "),a("p",[t._v("Ajv takes a schema for your JSON data and converts it into a very efficient JavaScript code\nthat validates your data according to the schema. To create a schema you can use either\n"),a("a",{attrs:{href:"../json-schema"}},[t._v("JSON Schema")]),t._v(" or "),a("a",{attrs:{href:"../json-type-definition"}},[t._v("JSON Type Definition")]),t._v(" - check out "),a("a",{attrs:{href:"./schema-language"}},[t._v("Choosing schema language")]),t._v(", they have\ndifferent advantages and disadvantages.")]),t._v(" "),a("p",[t._v('For example, to validate an object that has a required property "foo" (an integer number), an optional property "bar" (a string) and no other properties:')]),t._v(" "),a("code-group",[a("code-block",{attrs:{title:"JSON Schema"}},[a("div",{staticClass:"language-javascript extra-class"},[a("pre",{pre:!0,attrs:{class:"language-javascript"}},[a("code",[a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" Ajv "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("require")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"ajv"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" ajv "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("new")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("Ajv")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// options can be passed, e.g. {allErrors: true}")]),t._v("\n\n"),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" schema "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"object"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("properties")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("foo")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"integer"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("bar")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"string"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("required")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"foo"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("additionalProperties")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token boolean"}},[t._v("false")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n\n"),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" validate "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" ajv"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("compile")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("schema"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n\n"),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" data "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("foo")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("1")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("bar")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"abc"')]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n\n"),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" valid "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("validate")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("data"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("if")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("!")]),t._v("valid"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" console"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("log")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("validate"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("errors"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n")])])])]),t._v(" "),a("code-block",{attrs:{title:"JSON Type Definition"}},[a("div",{staticClass:"language-javascript extra-class"},[a("pre",{pre:!0,attrs:{class:"language-javascript"}},[a("code",[a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" Ajv "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("require")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"ajv/dist/jtd"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" ajv "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("new")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("Ajv")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// options can be passed, e.g. {allErrors: true}")]),t._v("\n\n"),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" schema "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("properties")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("foo")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"int32"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("optionalProperties")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("bar")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"string"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n\n\n"),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" validate "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" ajv"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("compile")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("schema"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n\n"),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" data "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("foo")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("1")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("bar")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"abc"')]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n\n"),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" valid "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("validate")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("data"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("if")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("!")]),t._v("valid"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" console"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("log")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("validate"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("errors"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n")])])])])],1),t._v(" "),a("p",[t._v("Ajv compiles schemas to functions and caches them in all cases (using the schema itself as a key in a Map), so that the next time the same schema object is used it won't be compiled again.")]),t._v(" "),a("div",{staticClass:"custom-block tip"},[a("p",{staticClass:"custom-block-title"},[t._v("Best performance: compile and getSchema methods")]),t._v(" "),a("p",[t._v("The best performance is achieved when using compiled functions returned by "),a("code",[t._v("compile")]),t._v(" or "),a("code",[t._v("getSchema")]),t._v(" methods.")]),t._v(" "),a("p",[t._v("While execution of the compiled validation function is very fast, its compilation is\nrelatively slow, so you need to make sure that you compile schemas only once and\nre-use compiled validation functions. See "),a("a",{attrs:{href:"./managing-schemas"}},[t._v("Managing multiple schemas")]),t._v(".")])]),t._v(" "),a("div",{staticClass:"custom-block warning"},[a("p",{staticClass:"custom-block-title"},[t._v("Save errors property")]),t._v(" "),a("p",[t._v("Every time a validation function (or "),a("code",[t._v("ajv.validate")]),t._v(") is called the "),a("code",[t._v("errors")]),t._v(" property is overwritten. You need to copy the "),a("code",[t._v("errors")]),t._v(" array reference to another variable if you want to use it later (e.g. in the callback). See "),a("RouterLink",{attrs:{to:"/api.html#validation-errors"}},[t._v("Validation errors")]),t._v(".")],1)]),t._v(" "),a("h2",{attrs:{id:"parsing-and-serializing-json"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#parsing-and-serializing-json"}},[t._v("#")]),t._v(" Parsing and serializing JSON "),a("Badge",{attrs:{text:"New"}})],1),t._v(" "),a("p",[t._v("Ajv can compile efficient parsers and serializers from "),a("a",{attrs:{href:"../json-type-definition"}},[t._v("JSON Type Definition")]),t._v(" schemas.")]),t._v(" "),a("p",[t._v("Serializing the data with a function specialized to your data shape can be more than 10x compared with "),a("code",[t._v("JSON.stringify")]),t._v(".")]),t._v(" "),a("p",[t._v("Parsing the data replaces the need for separate validation after generic parsing with "),a("code",[t._v("JSON.parse")]),t._v(" (although validation itself is usually much faster than parsing). In case your JSON string is valid, the specialized parsing is approximately as fast as JSON.parse, but in case your JSON is invalid, the specialized parsing would fail much faster - so it can be very efficient in some scenarios.")]),t._v(" "),a("p",[t._v("For the same data structure, you can compile parser and serializer in this way:")]),t._v(" "),a("code-group",[a("code-block",{attrs:{title:"JSON Type Definition"}},[a("div",{staticClass:"language-javascript extra-class"},[a("pre",{pre:!0,attrs:{class:"language-javascript"}},[a("code",[a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" Ajv "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("require")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"ajv/dist/jtd"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" ajv "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("new")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("Ajv")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// options can be passed, e.g. {allErrors: true}")]),t._v("\n\n"),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" schema "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("properties")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("foo")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"int32"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("optionalProperties")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("bar")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"string"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n\n"),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" serialize "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" ajv"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("compileSerializer")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("schema"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n\n"),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" data "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("foo")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("1")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("bar")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"abc"')]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n\nconsole"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("log")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("serialize")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("data"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n\n"),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" parse "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" ajv"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("compileParser")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("schema"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n\n"),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" json "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('\'{"foo": 1, "bar": "abc"}\'')]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" invalidJson "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('\'{"unknown": "abc"}\'')]),t._v("\n\n"),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("parseAndLog")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("json"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v('// logs {foo: 1, bar: "abc"}')]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("parseAndLog")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("invalidJson"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// logs error and position")]),t._v("\n\n"),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("function")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("parseAndLog")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token parameter"}},[t._v("json")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" data "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("parse")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("json"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("if")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("data "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("===")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("undefined")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n console"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("log")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("parse"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("message"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// error message from the last parse call")]),t._v("\n console"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("log")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("parse"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("position"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// error position in string")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("else")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n console"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("log")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("data"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])])])],1),t._v(" "),a("div",{staticClass:"custom-block tip"},[a("p",{staticClass:"custom-block-title"},[t._v("Lower parsing performance of empty schemas")]),t._v(" "),a("p",[t._v("You would have smaller performance benefits in case your schema contains some properties or other parts that are empty schemas ("),a("code",[t._v("{}")]),t._v(") - parser would call "),a("code",[t._v("JSON.parse")]),t._v(" in this case.")])]),t._v(" "),a("div",{staticClass:"custom-block warning"},[a("p",{staticClass:"custom-block-title"},[t._v("JTD discriminator schema")]),t._v(" "),a("p",[t._v("The performance of parsing discriminator schemas depends on the position of discriminator tag in the schema - the best parsing performance will be achieved if the tag is the first property - this is how compiled JTD serializers generate JSON in case of discriminator schemas.")]),t._v(" "),a("p",[t._v("Also, if discriminator tag were to be repeated in JSON, the second value would be ignored and the object still validated according to the first tag.")])]),t._v(" "),a("div",{staticClass:"custom-block warning"},[a("p",{staticClass:"custom-block-title"},[t._v("Compiled parsers do NOT throw exceptions")]),t._v(" "),a("p",[t._v("Compiled parsers, unlike JSON.parse, do not throw the exception in case JSON string is not a valid JSON or in case data is invalid according to the schema. As soon as the parser determines that either JSON or data is invalid, it returns "),a("code",[t._v("undefined")]),t._v(" and reports error and position via parsers properties "),a("code",[t._v("message")]),t._v(" and "),a("code",[t._v("position")]),t._v(".")])])],1)}),[],!1,null,null,null);a.default=e.exports}}]); \ No newline at end of file diff --git a/assets/js/58.9e2e8aac.js b/assets/js/58.9e2e8aac.js new file mode 100644 index 000000000..2099093ef --- /dev/null +++ b/assets/js/58.9e2e8aac.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[58],{404:function(e,t,a){"use strict";a.r(t);var s=a(14),n=Object(s.a)({},(function(){var e=this,t=e._self._c;return t("ContentSlotsDistributor",{attrs:{"slot-key":e.$parent.slotKey}},[t("h1",{attrs:{id:"choosing-schema-language"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#choosing-schema-language"}},[e._v("#")]),e._v(" Choosing schema language")]),e._v(" "),t("p"),t("div",{staticClass:"table-of-contents"},[t("ul",[t("li",[t("a",{attrs:{href:"#json-type-definition"}},[e._v("JSON Type Definition")])]),t("li",[t("a",{attrs:{href:"#json-schema"}},[e._v("JSON Schema")]),t("ul",[t("li",[t("a",{attrs:{href:"#draft-04"}},[e._v("draft-04")])]),t("li",[t("a",{attrs:{href:"#draft-07-and-draft-06"}},[e._v("draft-07 (and draft-06)")])]),t("li",[t("a",{attrs:{href:"#draft-2019-09-and-draft-2020-12"}},[e._v("draft 2019-09 (and draft-2020-12)")])])])]),t("li",[t("a",{attrs:{href:"#comparison"}},[e._v("Comparison")]),t("ul",[t("li",[t("a",{attrs:{href:"#json-schema"}},[e._v("JSON Schema")])]),t("li",[t("a",{attrs:{href:"#json-type-definition"}},[e._v("JSON Type Definition")])])])])])]),t("p"),e._v(" "),t("h2",{attrs:{id:"json-type-definition"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#json-type-definition"}},[e._v("#")]),e._v(" JSON Type Definition")]),e._v(" "),t("p",[e._v("Ajv supports the new specification focussed on defining cross-platform types of JSON messages/payloads - JSON Type Definition (JTD). See the informal reference of "),t("a",{attrs:{href:"../json-type-definition"}},[e._v("JTD schema forms")]),e._v(" and formal specification "),t("a",{attrs:{href:"https://datatracker.ietf.org/doc/rfc8927/",target:"_blank",rel:"noopener noreferrer"}},[e._v("RFC8927"),t("OutboundLink")],1),e._v(".")]),e._v(" "),t("h2",{attrs:{id:"json-schema"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#json-schema"}},[e._v("#")]),e._v(" JSON Schema")]),e._v(" "),t("p",[e._v("Ajv supports most widely used drafts of JSON Schema specification. Please see the informal reference of available "),t("a",{attrs:{href:"../json-schema"}},[e._v("JSON Schema validation keywords")]),e._v(" and "),t("a",{attrs:{href:"https://json-schema.org/specification.html",target:"_blank",rel:"noopener noreferrer"}},[e._v("specification drafts"),t("OutboundLink")],1),e._v(".")]),e._v(" "),t("h3",{attrs:{id:"draft-04"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#draft-04"}},[e._v("#")]),e._v(" draft-04")]),e._v(" "),t("p",[e._v("Draft-04 is not included in Ajv v7, because of some differences it has with the following drafts:")]),e._v(" "),t("ul",[t("li",[e._v("different schema member for schema identifier ("),t("code",[e._v("id")]),e._v(" in draft-04 instead of "),t("code",[e._v("$id")]),e._v(")")]),e._v(" "),t("li",[e._v("different syntax of exclusiveMaximum/Minimum")])]),e._v(" "),t("p",[e._v("You can still use draft-04 schemas with Ajv v6 - while this is no longer actively developed, any security related issues would still be supported at least until 30/06/2021.")]),e._v(" "),t("p",[e._v("To install v6:")]),e._v(" "),t("div",{staticClass:"language-bash extra-class"},[t("pre",{pre:!0,attrs:{class:"language-bash"}},[t("code",[t("span",{pre:!0,attrs:{class:"token function"}},[e._v("npm")]),e._v(" "),t("span",{pre:!0,attrs:{class:"token function"}},[e._v("install")]),e._v(" ajv@6\n")])])]),t("p",[e._v("You can migrate schemas from draft-04 to draft-07 using "),t("a",{attrs:{href:"https://github.com/ajv-validator/ajv-cli",target:"_blank",rel:"noopener noreferrer"}},[e._v("ajv-cli"),t("OutboundLink")],1),e._v(".")]),e._v(" "),t("h3",{attrs:{id:"draft-07-and-draft-06"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#draft-07-and-draft-06"}},[e._v("#")]),e._v(" draft-07 (and draft-06)")]),e._v(" "),t("p",[e._v("These are the most widely used versions of JSON Schema specification, and they are supported with the main ajv export.")]),e._v(" "),t("div",{staticClass:"language-javascript extra-class"},[t("pre",{pre:!0,attrs:{class:"language-javascript"}},[t("code",[t("span",{pre:!0,attrs:{class:"token keyword"}},[e._v("import")]),e._v(" Ajv "),t("span",{pre:!0,attrs:{class:"token keyword"}},[e._v("from")]),e._v(" "),t("span",{pre:!0,attrs:{class:"token string"}},[e._v('"ajv"')]),e._v("\n"),t("span",{pre:!0,attrs:{class:"token keyword"}},[e._v("const")]),e._v(" ajv "),t("span",{pre:!0,attrs:{class:"token operator"}},[e._v("=")]),e._v(" "),t("span",{pre:!0,attrs:{class:"token keyword"}},[e._v("new")]),e._v(" "),t("span",{pre:!0,attrs:{class:"token class-name"}},[e._v("Ajv")]),t("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("(")]),t("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(")")]),e._v("\n")])])]),t("p",[e._v("If you need to support draft-06 schemas you need to add additional meta-schema, but you may just change (or remove) "),t("code",[e._v("$schema")]),e._v(" attribute in your schemas - no other changes are needed:")]),e._v(" "),t("div",{staticClass:"language-javascript extra-class"},[t("pre",{pre:!0,attrs:{class:"language-javascript"}},[t("code",[t("span",{pre:!0,attrs:{class:"token keyword"}},[e._v("const")]),e._v(" draft6MetaSchema "),t("span",{pre:!0,attrs:{class:"token operator"}},[e._v("=")]),e._v(" "),t("span",{pre:!0,attrs:{class:"token function"}},[e._v("require")]),t("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("(")]),t("span",{pre:!0,attrs:{class:"token string"}},[e._v('"ajv/dist/refs/json-schema-draft-06.json"')]),t("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(")")]),e._v("\najv"),t("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(".")]),t("span",{pre:!0,attrs:{class:"token function"}},[e._v("addMetaSchema")]),t("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("(")]),e._v("draft6MetaSchema"),t("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(")")]),e._v("\n")])])]),t("h3",{attrs:{id:"draft-2019-09-and-draft-2020-12"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#draft-2019-09-and-draft-2020-12"}},[e._v("#")]),e._v(" draft 2019-09 (and draft-2020-12)")]),e._v(" "),t("p",[e._v("The main advantage of this JSON Schema version over draft-07 is the ability to spread the definition of records that do not allow additional properties across multiple schemas. If you do not need it, you might be better off with draft-07.")]),e._v(" "),t("p",[e._v("To use Ajv with the support of all JSON Schema draft-2019-09/2020-12 features you need to use a different export:")]),e._v(" "),t("div",{staticClass:"language-javascript extra-class"},[t("pre",{pre:!0,attrs:{class:"language-javascript"}},[t("code",[t("span",{pre:!0,attrs:{class:"token keyword"}},[e._v("import")]),e._v(" Ajv2019 "),t("span",{pre:!0,attrs:{class:"token keyword"}},[e._v("from")]),e._v(" "),t("span",{pre:!0,attrs:{class:"token string"}},[e._v('"ajv/dist/2019"')]),e._v("\n"),t("span",{pre:!0,attrs:{class:"token keyword"}},[e._v("const")]),e._v(" ajv "),t("span",{pre:!0,attrs:{class:"token operator"}},[e._v("=")]),e._v(" "),t("span",{pre:!0,attrs:{class:"token keyword"}},[e._v("new")]),e._v(" "),t("span",{pre:!0,attrs:{class:"token class-name"}},[e._v("Ajv2019")]),t("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("(")]),t("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(")")]),e._v("\n")])])]),t("p",[e._v("Optionally, you can add draft-07 meta-schema, to use both draft-07 and draft-2019-09 schemas in one Ajv instance:")]),e._v(" "),t("div",{staticClass:"language-javascript extra-class"},[t("pre",{pre:!0,attrs:{class:"language-javascript"}},[t("code",[t("span",{pre:!0,attrs:{class:"token keyword"}},[e._v("const")]),e._v(" draft7MetaSchema "),t("span",{pre:!0,attrs:{class:"token operator"}},[e._v("=")]),e._v(" "),t("span",{pre:!0,attrs:{class:"token function"}},[e._v("require")]),t("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("(")]),t("span",{pre:!0,attrs:{class:"token string"}},[e._v('"ajv/dist/refs/json-schema-draft-07.json"')]),t("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(")")]),e._v("\najv"),t("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(".")]),t("span",{pre:!0,attrs:{class:"token function"}},[e._v("addMetaSchema")]),t("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("(")]),e._v("draft7MetaSchema"),t("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(")")]),e._v("\n")])])]),t("p",[e._v("Draft-2019-09 support is provided via a separate export in order to avoid increasing the bundle and generated code size for draft-07 users.")]),e._v(" "),t("p",[e._v("With this import Ajv supports the following features:")]),e._v(" "),t("ul",[t("li",[e._v("keywords "),t("RouterLink",{attrs:{to:"/json-schema.html#unevaluatedproperties"}},[t("code",[e._v("unevaluatedProperties")])]),e._v(" and "),t("RouterLink",{attrs:{to:"/json-schema.html#unevaluateditems"}},[t("code",[e._v("unevaluatedItems")])])],1),e._v(" "),t("li",[e._v("keywords "),t("RouterLink",{attrs:{to:"/json-schema.html#dependentrequired"}},[t("code",[e._v("dependentRequired")])]),e._v(", "),t("RouterLink",{attrs:{to:"/json-schema.html#dependentschemas"}},[t("code",[e._v("dependentSchemas")])]),e._v(", "),t("RouterLink",{attrs:{to:"/json-schema.html#maxcontains--mincontains"}},[t("code",[e._v("maxContains")]),e._v("/"),t("code",[e._v("minContain")])])],1),e._v(" "),t("li",[e._v("dynamic recursive references with ["),t("code",[e._v("recursiveAnchor")]),e._v("/"),t("code",[e._v("recursiveReference")]),e._v("] - see "),t("RouterLink",{attrs:{to:"/guide/combining-schemas.html#extending-recursive-schemas"}},[e._v("Extending recursive schemas")])],1),e._v(" "),t("li",[e._v("draft-2019-09 meta-schema is the default.")])]),e._v(" "),t("div",{staticClass:"custom-block warning"},[t("p",{staticClass:"custom-block-title"},[e._v("Draft-2019-09 features performance cost (even when not used)")]),e._v(" "),t("p",[e._v("Supporting dynamic recursive references and "),t("code",[e._v("unevaluatedProperties")]),e._v("/"),t("code",[e._v("unevaluatedItems")]),e._v(' keywords adds additional generated code even to the validation functions where these features are not used (when possible, Ajv determines which properties/items are "unevaluated" at compilation time, but support for dynamic references always adds additional generated code). If you are not using these features in your schemas it is recommended to use default Ajv export with JSON-Schema draft-07 support.')])]),e._v(" "),t("h2",{attrs:{id:"comparison"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#comparison"}},[e._v("#")]),e._v(" Comparison")]),e._v(" "),t("p",[e._v("Both "),t("RouterLink",{attrs:{to:"/json-schema.html"}},[e._v("JSON Schema")]),e._v(" and "),t("RouterLink",{attrs:{to:"/json-type-definition.html"}},[e._v("JSON Type Definition")]),e._v(" are cross-platform specifications with implementations in multiple programming languages that define the shape of your JSON data.")],1),e._v(" "),t("p",[e._v("You can see the difference between the two specifications in "),t("a",{attrs:{href:"./getting-started"}},[e._v("Getting started")]),e._v(" section examples.")]),e._v(" "),t("p",[e._v("This section compares their pros/cons to help decide which specification fits your application better.")]),e._v(" "),t("h3",{attrs:{id:"json-schema-2"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#json-schema-2"}},[e._v("#")]),e._v(" JSON Schema")]),e._v(" "),t("p",[t("strong",[e._v("Pros")]),e._v(":")]),e._v(" "),t("ul",[t("li",[e._v("Wide specification adoption.")]),e._v(" "),t("li",[e._v("Used as part of OpenAPI specification.")]),e._v(" "),t("li",[e._v("Support of complex validation scenarios:\n"),t("ul",[t("li",[e._v("untagged unions and boolean logic")]),e._v(" "),t("li",[e._v("conditional schemas and dependencies")]),e._v(" "),t("li",[e._v("restrictions on the number ranges and the size of strings, arrays and objects")]),e._v(" "),t("li",[e._v("semantic validation with formats, patterns and content keywords")]),e._v(" "),t("li",[e._v("distribute strict record definitions across multiple schemas (with unevaluatedProperties)")])])]),e._v(" "),t("li",[e._v("Can be effectively used for validation of any JavaScript objects and configuration files.")])]),e._v(" "),t("p",[t("strong",[e._v("Cons")]),e._v(":")]),e._v(" "),t("ul",[t("li",[e._v("Defines the collection of restrictions on the data, rather than the shape of the data.")]),e._v(" "),t("li",[e._v("No standard support for tagged unions.")]),e._v(" "),t("li",[e._v("Complex and error prone for the new users (Ajv has "),t("a",{attrs:{href:"../strict-mode"}},[e._v("strict mode")]),e._v(" enabled by default to compensate for it, but it is not cross-platform).")]),e._v(" "),t("li",[e._v("Some parts of specification are difficult to implement, creating the risk of implementations divergence:\n"),t("ul",[t("li",[e._v("reference resolution model")]),e._v(" "),t("li",[e._v("unevaluatedProperties/unevaluatedItems")]),e._v(" "),t("li",[e._v("dynamic recursive references")])])]),e._v(" "),t("li",[e._v("Internet draft status (rather than RFC)")])]),e._v(" "),t("p",[e._v("See "),t("RouterLink",{attrs:{to:"/json-schema.html"}},[e._v("JSON Schema")]),e._v(" for more information and the list of defined keywords.")],1),e._v(" "),t("h3",{attrs:{id:"json-type-definition-2"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#json-type-definition-2"}},[e._v("#")]),e._v(" JSON Type Definition")]),e._v(" "),t("p",[t("strong",[e._v("Pros")]),e._v(":")]),e._v(" "),t("ul",[t("li",[e._v("Aligned with type systems of many languages - can be used to generate type definitions and efficient parsers and serializers to/from these types.")]),e._v(" "),t("li",[e._v("Very simple, enforcing the best practices for cross-platform JSON API modelling.")]),e._v(" "),t("li",[e._v("Simple to implement, ensuring consistency across implementations.")]),e._v(" "),t("li",[e._v("Defines the shape of JSON data via strictly defined schema forms (rather than the collection of restrictions).")]),e._v(" "),t("li",[e._v("Effective support for tagged unions.")]),e._v(" "),t("li",[e._v("Designed to protect against user mistakes.")]),e._v(" "),t("li",[e._v("Supports compilation of schemas to efficient "),t("RouterLink",{attrs:{to:"/guide/getting-started.html#parsing-and-serializing-json"}},[e._v("serializers and parsers")]),e._v(" (no need to validate as a separate step).")],1),e._v(" "),t("li",[e._v("Approved as "),t("a",{attrs:{href:"https://datatracker.ietf.org/doc/rfc8927/",target:"_blank",rel:"noopener noreferrer"}},[e._v("RFC8927"),t("OutboundLink")],1),e._v(".")]),e._v(" "),t("li",[e._v("Substantial industry adoption since it was standardized in 2020, Ajv v8.12.0 fixed all reported JTD bugs.")])]),e._v(" "),t("p",[t("strong",[e._v("Cons")]),e._v(":")]),e._v(" "),t("ul",[t("li",[e._v("Limited, compared with JSON Schema - no support for untagged unions"),t("sup",[e._v("1")]),e._v(", conditionals, references between different schema files"),t("sup",[e._v("2")]),e._v(", etc.")]),e._v(" "),t("li",[e._v("No meta-schema in the specification"),t("sup",[e._v("3")]),e._v(".")])]),e._v(" "),t("p",[t("sup",[e._v("1")]),e._v(' Ajv defines non-standard keyword "union" that can be used inside "metadata" object.')]),e._v(" "),t("p",[t("sup",[e._v("2")]),e._v(" You can still combine schemas from multiple files in the application code.")]),e._v(" "),t("p",[t("sup",[e._v("3")]),e._v(" Ajv defines meta-schema for JTD schemas.")]),e._v(" "),t("p",[e._v("See "),t("RouterLink",{attrs:{to:"/json-type-definition.html"}},[e._v("JSON Type Definition")]),e._v(" for more information and the list of defined schema forms.")],1)])}),[],!1,null,null,null);t.default=n.exports}}]); \ No newline at end of file diff --git a/assets/js/59.b83169de.js b/assets/js/59.b83169de.js new file mode 100644 index 000000000..a0e7cdb0d --- /dev/null +++ b/assets/js/59.b83169de.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[59],{405:function(t,s,a){"use strict";a.r(s);var n=a(14),e=Object(n.a)({},(function(){var t=this,s=t._self._c;return s("ContentSlotsDistributor",{attrs:{"slot-key":t.$parent.slotKey}},[s("h1",{attrs:{id:"using-with-typescript"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#using-with-typescript"}},[t._v("#")]),t._v(" Using with TypeScript")]),t._v(" "),s("p"),s("div",{staticClass:"table-of-contents"},[s("ul",[s("li",[s("a",{attrs:{href:"#additional-functionality"}},[t._v("Additional functionality")])]),s("li",[s("a",{attrs:{href:"#utility-types-for-schemas"}},[t._v("Utility types for schemas")])]),s("li",[s("a",{attrs:{href:"#utility-type-for-jtd-data-type"}},[t._v("Utility type for JTD data type")])]),s("li",[s("a",{attrs:{href:"#type-safe-error-handling"}},[t._v("Type-safe error handling")])]),s("li",[s("a",{attrs:{href:"#type-safe-parsers-and-serializers"}},[t._v("Type-safe parsers and serializers")])]),s("li",[s("a",{attrs:{href:"#type-safe-unions"}},[t._v("Type-safe unions")])])])]),s("p"),t._v(" "),s("h2",{attrs:{id:"additional-functionality"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#additional-functionality"}},[t._v("#")]),t._v(" Additional functionality")]),t._v(" "),s("p",[t._v("Ajv takes advantage of TypeScript type system to provide additional functionality that is not possible in JavaScript:")]),t._v(" "),s("ul",[s("li",[t._v("utility types "),s("code",[t._v("JSONSchemaType")]),t._v(" and "),s("code",[t._v("JTDSchemaType")]),t._v(" to convert data type into the schema type to simplify writing schemas, both for "),s("RouterLink",{attrs:{to:"/json-schema.html"}},[t._v("JSON Schema")]),t._v(" (but without union support) and for "),s("a",{attrs:{href:"../json-type-definition"}},[t._v("JSON Type Definition")]),t._v(" (with tagged unions support).")],1),t._v(" "),s("li",[t._v("utility type "),s("code",[t._v("JTDDataType")]),t._v(" to convert JSON Type Definition schema into the type of data that it defines.")]),t._v(" "),s("li",[t._v("compiled validation functions are type guards that narrow the type after successful validation.")]),t._v(" "),s("li",[t._v("validation errors for JSON Schema are defined as tagged unions, for type-safe error handling.")]),t._v(" "),s("li",[t._v("when utility type is used, compiled JTD serializers only accept data of correct type (as they do not validate that the data is valid) and compiled parsers return correct data type.")])]),t._v(" "),s("h2",{attrs:{id:"utility-types-for-schemas"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#utility-types-for-schemas"}},[t._v("#")]),t._v(" Utility types for schemas")]),t._v(" "),s("p",[t._v("For the same example as in "),s("a",{attrs:{href:"./getting-started"}},[t._v("Getting started")]),t._v(":")]),t._v(" "),s("ul",[s("li",[t._v("ensure strictNullChecks is true")])]),t._v(" "),s("code-group",[s("code-block",{attrs:{title:"JSON Schema"}},[s("div",{staticClass:"language-typescript extra-class"},[s("pre",{pre:!0,attrs:{class:"language-typescript"}},[s("code",[s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("import")]),t._v(" Ajv"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("JSONSchemaType"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("from")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"ajv"')]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" ajv "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("new")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("Ajv")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("interface")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("MyData")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n foo"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("number")]),t._v("\n bar"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("string")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" schema"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" JSONSchemaType"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<")]),t._v("MyData"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(">")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n type"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"object"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n properties"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n foo"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("type"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"integer"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n bar"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("type"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"string"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" nullable"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token boolean"}},[t._v("true")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n required"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"foo"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n additionalProperties"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token boolean"}},[t._v("false")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n\n"),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// validate is a type guard for MyData - type is inferred from schema type")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" validate "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" ajv"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("compile")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("schema"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n\n"),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// or, if you did not use type annotation for the schema,")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// type parameter can be used to make it type guard:")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// const validate = ajv.compile(schema)")]),t._v("\n\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" data "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n foo"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("1")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n bar"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"abc"')]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("if")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("validate")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("data"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// data is MyData here")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("console")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("log")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("data"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("foo"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("else")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("console")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("log")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("validate"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("errors"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])])]),t._v(" "),s("code-block",{attrs:{title:"JSON Type Definition"}},[s("div",{staticClass:"language-typescript extra-class"},[s("pre",{pre:!0,attrs:{class:"language-typescript"}},[s("code",[s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("import")]),t._v(" Ajv"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("JTDSchemaType"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("from")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"ajv/dist/jtd"')]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" ajv "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("new")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("Ajv")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("interface")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("MyData")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n foo"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("number")]),t._v("\n bar"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("string")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" schema"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" JTDSchemaType"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<")]),t._v("MyData"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(">")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n properties"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n foo"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("type"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"int32"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n optionalProperties"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n bar"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("type"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"string"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n\n\n"),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// validate is a type guard for MyData - type is inferred from schema type")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" validate "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" ajv"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("compile")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("schema"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n\n"),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// or, if you did not use type annotation for the schema,")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// type parameter can be used to make it type guard:")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// const validate = ajv.compile(schema)")]),t._v("\n\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" data "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n foo"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("1")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n bar"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"abc"')]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("if")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("validate")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("data"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// data is MyData here")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("console")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("log")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("data"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("foo"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("else")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("console")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("log")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("validate"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("errors"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])])])],1),t._v(" "),s("p",[t._v("See "),s("a",{attrs:{href:"https://github.com/ajv-validator/ajv/tree/master/spec/types/json-schema.spec.ts",target:"_blank",rel:"noopener noreferrer"}},[t._v("this test"),s("OutboundLink")],1),t._v(" for an advanced example.")]),t._v(" "),s("h2",{attrs:{id:"utility-type-for-jtd-data-type"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#utility-type-for-jtd-data-type"}},[t._v("#")]),t._v(" Utility type for JTD data type")]),t._v(" "),s("p",[t._v("You can use JTD schema to construct the type of data using utility type "),s("code",[t._v("JTDDataType")])]),t._v(" "),s("code-group",[s("code-block",{attrs:{title:"JSON Type Definition"}},[s("div",{staticClass:"language-typescript extra-class"},[s("pre",{pre:!0,attrs:{class:"language-typescript"}},[s("code",[s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("import")]),t._v(" Ajv"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("JTDDataType"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("from")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"ajv/dist/jtd"')]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" ajv "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("new")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("Ajv")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" schema "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n properties"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n foo"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("type"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"int32"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n optionalProperties"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n bar"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("type"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"string"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("as")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v("\n\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("type")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("MyData")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" JTDDataType"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<")]),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("typeof")]),t._v(" schema"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(">")]),t._v("\n\n"),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// type inference is not supported for JTDDataType yet")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" validate "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" ajv"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),s("span",{pre:!0,attrs:{class:"token generic-function"}},[s("span",{pre:!0,attrs:{class:"token function"}},[t._v("compile")]),s("span",{pre:!0,attrs:{class:"token generic class-name"}},[s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<")]),t._v("MyData"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(">")])])]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("schema"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" validData "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n foo"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("1")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n bar"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"abc"')]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("if")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("validate")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("validData"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// data is MyData here")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("console")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("log")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("validData"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("foo"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("else")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("console")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("log")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("validate"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("errors"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])])])],1),t._v(" "),s("div",{staticClass:"custom-block warning"},[s("p",{staticClass:"custom-block-title"},[t._v("TypeScript limitation")]),t._v(" "),s("p",[t._v("Note that it's currently not possible for "),s("code",[t._v("JTDDataType")]),t._v(" to know whether the compiler is inferring timestamps as strings or Dates, and so it conservatively types any timestamp as "),s("code",[t._v("string | Date")]),t._v(". This is accurate, but often requires extra validation on the part of the user to confirm they're getting the appropriate data type.")])]),t._v(" "),s("h2",{attrs:{id:"type-safe-error-handling"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#type-safe-error-handling"}},[t._v("#")]),t._v(" Type-safe error handling")]),t._v(" "),s("p",[t._v("With both "),s("RouterLink",{attrs:{to:"/json-schema.html"}},[t._v("JSON Schema")]),t._v(" and "),s("RouterLink",{attrs:{to:"/json-type-definition.html"}},[t._v("JSON Type Definition")]),t._v(", the validation error type is an open union, but it can be cast to tagged unions (using validation keyword as tag) for easier error handling.")],1),t._v(" "),s("p",[t._v("Continuing the example above:")]),t._v(" "),s("code-group",[s("code-block",{attrs:{title:"JSON Schema"}},[s("div",{staticClass:"language-typescript extra-class"},[s("pre",{pre:!0,attrs:{class:"language-typescript"}},[s("code",[s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("import")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("DefinedError"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("from")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"ajv"')]),t._v("\n\n"),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// ...")]),t._v("\n\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("if")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("validate")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("data"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// data is MyData here")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("console")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("log")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("data"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("foo"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("else")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// The type cast is needed, as Ajv uses a wider type to allow extension")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// You can extend this type to include your error types as needed.")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("for")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" err "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("of")]),t._v(" validate"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("errors "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("as")]),t._v(" DefinedError"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("switch")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("err"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("keyword"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("case")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"type"')]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v('// err type is narrowed here to have "type" error params properties')]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("console")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("log")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("err"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("params"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("type"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("break")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// ...")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])])]),t._v(" "),s("code-block",{attrs:{title:"JSON Type Definition"}},[s("div",{staticClass:"language-typescript extra-class"},[s("pre",{pre:!0,attrs:{class:"language-typescript"}},[s("code",[s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("import")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("JTDErrorObject"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("from")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"ajv/dist/jtd"')]),t._v("\n\n"),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// ...")]),t._v("\n\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("if")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("validate")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("data"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// data is MyData here")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("console")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("log")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("data"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("foo"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("else")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// The type cast is needed, as Ajv uses a wider type to allow extension")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// You can extend this type to include your error types as needed.")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("for")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" err "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("of")]),t._v(" validate"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("errors "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("as")]),t._v(" JTDErrorObject"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("switch")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("err"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("keyword"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("case")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"type"')]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v('// err type is narrowed here to have "type" error params properties')]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("console")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("log")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("err"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("params"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("type"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("break")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// ...")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])])])],1),t._v(" "),s("h2",{attrs:{id:"type-safe-parsers-and-serializers"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#type-safe-parsers-and-serializers"}},[t._v("#")]),t._v(" Type-safe parsers and serializers")]),t._v(" "),s("p",[t._v("With typescript, your compiled parsers and serializers can be type-safe, either taking their type from schema type or from type parameter passed to compilation functions.")]),t._v(" "),s("p",[t._v("This example uses the same data and schema types as above:")]),t._v(" "),s("code-group",[s("code-block",{attrs:{title:"JSON Type Definition"}},[s("div",{staticClass:"language-typescript extra-class"},[s("pre",{pre:!0,attrs:{class:"language-typescript"}},[s("code",[s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("import")]),t._v(" Ajv"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("JTDSchemaType"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("from")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"ajv/dist/jtd"')]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" ajv "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("new")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("Ajv")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("interface")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("MyData")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n foo"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("number")]),t._v("\n bar"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("string")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" schema"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" JTDSchemaType"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<")]),t._v("MyData"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(">")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n properties"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n foo"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("type"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"int32"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n optionalProperties"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n bar"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("type"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"string"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n\n"),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// serialize will only accept data compatible with MyData")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" serialize "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" ajv"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("compileSerializer")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("schema"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n\n"),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// parse will return MyData or undefined")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" parse "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" ajv"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("compileParser")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("schema"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n\n"),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// types of parse and serialize are inferred from schema,")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// they can also be defined explicitly:")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// const parse = ajv.compileParser(schema)")]),t._v("\n\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" data "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n foo"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("1")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n bar"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"abc"')]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" invalidData "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("unknown")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"abc"')]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n\n"),s("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("console")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("log")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("serialize")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("data"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("console")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("log")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("serialize")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("invalidData"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// type error")]),t._v("\n\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" json "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('\'{"foo": 1, "bar": "abc"}\'')]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" invalidJson "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('\'{"unknown": "abc"}\'')]),t._v("\n\n"),s("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("console")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("log")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("parseAndLogFoo")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("json"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// logs property")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("console")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("log")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("parseAndLogFoo")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("invalidJson"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// logs error and position")]),t._v("\n\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("function")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("parseAndLogFoo")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("json"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("string")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("void")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" data "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("parse")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("json"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// MyData | undefined")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("if")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("data "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("===")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("undefined")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("console")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("log")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("parse"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("message"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// error message from the last parse call")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("console")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("log")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("parse"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("position"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// error position in string")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("else")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// data is MyData here")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("console")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("log")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("data"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("foo"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])])])],1),t._v(" "),s("h2",{attrs:{id:"type-safe-unions"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#type-safe-unions"}},[t._v("#")]),t._v(" Type-safe unions")]),t._v(" "),s("p",[t._v("JSON Type Definition only supports tagged unions, so unions in JTD are fully supported for "),s("code",[t._v("JTDSchemaType")]),t._v(" and "),s("code",[t._v("JTDDataType")]),t._v(".\nJSON Schema is more complex and so "),s("code",[t._v("JSONSchemaType")]),t._v(" has limited support for type safe unions.")]),t._v(" "),s("p",[s("code",[t._v("JSONSchemaType")]),t._v(" will type check unions where each union element is fully specified as an element of an "),s("code",[t._v("anyOf")]),t._v(" array or "),s("code",[t._v("oneOf")]),t._v(" array.\nAdditionally, unions of primitives will type check appropriately if they're combined into an array "),s("code",[t._v("type")]),t._v(", e.g. "),s("code",[t._v('{type: ["string", "number"]}')]),t._v(".")]),t._v(" "),s("div",{staticClass:"custom-block warning"},[s("p",{staticClass:"custom-block-title"},[t._v("TypeScript limitation")]),t._v(" "),s("p",[t._v("Note that due to current limitation of TypeScript, JSONSchemaType cannot verify that every element of the union is present, and the following example is still valid "),s("code",[t._v('const schema: JSONSchemaType = {type: "string"}')]),t._v(".")])]),t._v(" "),s("p",[t._v("Here's a more detailed example showing several union types:")]),t._v(" "),s("code-group",[s("code-block",{attrs:{title:"JSON Schema"}},[s("div",{staticClass:"language-typescript extra-class"},[s("pre",{pre:!0,attrs:{class:"language-typescript"}},[s("code",[s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("import")]),t._v(" Ajv"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("JSONSchemaType"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("from")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"ajv"')]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" ajv "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("new")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("Ajv")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("type")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("MyUnion")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("prop"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("boolean")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("|")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("string")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("|")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("number")]),t._v("\n\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" schema"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" JSONSchemaType"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<")]),t._v("MyUnion"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(">")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n anyOf"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n type"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"object"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n properties"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v(" prop"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v(" type"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"boolean"')]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n required"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"prop"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n type"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"string"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"number"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])])])],1)],1)}),[],!1,null,null,null);s.default=e.exports}}]); \ No newline at end of file diff --git a/assets/js/61.3b14a798.js b/assets/js/61.3b14a798.js new file mode 100644 index 000000000..d1372e8b8 --- /dev/null +++ b/assets/js/61.3b14a798.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[61],{407:function(e,t,a){"use strict";a.r(t);var r=a(14),s=Object(r.a)({},(function(){var e=this,t=e._self._c;return t("ContentSlotsDistributor",{attrs:{"slot-key":e.$parent.slotKey}},[t("h1",{attrs:{id:"why-use-ajv"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#why-use-ajv"}},[e._v("#")]),e._v(" Why use AJV")]),e._v(" "),t("h2",{attrs:{id:"write-less-code"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#write-less-code"}},[e._v("#")]),e._v(" Write less code")]),e._v(" "),t("p",[t("strong",[e._v("Ensure your data is valid as soon as it's received")])]),e._v(" "),t("p",[e._v("Instead of having your data validation and sanitization logic written as lengthy code, you can declare the requirements to your data with concise, easy to read and cross-platform "),t("a",{attrs:{href:"https://json-schema.org",target:"_blank",rel:"noopener noreferrer"}},[e._v("JSON Schema"),t("OutboundLink")],1),e._v(" or "),t("a",{attrs:{href:"https://jsontypedef.com",target:"_blank",rel:"noopener noreferrer"}},[e._v("JSON Type Definition"),t("OutboundLink")],1),e._v(" specifications and validate the data as soon as it arrives to your application.")]),e._v(" "),t("p",[e._v("TypeScript users can use validation functions as type guards, having type level guarantee that if your data is validated - it is correct.")]),e._v(" "),t("p",[e._v("Read more in "),t("RouterLink",{attrs:{to:"/guide/getting-started.html"}},[e._v("Getting started")]),e._v(" and "),t("RouterLink",{attrs:{to:"/guide/typescript.html"}},[e._v("Using with TypeScript")])],1),e._v(" "),t("h2",{attrs:{id:"super-fast-secure"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#super-fast-secure"}},[e._v("#")]),e._v(" Super fast & secure")]),e._v(" "),t("p",[t("strong",[e._v("Compiles your schemas to optimized JavaScript code")])]),e._v(" "),t("p",[e._v("Ajv generates code to turn JSON Schemas into super-fast validation functions that are efficient for v8 optimization.")]),e._v(" "),t("p",[e._v("Currently Ajv is the fastest and the most standard compliant validator according to these benchmarks:")]),e._v(" "),t("ul",[t("li",[t("a",{attrs:{href:"https://github.com/ebdrup/json-schema-benchmark",target:"_blank",rel:"noopener noreferrer"}},[e._v("json-schema-benchmark"),t("OutboundLink")],1),e._v(" - 50% faster than the second place")]),e._v(" "),t("li",[t("a",{attrs:{href:"https://github.com/pandastrike/jsck#benchmarks",target:"_blank",rel:"noopener noreferrer"}},[e._v("jsck benchmark"),t("OutboundLink")],1),e._v(" - 20-190% faster")]),e._v(" "),t("li",[t("a",{attrs:{href:"https://rawgit.com/zaggino/z-schema/master/benchmark/results.html",target:"_blank",rel:"noopener noreferrer"}},[e._v("z-schema benchmark"),t("OutboundLink")],1)]),e._v(" "),t("li",[t("a",{attrs:{href:"https://cdn.rawgit.com/playlyfe/themis/master/benchmark/results.html",target:"_blank",rel:"noopener noreferrer"}},[e._v("themis benchmark"),t("OutboundLink")],1)])]),e._v(" "),t("p",[e._v("Ajv was designed at the time when there were no validators fully complying with JSON Schema specification, aiming to achieve the best possibly validation performance via just-in-time compilation of JSON schemas to code. Ajv achieved both speed and rigour, but initially security was an afterthought - many security flaws have been fixed thanks to the reports from its users.")]),e._v(" "),t("p",[e._v("Ajv version 7 was rebuilt to have secure code generation embedded in its design as the primary objective - even if you use untrusted schemas (which is still not recommended) there are type-level guarantees against remote code execution.")]),e._v(" "),t("p",[e._v("Read more in "),t("RouterLink",{attrs:{to:"/codegen.html"}},[e._v("Code generation design")])],1),e._v(" "),t("h2",{attrs:{id:"multi-standard"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#multi-standard"}},[e._v("#")]),e._v(" Multi-standard")]),e._v(" "),t("p",[t("strong",[e._v("Use JSON Type Definition or JSON Schema")])]),e._v(" "),t("p",[e._v("In addition to the multiple "),t("RouterLink",{attrs:{to:"/json-schema.html"}},[e._v("JSON Schema")]),e._v(" drafts, including the latest draft 2020-12, Ajv has support for "),t("RouterLink",{attrs:{to:"/json-type-definition.html"}},[e._v("JSON Type Definition")]),e._v(" - a new "),t("a",{attrs:{href:"https://datatracker.ietf.org/doc/rfc8927/",target:"_blank",rel:"noopener noreferrer"}},[e._v("RFC8927"),t("OutboundLink")],1),e._v(" that offers a much simpler alternative to JSON Schema. Designed to be well-aligned with type systems, JTD has tools for both validation and type code generation for multiple languages.")],1),e._v(" "),t("p",[e._v("Read more in "),t("RouterLink",{attrs:{to:"/guide/schema-language.html"}},[e._v("Choosing schema language")])],1)])}),[],!1,null,null,null);t.default=s.exports}}]); \ No newline at end of file diff --git a/assets/js/62.648b3e09.js b/assets/js/62.648b3e09.js new file mode 100644 index 000000000..2d776c0f3 --- /dev/null +++ b/assets/js/62.648b3e09.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[62],{408:function(t,a,e){"use strict";e.r(a);var s=e(14),r=Object(s.a)({},(function(){var t=this,a=t._self._c;return a("ContentSlotsDistributor",{attrs:{"slot-key":t.$parent.slotKey}},[a("h1",{attrs:{id:"json-schema"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#json-schema"}},[t._v("#")]),t._v(" JSON Schema")]),t._v(" "),a("p",[t._v("In a simple way, JSON Schema is an object with validation keywords.")]),t._v(" "),a("p",[t._v("The keywords and their values define what rules the data should satisfy to be valid.")]),t._v(" "),a("p"),a("div",{staticClass:"table-of-contents"},[a("ul",[a("li",[a("a",{attrs:{href:"#json-schema-versions"}},[t._v("JSON Schema versions")]),a("ul",[a("li",[a("a",{attrs:{href:"#draft-07"}},[t._v("draft-07 "),a("Badge",{attrs:{text:"default"}})],1)]),a("li",[a("a",{attrs:{href:"#draft-2019-09"}},[t._v("draft-2019-09 "),a("Badge",{attrs:{text:"NEW"}})],1)]),a("li",[a("a",{attrs:{href:"#draft-2020-12"}},[t._v("draft-2020-12 "),a("Badge",{attrs:{text:"BREAKING",type:"warning"}})],1)]),a("li",[a("a",{attrs:{href:"#draft-06"}},[t._v("draft-06")])]),a("li",[a("a",{attrs:{href:"#draft-04"}},[t._v("draft-04")])])])]),a("li",[a("a",{attrs:{href:"#openapi-support"}},[t._v("OpenAPI support")])]),a("li",[a("a",{attrs:{href:"#json-data-type"}},[t._v("JSON data type")]),a("ul",[a("li",[a("a",{attrs:{href:"#type"}},[t._v("type")])]),a("li",[a("a",{attrs:{href:"#nullable"}},[t._v("nullable "),a("Badge",{attrs:{text:"OpenAPI"}})],1)])])]),a("li",[a("a",{attrs:{href:"#keywords-for-numbers"}},[t._v("Keywords for numbers")]),a("ul",[a("li",[a("a",{attrs:{href:"#maximum-minimum-and-exclusivemaximum-exclusiveminimum"}},[t._v("maximum / minimum and exclusiveMaximum / exclusiveMinimum")])]),a("li",[a("a",{attrs:{href:"#multipleof"}},[t._v("multipleOf")])])])]),a("li",[a("a",{attrs:{href:"#keywords-for-strings"}},[t._v("Keywords for strings")]),a("ul",[a("li",[a("a",{attrs:{href:"#maxlength-minlength"}},[t._v("maxLength / minLength")])]),a("li",[a("a",{attrs:{href:"#pattern"}},[t._v("pattern")])]),a("li",[a("a",{attrs:{href:"#format"}},[t._v("format")])])])]),a("li",[a("a",{attrs:{href:"#keywords-for-arrays"}},[t._v("Keywords for arrays")]),a("ul",[a("li",[a("a",{attrs:{href:"#maxitems-minitems"}},[t._v("maxItems / minItems")])]),a("li",[a("a",{attrs:{href:"#uniqueitems"}},[t._v("uniqueItems")])]),a("li",[a("a",{attrs:{href:"#items"}},[t._v("items")]),a("ul",[a("li",[a("a",{attrs:{href:"#items-in-draft-04-06-07-and-2019-09"}},[t._v("items in draft-04, -06, -07 and -2019-09")])]),a("li",[a("a",{attrs:{href:"#items-in-draft-2020-12"}},[t._v("items in draft-2020-12 "),a("Badge",{attrs:{text:"NEW"}})],1)])])]),a("li",[a("a",{attrs:{href:"#prefixitems"}},[t._v("prefixItems "),a("Badge",{attrs:{text:"NEW: draft 2020-12"}})],1)]),a("li",[a("a",{attrs:{href:"#additionalitems"}},[t._v("additionalItems")])]),a("li",[a("a",{attrs:{href:"#contains"}},[t._v("contains")])]),a("li",[a("a",{attrs:{href:"#maxcontains-mincontains"}},[t._v("maxContains / minContains "),a("Badge",{attrs:{text:"NEW: draft 2019-09"}})],1)]),a("li",[a("a",{attrs:{href:"#unevaluateditems"}},[t._v("unevaluatedItems "),a("Badge",{attrs:{text:"NEW: draft 2019-09"}})],1)])])]),a("li",[a("a",{attrs:{href:"#keywords-for-objects"}},[t._v("Keywords for objects")]),a("ul",[a("li",[a("a",{attrs:{href:"#maxproperties-minproperties"}},[t._v("maxProperties / minProperties")])]),a("li",[a("a",{attrs:{href:"#required"}},[t._v("required")])]),a("li",[a("a",{attrs:{href:"#properties"}},[t._v("properties")])]),a("li",[a("a",{attrs:{href:"#patternproperties"}},[t._v("patternProperties")])]),a("li",[a("a",{attrs:{href:"#additionalproperties"}},[t._v("additionalProperties")])]),a("li",[a("a",{attrs:{href:"#dependencies"}},[t._v("dependencies "),a("Badge",{attrs:{text:"deprecated in draft 2019-09",type:"warning"}})],1)]),a("li",[a("a",{attrs:{href:"#dependentrequired"}},[t._v("dependentRequired "),a("Badge",{attrs:{text:"NEW: draft 2019-09"}})],1)]),a("li",[a("a",{attrs:{href:"#dependentschemas"}},[t._v("dependentSchemas "),a("Badge",{attrs:{text:"NEW: draft 2019-09"}})],1)]),a("li",[a("a",{attrs:{href:"#propertynames"}},[t._v("propertyNames")])]),a("li",[a("a",{attrs:{href:"#unevaluatedproperties"}},[t._v("unevaluatedProperties "),a("Badge",{attrs:{text:"NEW: draft 2019-09"}})],1)]),a("li",[a("a",{attrs:{href:"#discriminator"}},[t._v("discriminator "),a("Badge",{attrs:{text:"NEW: OpenAPI"}})],1)])])]),a("li",[a("a",{attrs:{href:"#keywords-for-all-types"}},[t._v("Keywords for all types")]),a("ul",[a("li",[a("a",{attrs:{href:"#enum"}},[t._v("enum")])]),a("li",[a("a",{attrs:{href:"#const"}},[t._v("const")])])])]),a("li",[a("a",{attrs:{href:"#compound-keywords"}},[t._v("Compound keywords")]),a("ul",[a("li",[a("a",{attrs:{href:"#not"}},[t._v("not")])]),a("li",[a("a",{attrs:{href:"#oneof"}},[t._v("oneOf")])]),a("li",[a("a",{attrs:{href:"#anyof"}},[t._v("anyOf")])]),a("li",[a("a",{attrs:{href:"#allof"}},[t._v("allOf")])]),a("li",[a("a",{attrs:{href:"#if-then-else"}},[t._v("if/then/else")])])])]),a("li",[a("a",{attrs:{href:"#metadata-keywords"}},[t._v("Metadata keywords")])])])]),a("p"),t._v(" "),a("h2",{attrs:{id:"json-schema-versions"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#json-schema-versions"}},[t._v("#")]),t._v(" JSON Schema versions")]),t._v(" "),a("h3",{attrs:{id:"draft-07"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#draft-07"}},[t._v("#")]),t._v(" draft-07 "),a("Badge",{attrs:{text:"default"}})],1),t._v(" "),a("p",[t._v("This version is provided as default export:")]),t._v(" "),a("code-group",[a("code-block",{attrs:{title:"JavaScript"}},[a("div",{staticClass:"language-javascript extra-class"},[a("pre",{pre:!0,attrs:{class:"language-javascript"}},[a("code",[a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" Ajv "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("require")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"ajv"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" ajv "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("new")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("Ajv")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n")])])])]),t._v(" "),a("code-block",{attrs:{title:"TypeScript"}},[a("div",{staticClass:"language-typescript extra-class"},[a("pre",{pre:!0,attrs:{class:"language-typescript"}},[a("code",[a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("import")]),t._v(" Ajv "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("from")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"ajv"')]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" ajv "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("new")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("Ajv")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n")])])])])],1),t._v(" "),a("div",{staticClass:"custom-block tip"},[a("p",{staticClass:"custom-block-title"},[t._v("draft-07 has better performance")]),t._v(" "),a("p",[t._v("Unless you need the new features of later versions, you would have more efficient generated code with this draft.")])]),t._v(" "),a("h3",{attrs:{id:"draft-2019-09"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#draft-2019-09"}},[t._v("#")]),t._v(" draft-2019-09 "),a("Badge",{attrs:{text:"NEW"}})],1),t._v(" "),a("p",[t._v("Ajv supports all new keywords of JSON Schema draft-2019-09:")]),t._v(" "),a("ul",[a("li",[a("a",{attrs:{href:"#unevaluatedproperties"}},[t._v("unevaluatedProperties")])]),t._v(" "),a("li",[a("a",{attrs:{href:"#unevaluateditems"}},[t._v("unevaluatedItems")])]),t._v(" "),a("li",[a("a",{attrs:{href:"#dependentrequired"}},[t._v("dependentRequired")])]),t._v(" "),a("li",[a("a",{attrs:{href:"#dependentschemas"}},[t._v("dependentSchemas")])]),t._v(" "),a("li",[a("a",{attrs:{href:"#maxcontains--mincontains"}},[t._v("maxContains/minContains")])]),t._v(" "),a("li",[a("RouterLink",{attrs:{to:"/guide/combining-schemas.html#extending-recursive-schemas"}},[t._v("$recursiveAnchor/$recursiveRef")])],1)]),t._v(" "),a("p",[t._v("To use draft-2019-09 schemas you need to import a different Ajv class:")]),t._v(" "),a("code-group",[a("code-block",{attrs:{title:"JavaScript"}},[a("div",{staticClass:"language-javascript extra-class"},[a("pre",{pre:!0,attrs:{class:"language-javascript"}},[a("code",[a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" Ajv2019 "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("require")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"ajv/dist/2019"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" ajv "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("new")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("Ajv2019")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n")])])])]),t._v(" "),a("code-block",{attrs:{title:"TypeScript"}},[a("div",{staticClass:"language-typescript extra-class"},[a("pre",{pre:!0,attrs:{class:"language-typescript"}},[a("code",[a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("import")]),t._v(" Ajv2019 "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("from")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"ajv/dist/2019"')]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" ajv "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("new")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("Ajv2019")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n")])])])])],1),t._v(" "),a("p",[t._v("You can use draft-07 schemas with this Ajv instance as well, draft-2019-09 is backwards compatible. If your schemas use "),a("code",[t._v("$schema")]),t._v(" keyword, you need to add draft-07 meta-schema to Ajv instance:")]),t._v(" "),a("code-group",[a("code-block",{attrs:{title:"JavaScript"}},[a("div",{staticClass:"language-javascript extra-class"},[a("pre",{pre:!0,attrs:{class:"language-javascript"}},[a("code",[a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" draft7MetaSchema "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("require")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"ajv/dist/refs/json-schema-draft-07.json"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\najv"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("addMetaSchema")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("draft7MetaSchema"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n")])])])]),t._v(" "),a("code-block",{attrs:{title:"TypeScript"}},[a("div",{staticClass:"language-typescript extra-class"},[a("pre",{pre:!0,attrs:{class:"language-typescript"}},[a("code",[a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("import")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("*")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("as")]),t._v(" draft7MetaSchema "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("from")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"ajv/dist/refs/json-schema-draft-07.json"')]),t._v("\najv"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("addMetaSchema")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("draft7MetaSchema"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n")])])])])],1),t._v(" "),a("h3",{attrs:{id:"draft-2020-12"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#draft-2020-12"}},[t._v("#")]),t._v(" draft-2020-12 "),a("Badge",{attrs:{text:"BREAKING",type:"warning"}})],1),t._v(" "),a("div",{staticClass:"custom-block warning"},[a("p",{staticClass:"custom-block-title"},[t._v("draft-2020-12 is not backwards compatible")]),t._v(" "),a("p",[t._v("You cannot use draft-2020-12 and previous JSON Schema versions in the same Ajv instance.")])]),t._v(" "),a("p",[t._v("Ajv supports all keywords of JSON Schema draft-2020-12:")]),t._v(" "),a("ul",[a("li",[a("a",{attrs:{href:"#prefixItems"}},[t._v("prefixItems")]),t._v(" that replaced array form of items keyword")]),t._v(" "),a("li",[t._v("changed "),a("a",{attrs:{href:"#items-in-draft-2020-12"}},[t._v("items")]),t._v(" keyword that combined parts of functionality of items and additionalItems")]),t._v(" "),a("li",[a("RouterLink",{attrs:{to:"/guide/combining-schemas.html#extending-recursive-schemas"}},[t._v("$dynamicAnchor/$dynamicRef")])],1)]),t._v(" "),a("p",[t._v("To use draft-2020-12 schemas you need to import a different Ajv class:")]),t._v(" "),a("code-group",[a("code-block",{attrs:{title:"JavaScript"}},[a("div",{staticClass:"language-javascript extra-class"},[a("pre",{pre:!0,attrs:{class:"language-javascript"}},[a("code",[a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" Ajv2020 "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("require")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"ajv/dist/2020"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" ajv "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("new")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("Ajv2020")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n")])])])]),t._v(" "),a("code-block",{attrs:{title:"TypeScript"}},[a("div",{staticClass:"language-typescript extra-class"},[a("pre",{pre:!0,attrs:{class:"language-typescript"}},[a("code",[a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("import")]),t._v(" Ajv2020 "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("from")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"ajv/dist/2020"')]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" ajv "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("new")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("Ajv2020")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n")])])])])],1),t._v(" "),a("h3",{attrs:{id:"draft-06"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#draft-06"}},[t._v("#")]),t._v(" draft-06")]),t._v(" "),a("p",[t._v("You can use JSON Schema draft-06 schemas with Ajv v7/8. If your schemas use "),a("code",[t._v("$schema")]),t._v(" keyword, you need to add draft-06 meta-schema to Ajv instance. This example shows how to support both draft-06 and draft-07 schemas:")]),t._v(" "),a("code-group",[a("code-block",{attrs:{title:"JavaScript"}},[a("div",{staticClass:"language-javascript extra-class"},[a("pre",{pre:!0,attrs:{class:"language-javascript"}},[a("code",[a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" Ajv "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("require")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"ajv"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" draft6MetaSchema "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("require")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"ajv/dist/refs/json-schema-draft-06.json"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n\n"),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" ajv "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("new")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("Ajv")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\najv"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("addMetaSchema")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("draft6MetaSchema"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n")])])])]),t._v(" "),a("code-block",{attrs:{title:"TypeScript"}},[a("div",{staticClass:"language-typescript extra-class"},[a("pre",{pre:!0,attrs:{class:"language-typescript"}},[a("code",[a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("import")]),t._v(" Ajv "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("from")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"ajv"')]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("import")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("*")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("as")]),t._v(" draft6MetaSchema "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("from")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"ajv/dist/refs/json-schema-draft-06.json"')]),t._v("\n\n"),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" ajv "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("new")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("Ajv")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\najv"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("addMetaSchema")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("draft6MetaSchema"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n")])])])])],1),t._v(" "),a("h3",{attrs:{id:"draft-04"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#draft-04"}},[t._v("#")]),t._v(" draft-04")]),t._v(" "),a("p",[t._v("You can use JSON Schema draft-04 schemas with Ajv from v8.5.0 and the additional package "),a("a",{attrs:{href:"https://github.com/ajv-validator/ajv-draft-04",target:"_blank",rel:"noopener noreferrer"}},[t._v("ajv-draft-04"),a("OutboundLink")],1),t._v(" (both ajv and ajv-draft-04 should be installed).")]),t._v(" "),a("code-group",[a("code-block",{attrs:{title:"JavaScript"}},[a("div",{staticClass:"language-javascript extra-class"},[a("pre",{pre:!0,attrs:{class:"language-javascript"}},[a("code",[a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" Ajv "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("require")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"ajv-draft-04"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" ajv "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("new")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("Ajv")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n")])])])]),t._v(" "),a("code-block",{attrs:{title:"TypeScript"}},[a("div",{staticClass:"language-typescript extra-class"},[a("pre",{pre:!0,attrs:{class:"language-typescript"}},[a("code",[a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("import")]),t._v(" Ajv "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("from")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"ajv-draft-04"')]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" ajv "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("new")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("Ajv")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n")])])])])],1),t._v(" "),a("div",{staticClass:"custom-block warning"},[a("p",{staticClass:"custom-block-title"},[t._v("Ajv cannot combine multiple JSON Schema versions")]),t._v(" "),a("p",[t._v("You can only use this import with JSON Schema draft-04, you cannot combine multiple JSON Schema versions in this ajv instance.")])]),t._v(" "),a("h2",{attrs:{id:"openapi-support"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#openapi-support"}},[t._v("#")]),t._v(" OpenAPI support")]),t._v(" "),a("p",[t._v("Ajv supports these additional "),a("a",{attrs:{href:"https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md",target:"_blank",rel:"noopener noreferrer"}},[t._v("OpenAPI specification"),a("OutboundLink")],1),t._v(" keywords:")]),t._v(" "),a("ul",[a("li",[a("a",{attrs:{href:"#nullable"}},[t._v("nullable")]),t._v(" - to avoid using "),a("code",[t._v("type")]),t._v(" keyword with array of types.")]),t._v(" "),a("li",[a("a",{attrs:{href:"#discriminator"}},[t._v("discriminator")]),t._v(" - to optimize validation and error reporting of tagged unions")])]),t._v(" "),a("h2",{attrs:{id:"json-data-type"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#json-data-type"}},[t._v("#")]),t._v(" JSON data type")]),t._v(" "),a("h3",{attrs:{id:"type"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#type"}},[t._v("#")]),t._v(" "),a("code",[t._v("type")])]),t._v(" "),a("p",[a("code",[t._v("type")]),t._v(" keyword requires that the data is of certain type (or some of types). Its value can be a string (the allowed type) or an array of strings (multiple allowed types).")]),t._v(" "),a("p",[t._v("Type can be: "),a("code",[t._v("number")]),t._v(", "),a("code",[t._v("integer")]),t._v(", "),a("code",[t._v("string")]),t._v(", "),a("code",[t._v("boolean")]),t._v(", "),a("code",[t._v("array")]),t._v(", "),a("code",[t._v("object")]),t._v(" or "),a("code",[t._v("null")]),t._v(".")]),t._v(" "),a("p",[a("strong",[t._v("Examples")])]),t._v(" "),a("ol",[a("li",[a("p",[a("em",[t._v("schema")]),t._v(": "),a("code",[t._v('{type: "number"}')])]),t._v(" "),a("p",[a("em",[t._v("valid")]),t._v(": "),a("code",[t._v("1")]),t._v(", "),a("code",[t._v("1.5")])]),t._v(" "),a("p",[a("em",[t._v("invalid")]),t._v(": "),a("code",[t._v('"abc"')]),t._v(", "),a("code",[t._v('"1"')]),t._v(", "),a("code",[t._v("[]")]),t._v(", "),a("code",[t._v("{}")]),t._v(", "),a("code",[t._v("null")]),t._v(", "),a("code",[t._v("true")])])])]),t._v(" "),a("ol",{attrs:{start:"2"}},[a("li",[a("p",[a("em",[t._v("schema")]),t._v(": "),a("code",[t._v('{type: "integer"}')])]),t._v(" "),a("p",[a("em",[t._v("valid")]),t._v(": "),a("code",[t._v("1")]),t._v(", "),a("code",[t._v("2")])]),t._v(" "),a("p",[a("em",[t._v("invalid")]),t._v(": "),a("code",[t._v('"abc"')]),t._v(", "),a("code",[t._v('"1"')]),t._v(", "),a("code",[t._v("1.5")]),t._v(", "),a("code",[t._v("[]")]),t._v(", "),a("code",[t._v("{}")]),t._v(", "),a("code",[t._v("null")]),t._v(", "),a("code",[t._v("true")])])])]),t._v(" "),a("ol",{attrs:{start:"3"}},[a("li",[a("p",[a("em",[t._v("schema")]),t._v(": "),a("code",[t._v('{type: ["number", "string"]}')])]),t._v(" "),a("p",[a("em",[t._v("valid")]),t._v(": "),a("code",[t._v("1")]),t._v(", "),a("code",[t._v("1.5")]),t._v(", "),a("code",[t._v('"abc"')]),t._v(", "),a("code",[t._v('"1"')])]),t._v(" "),a("p",[a("em",[t._v("invalid")]),t._v(": "),a("code",[t._v("[]")]),t._v(", "),a("code",[t._v("{}")]),t._v(", "),a("code",[t._v("null")]),t._v(", "),a("code",[t._v("true")])])])]),t._v(" "),a("p",[t._v("All examples above are JSON Schemas that only require data to be of certain type to be valid.")]),t._v(" "),a("p",[t._v("Most other keywords apply only to a particular type of data. If the data is of different type, the keyword will not apply and the data will be considered valid.")]),t._v(" "),a("p",[t._v("In v7 Ajv introduced "),a("RouterLink",{attrs:{to:"/strict-mode.html#strict-types"}},[t._v("Strict types")]),t._v(" mode that makes these mistakes less likely by requiring that types are constrained with type keyword whenever another keyword that applies to specific type is used.")],1),t._v(" "),a("h3",{attrs:{id:"nullable"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#nullable"}},[t._v("#")]),t._v(" nullable "),a("Badge",{attrs:{text:"OpenAPI"}})],1),t._v(" "),a("p",[t._v("This keyword can be used to allow "),a("code",[t._v("null")]),t._v(" value in addition to the defined "),a("code",[t._v("type")]),t._v(".")]),t._v(" "),a("p",[t._v("Ajv supports it by default, without additional options. These two schemas are equivalent, but the first one is better supported by some tools and is also compatible with "),a("code",[t._v("strictTypes")]),t._v(" option (see "),a("RouterLink",{attrs:{to:"/strict-mode.html#strict-types"}},[t._v("Strict types")]),t._v(")")],1),t._v(" "),a("div",{staticClass:"language-json extra-class"},[a("pre",{pre:!0,attrs:{class:"language-json"}},[a("code",[a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token property"}},[t._v('"type"')]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"string"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token property"}},[t._v('"nullable"')]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token boolean"}},[t._v("true")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])]),a("p",[t._v("and")]),t._v(" "),a("div",{staticClass:"language-json extra-class"},[a("pre",{pre:!0,attrs:{class:"language-json"}},[a("code",[a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token property"}},[t._v('"type"')]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"string"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"null"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])]),a("div",{staticClass:"custom-block warning"},[a("p",{staticClass:"custom-block-title"},[t._v("nullable does not extend enum and const")]),t._v(" "),a("p",[t._v("If you use "),a("a",{attrs:{href:"#enum"}},[t._v("enum")]),t._v(" or "),a("a",{attrs:{href:"#const"}},[t._v("const")]),t._v(" keywords, "),a("code",[t._v('"nullable": true')]),t._v(" would not extend the list of allowed values - "),a("code",[t._v("null")]),t._v(" value has to be explicitly added to "),a("code",[t._v("enum")]),t._v(" (and "),a("code",[t._v("const")]),t._v(" would fail, unless it is "),a("code",[t._v('"const": null')]),t._v(")")]),t._v(" "),a("p",[t._v("This is different from how "),a("code",[t._v("nullable")]),t._v(" is defined in "),a("RouterLink",{attrs:{to:"/json-type-definition.html"}},[t._v("JSON Type Definition")]),t._v(", where "),a("code",[t._v('"nullable": true')]),t._v(" allows "),a("code",[t._v("null")]),t._v(" value in addition to any data defined by the schema.")],1)]),t._v(" "),a("h2",{attrs:{id:"keywords-for-numbers"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#keywords-for-numbers"}},[t._v("#")]),t._v(" Keywords for numbers")]),t._v(" "),a("h3",{attrs:{id:"maximum-minimum-and-exclusivemaximum-exclusiveminimum"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#maximum-minimum-and-exclusivemaximum-exclusiveminimum"}},[t._v("#")]),t._v(" "),a("code",[t._v("maximum")]),t._v(" / "),a("code",[t._v("minimum")]),t._v(" and "),a("code",[t._v("exclusiveMaximum")]),t._v(" / "),a("code",[t._v("exclusiveMinimum")])]),t._v(" "),a("p",[t._v("The value of keyword "),a("code",[t._v("maximum")]),t._v(" ("),a("code",[t._v("minimum")]),t._v(") should be a number. This value is the maximum (minimum) allowed value for the data to be valid.")]),t._v(" "),a("p",[t._v("The value of keyword "),a("code",[t._v("exclusiveMaximum")]),t._v(" ("),a("code",[t._v("exclusiveMinimum")]),t._v(") should be a number. This value is the exclusive maximum (minimum) allowed value for the data to be valid (the data equal to this keyword value is invalid).")]),t._v(" "),a("div",{staticClass:"custom-block warning"},[a("p",{staticClass:"custom-block-title"},[t._v("NO support for boolean keyword values")]),t._v(" "),a("p",[t._v("Boolean values for keywords "),a("code",[t._v("exclusiveMaximum")]),t._v(" ("),a("code",[t._v("exclusiveMinimum")]),t._v(") are not supported.")])]),t._v(" "),a("p",[a("strong",[t._v("Examples")])]),t._v(" "),a("ol",[a("li",[a("p",[a("em",[t._v("schema")]),t._v(": "),a("code",[t._v('{type: "number", maximum: 5}')])]),t._v(" "),a("p",[a("em",[t._v("valid")]),t._v(": "),a("code",[t._v("4")]),t._v(", "),a("code",[t._v("5")])]),t._v(" "),a("p",[a("em",[t._v("invalid")]),t._v(": "),a("code",[t._v("6")]),t._v(", "),a("code",[t._v("7")])])]),t._v(" "),a("li",[a("p",[a("em",[t._v("schema")]),t._v(": "),a("code",[t._v('{type: "number", minimum: 5}')])]),t._v(" "),a("p",[a("em",[t._v("valid")]),t._v(": "),a("code",[t._v("5")]),t._v(", "),a("code",[t._v("6")])]),t._v(" "),a("p",[a("em",[t._v("invalid")]),t._v(": "),a("code",[t._v("4")]),t._v(", "),a("code",[t._v("4.5")])])]),t._v(" "),a("li",[a("p",[a("em",[t._v("schema")]),t._v(": "),a("code",[t._v('{type: "number", exclusiveMinimum: 5}')])]),t._v(" "),a("p",[a("em",[t._v("valid")]),t._v(": "),a("code",[t._v("6")]),t._v(", "),a("code",[t._v("7")])]),t._v(" "),a("p",[a("em",[t._v("invalid")]),t._v(": "),a("code",[t._v("4.5")]),t._v(", "),a("code",[t._v("5")])])])]),t._v(" "),a("h3",{attrs:{id:"multipleof"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#multipleof"}},[t._v("#")]),t._v(" "),a("code",[t._v("multipleOf")])]),t._v(" "),a("p",[t._v("The value of the keyword should be a number. The data to be valid should be a multiple of the keyword value (i.e. the result of division of the data on the value should be integer).")]),t._v(" "),a("p",[a("strong",[t._v("Examples")])]),t._v(" "),a("ol",[a("li",[a("p",[a("em",[t._v("schema")]),t._v(": "),a("code",[t._v('{type: "number", multipleOf: 5}')])]),t._v(" "),a("p",[a("em",[t._v("valid")]),t._v(": "),a("code",[t._v("5")]),t._v(", "),a("code",[t._v("10")])]),t._v(" "),a("p",[a("em",[t._v("invalid")]),t._v(": "),a("code",[t._v("1")]),t._v(", "),a("code",[t._v("4")])])])]),t._v(" "),a("ol",{attrs:{start:"2"}},[a("li",[a("p",[a("em",[t._v("schema")]),t._v(": "),a("code",[t._v('{type: "number", multipleOf: 2.5}')])]),t._v(" "),a("p",[a("em",[t._v("valid")]),t._v(": "),a("code",[t._v("2.5")]),t._v(", "),a("code",[t._v("5")]),t._v(", "),a("code",[t._v("7.5")])]),t._v(" "),a("p",[a("em",[t._v("invalid")]),t._v(": "),a("code",[t._v("1")]),t._v(", "),a("code",[t._v("4")])])])]),t._v(" "),a("h2",{attrs:{id:"keywords-for-strings"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#keywords-for-strings"}},[t._v("#")]),t._v(" Keywords for strings")]),t._v(" "),a("h3",{attrs:{id:"maxlength-minlength"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#maxlength-minlength"}},[t._v("#")]),t._v(" "),a("code",[t._v("maxLength")]),t._v(" / "),a("code",[t._v("minLength")])]),t._v(" "),a("div",{staticClass:"custom-block warning"},[a("p",{staticClass:"custom-block-title"},[t._v("Grapheme clusters will count as multiple characters")]),t._v(" "),a("p",[t._v("Certain charsets have characters that are made up of multiple Unicode code points. These "),a("a",{attrs:{href:"https://www.unicode.org/reports/tr29/tr29-17.html#Grapheme_Cluster_Boundaries",target:"_blank",rel:"noopener noreferrer"}},[t._v("grapheme clusters"),a("OutboundLink")],1),t._v(" are counted as multiple in length calculations.")])]),t._v(" "),a("p",[t._v("The value of the keywords should be a number. The data to be valid should have length satisfying this rule. Unicode pairs are counted as a single character.")]),t._v(" "),a("p",[a("strong",[t._v("Examples")])]),t._v(" "),a("ol",[a("li",[a("p",[a("em",[t._v("schema")]),t._v(": "),a("code",[t._v('{type: "string", maxLength: 5}')])]),t._v(" "),a("p",[a("em",[t._v("valid")]),t._v(": "),a("code",[t._v('"abc"')]),t._v(", "),a("code",[t._v('"abcde"')])]),t._v(" "),a("p",[a("em",[t._v("invalid")]),t._v(": "),a("code",[t._v('"abcdef"')])])])]),t._v(" "),a("ol",{attrs:{start:"2"}},[a("li",[a("p",[a("em",[t._v("schema")]),t._v(": "),a("code",[t._v('{type: "string", minLength: 2}')])]),t._v(" "),a("p",[a("em",[t._v("valid")]),t._v(": "),a("code",[t._v('"ab"')]),t._v(", "),a("code",[t._v('"😀😀"')])]),t._v(" "),a("p",[a("em",[t._v("invalid")]),t._v(": "),a("code",[t._v('"a"')]),t._v(", "),a("code",[t._v('"😀"')])])])]),t._v(" "),a("h3",{attrs:{id:"pattern"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#pattern"}},[t._v("#")]),t._v(" "),a("code",[t._v("pattern")])]),t._v(" "),a("p",[t._v("The value of the keyword should be a string. The data to be valid should match the regular expression defined by the keyword value.")]),t._v(" "),a("p",[t._v("Ajv uses "),a("code",[t._v('new RegExp(value, "u")')]),t._v(" to create the regular expression that will be used to test data.")]),t._v(" "),a("p",[a("strong",[t._v("Example")])]),t._v(" "),a("p",[a("em",[t._v("schema")]),t._v(": "),a("code",[t._v('{type: "string", pattern: "[abc]+"}')])]),t._v(" "),a("p",[a("em",[t._v("valid")]),t._v(": "),a("code",[t._v('"a"')]),t._v(", "),a("code",[t._v('"abcd"')]),t._v(", "),a("code",[t._v('"cde"')])]),t._v(" "),a("p",[a("em",[t._v("invalid")]),t._v(": "),a("code",[t._v('"def"')]),t._v(", "),a("code",[t._v('""')])]),t._v(" "),a("h3",{attrs:{id:"format"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#format"}},[t._v("#")]),t._v(" "),a("code",[t._v("format")])]),t._v(" "),a("p",[t._v("The value of the keyword should be a string. The data to be valid should match the format with this name.")]),t._v(" "),a("p",[t._v("Ajv does not include any formats, they can be added with "),a("a",{attrs:{href:"https://github.com/ajv-validator/ajv-formats",target:"_blank",rel:"noopener noreferrer"}},[t._v("ajv-formats"),a("OutboundLink")],1),t._v(" plugin.")]),t._v(" "),a("p",[a("strong",[t._v("Example")])]),t._v(" "),a("p",[a("em",[t._v("schema")]),t._v(": "),a("code",[t._v('{type: "string", format: "ipv4"}')])]),t._v(" "),a("p",[a("em",[t._v("valid")]),t._v(": "),a("code",[t._v('"192.168.0.1"')])]),t._v(" "),a("p",[a("em",[t._v("invalid")]),t._v(": "),a("code",[t._v('"abc"')])]),t._v(" "),a("h2",{attrs:{id:"keywords-for-arrays"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#keywords-for-arrays"}},[t._v("#")]),t._v(" Keywords for arrays")]),t._v(" "),a("h3",{attrs:{id:"maxitems-minitems"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#maxitems-minitems"}},[t._v("#")]),t._v(" "),a("code",[t._v("maxItems")]),t._v(" / "),a("code",[t._v("minItems")])]),t._v(" "),a("p",[t._v("The value of the keywords should be a number. The data array to be valid should not have more (less) items than the keyword value.")]),t._v(" "),a("p",[a("strong",[t._v("Example")])]),t._v(" "),a("p",[a("em",[t._v("schema")]),t._v(": "),a("code",[t._v('{type: "array", maxItems: 3}')])]),t._v(" "),a("p",[a("em",[t._v("valid")]),t._v(": "),a("code",[t._v("[]")]),t._v(", "),a("code",[t._v("[1]")]),t._v(", "),a("code",[t._v('["1", 2, "3"]')])]),t._v(" "),a("p",[a("em",[t._v("invalid")]),t._v(": "),a("code",[t._v("[1, 2, 3, 4]")])]),t._v(" "),a("h3",{attrs:{id:"uniqueitems"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#uniqueitems"}},[t._v("#")]),t._v(" "),a("code",[t._v("uniqueItems")])]),t._v(" "),a("p",[t._v("The value of the keyword should be a boolean. If the keyword value is "),a("code",[t._v("true")]),t._v(", the data array to be valid should have unique items.")]),t._v(" "),a("p",[a("strong",[t._v("Example")])]),t._v(" "),a("p",[a("em",[t._v("schema")]),t._v(": "),a("code",[t._v('{type: "array", uniqueItems: true}')])]),t._v(" "),a("p",[a("em",[t._v("valid")]),t._v(": "),a("code",[t._v("[]")]),t._v(", "),a("code",[t._v("[1]")]),t._v(", "),a("code",[t._v('["1", 2, "3"]')])]),t._v(" "),a("p",[a("em",[t._v("invalid")]),t._v(": "),a("code",[t._v("[1, 2, 1]")]),t._v(", "),a("code",[t._v("[{a: 1, b: 2}, {b: 2, a: 1}]")])]),t._v(" "),a("h3",{attrs:{id:"items"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#items"}},[t._v("#")]),t._v(" "),a("code",[t._v("items")])]),t._v(" "),a("h4",{attrs:{id:"items-in-draft-04-06-07-and-2019-09"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#items-in-draft-04-06-07-and-2019-09"}},[t._v("#")]),t._v(" "),a("code",[t._v("items")]),t._v(" in draft-04, -06, -07 and -2019-09")]),t._v(" "),a("div",{staticClass:"custom-block warning"},[a("p",{staticClass:"custom-block-title"},[t._v("items keyword changed in JSON Schema draft-2020-12")]),t._v(" "),a("p",[t._v("This section describes "),a("code",[t._v("items")]),t._v(" keyword in all JSON Schema versions prior to draft-2020-12.")])]),t._v(" "),a("p",[t._v("The value of the keyword should be a schema or an array of schemas.")]),t._v(" "),a("p",[t._v("If the keyword value is a schema, then for the data array to be valid each item of the array should be valid according to the schema. In this case the "),a("code",[t._v("additionalItems")]),t._v(" keyword is ignored.")]),t._v(" "),a("p",[t._v("If the keyword value is an array, then items with indices less than the number of items in the keyword should be valid according to the schemas with the same indices. Whether additional items are valid will depend on "),a("code",[t._v("additionalItems")]),t._v(" keyword.")]),t._v(" "),a("p",[a("strong",[t._v("Examples")])]),t._v(" "),a("ol",[a("li",[a("p",[a("em",[t._v("schema")]),t._v(": "),a("code",[t._v('{type: "array", items: {type: "integer"}}')])]),t._v(" "),a("p",[a("em",[t._v("valid")]),t._v(": "),a("code",[t._v("[1,2,3]")]),t._v(", "),a("code",[t._v("[]")])]),t._v(" "),a("p",[a("em",[t._v("invalid")]),t._v(": "),a("code",[t._v('[1,"abc"]')])])]),t._v(" "),a("li",[a("p",[a("em",[t._v("schema")]),t._v(":")]),t._v(" "),a("div",{staticClass:"language-javascript extra-class"},[a("pre",{pre:!0,attrs:{class:"language-javascript"}},[a("code",[a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"array"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("items")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"integer"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"string"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])]),a("p",[a("em",[t._v("valid")]),t._v(": "),a("code",[t._v("[1]")]),t._v(", "),a("code",[t._v('[1, "abc"]')]),t._v(", "),a("code",[t._v('[1, "abc", 2]')]),t._v(", "),a("code",[t._v("[]")])]),t._v(" "),a("p",[a("em",[t._v("invalid")]),t._v(": "),a("code",[t._v('["abc", 1]')]),t._v(", "),a("code",[t._v('["abc"]')])])])]),t._v(" "),a("p",[t._v("The schema in example 2 will log warning by default (see "),a("code",[t._v("strictTuples")]),t._v(" option), because it defines unconstrained tuple. To define a tuple with exactly 2 elements use "),a("code",[t._v("minItems")]),t._v(" and "),a("code",[t._v("additionalItems")]),t._v(" keywords (see example 1 in "),a("code",[t._v("additionalItems")]),t._v(").")]),t._v(" "),a("h4",{attrs:{id:"items-in-draft-2020-12"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#items-in-draft-2020-12"}},[t._v("#")]),t._v(" "),a("code",[t._v("items")]),t._v(" in draft-2020-12 "),a("Badge",{attrs:{text:"NEW"}})],1),t._v(" "),a("div",{staticClass:"custom-block warning"},[a("p",{staticClass:"custom-block-title"},[t._v("items keyword changed in JSON Schema draft-2020-12")]),t._v(" "),a("p",[t._v("This section describes "),a("code",[t._v("items")]),t._v(" keyword in JSON draft-2020-12.")])]),t._v(" "),a("p",[t._v("The value of the keyword must be a schema.")]),t._v(" "),a("p",[t._v("For the data array to be valid:")]),t._v(" "),a("ul",[a("li",[t._v("if "),a("a",{attrs:{href:"#prefixItems"}},[t._v("prefixItems")]),t._v(" keyword is not used in the schema, then each item of the array must be valid according to the schema in "),a("code",[t._v("items")]),t._v(".")]),t._v(" "),a("li",[t._v("if "),a("a",{attrs:{href:"#prefixItems"}},[t._v("prefixItems")]),t._v(" keyword is used in the schema, then each item with the index starting from the size of "),a("code",[t._v("prefixItems")]),t._v(" schema must be valid according to the schema in "),a("code",[t._v("items")])])]),t._v(" "),a("p",[a("strong",[t._v("Examples")])]),t._v(" "),a("ol",[a("li",[a("p",[a("em",[t._v("schema")]),t._v(": "),a("code",[t._v('{type: "array", items: {type: "integer"}}')])]),t._v(" "),a("p",[a("em",[t._v("valid")]),t._v(": "),a("code",[t._v("[1,2,3]")]),t._v(", "),a("code",[t._v("[]")])]),t._v(" "),a("p",[a("em",[t._v("invalid")]),t._v(": "),a("code",[t._v('[1,"abc"]')])])]),t._v(" "),a("li",[a("p",[a("em",[t._v("schema")]),t._v(":")]),t._v(" "),a("div",{staticClass:"language-javascript extra-class"},[a("pre",{pre:!0,attrs:{class:"language-javascript"}},[a("code",[a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"array"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("prefixItems")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"integer"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"integer"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("minItems")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("2")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("items")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token boolean"}},[t._v("false")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])]),a("p",[a("em",[t._v("valid")]),t._v(": "),a("code",[t._v("[1, 2]")])]),t._v(" "),a("p",[a("em",[t._v("invalid")]),t._v(": "),a("code",[t._v("[]")]),t._v(", "),a("code",[t._v("[1]")]),t._v(", "),a("code",[t._v("[1, 2, 3]")]),t._v(", "),a("code",[t._v('[1, "abc"]')]),t._v(" (any wrong number of items or wrong type)")])]),t._v(" "),a("li",[a("p",[a("em",[t._v("schema")]),t._v(":")]),t._v(" "),a("div",{staticClass:"language-javascript extra-class"},[a("pre",{pre:!0,attrs:{class:"language-javascript"}},[a("code",[a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"array"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("prefixItems")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"integer"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"integer"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("items")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"string"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])]),a("p",[a("em",[t._v("valid")]),t._v(": "),a("code",[t._v("[]")]),t._v(", "),a("code",[t._v("[1, 2]")]),t._v(", "),a("code",[t._v('[1, 2, "abc"]')])]),t._v(" "),a("p",[a("em",[t._v("invalid")]),t._v(": "),a("code",[t._v('["abc"]')]),t._v(", "),a("code",[t._v("[1, 2, 3]")])]),t._v(" "),a("div",{staticClass:"language- extra-class"},[a("pre",{pre:!0,attrs:{class:"language-text"}},[a("code",[t._v('\n_valid_: `[1]`, `[1, "abc"]`, `[1, "abc", 2]`, `[]`\n\n_invalid_: `["abc", 1]`, `["abc"]`\n\n')])])])])]),t._v(" "),a("p",[t._v("The schema in example 3 will log warning by default (see "),a("code",[t._v("strictTuples")]),t._v(" option), because it defines unconstrained tuple. To define a tuple with exactly 2 elements use "),a("code",[t._v("minItems")]),t._v(" and "),a("code",[t._v("items")]),t._v(" keywords (see example 2).")]),t._v(" "),a("h3",{attrs:{id:"prefixitems"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#prefixitems"}},[t._v("#")]),t._v(" "),a("code",[t._v("prefixItems")]),t._v(" "),a("Badge",{attrs:{text:"NEW: draft 2020-12"}})],1),t._v(" "),a("p",[t._v("The value of the keyword must be an array of schemas.")]),t._v(" "),a("p",[t._v("For the data array to be valid, the items with indices less than the number of schemas in this keyword must be valid according to the schemas with the same indices. Whether additional items are valid will depend on "),a("code",[t._v("items")]),t._v(" keyword.")]),t._v(" "),a("p",[a("strong",[t._v("Examples")])]),t._v(" "),a("p",[a("em",[t._v("schema")]),t._v(":")]),t._v(" "),a("div",{staticClass:"language-javascript extra-class"},[a("pre",{pre:!0,attrs:{class:"language-javascript"}},[a("code",[a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"array"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("prefixItems")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"integer"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"string"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])]),a("p",[a("em",[t._v("valid")]),t._v(": "),a("code",[t._v("[1]")]),t._v(", "),a("code",[t._v('[1, "abc"]')]),t._v(", "),a("code",[t._v('[1, "abc", 2]')]),t._v(", "),a("code",[t._v("[]")])]),t._v(" "),a("p",[a("em",[t._v("invalid")]),t._v(": "),a("code",[t._v('["abc", 1]')]),t._v(", "),a("code",[t._v('["abc"]')])]),t._v(" "),a("p",[t._v("The schema in example will log warning by default (see "),a("code",[t._v("strictTuples")]),t._v(" option), because it defines unconstrained tuple. To define a tuple with exactly 2 elements use "),a("a",{attrs:{href:"#minitems"}},[t._v("minItems")]),t._v(" and "),a("a",{attrs:{href:"#items-in-draft-2020-12"}},[t._v("items")]),t._v(" keywords (see example 2 in "),a("a",{attrs:{href:"#items-in-draft-2020-12"}},[t._v("items")]),t._v(").")]),t._v(" "),a("h3",{attrs:{id:"additionalitems"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#additionalitems"}},[t._v("#")]),t._v(" "),a("code",[t._v("additionalItems")])]),t._v(" "),a("div",{staticClass:"custom-block warning"},[a("p",{staticClass:"custom-block-title"},[t._v("additionalItems is not supported in JSON Schema draft-2020-12")]),t._v(" "),a("p",[t._v("To create and equivalent schema in draft-2020-12 use keywords "),a("a",{attrs:{href:"#prefixItems"}},[t._v("prefixItems")]),t._v(" and the new "),a("a",{attrs:{href:"#items-in-draft-2020-12"}},[t._v("items")]),t._v(" keyword")])]),t._v(" "),a("p",[t._v("The value of the keyword should be a boolean or an object.")]),t._v(" "),a("p",[t._v("If "),a("code",[t._v("items")]),t._v(" keyword is not present or it is an object, "),a("code",[t._v("additionalItems")]),t._v(" keyword should be ignored regardless of its value. By default Ajv will throw exception in this case - see "),a("RouterLink",{attrs:{to:"/strict-mode.html"}},[t._v("Strict mode")])],1),t._v(" "),a("p",[t._v("If "),a("code",[t._v("items")]),t._v(" keyword is an array and data array has not more items than the length of "),a("code",[t._v("items")]),t._v(" keyword value, "),a("code",[t._v("additionalItems")]),t._v(" keyword is also ignored.")]),t._v(" "),a("p",[t._v('If the length of data array is bigger than the length of "items" keyword value than the result of the validation depends on the value of '),a("code",[t._v("additionalItems")]),t._v(" keyword:")]),t._v(" "),a("ul",[a("li",[a("code",[t._v("false")]),t._v(": data is invalid")]),t._v(" "),a("li",[a("code",[t._v("true")]),t._v(": data is valid")]),t._v(" "),a("li",[t._v('an object: data is valid if all additional items (i.e. items with indices greater or equal than "items" keyword value length) are valid according to the schema in "additionalItems" keyword.')])]),t._v(" "),a("p",[t._v("The schemas in examples 2-3 log warning by default, use option "),a("code",[t._v("strictTuples: false")]),t._v(" to allow)")]),t._v(" "),a("p",[a("strong",[t._v("Examples")])]),t._v(" "),a("ol",[a("li",[a("p",[a("em",[t._v("schema")]),t._v(":")]),t._v(" "),a("div",{staticClass:"language-javascript extra-class"},[a("pre",{pre:!0,attrs:{class:"language-javascript"}},[a("code",[a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"array"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("items")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"integer"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"integer"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("minItems")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("2")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("additionalItems")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token boolean"}},[t._v("false")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])]),a("p",[a("em",[t._v("valid")]),t._v(": "),a("code",[t._v("[1, 2]")])]),t._v(" "),a("p",[a("em",[t._v("invalid")]),t._v(": "),a("code",[t._v("[]")]),t._v(", "),a("code",[t._v("[1]")]),t._v(", "),a("code",[t._v("[1, 2, 3]")]),t._v(", "),a("code",[t._v('[1, "abc"]')]),t._v(" (any wrong number of items or wrong type)")])]),t._v(" "),a("li",[a("p",[a("em",[t._v("schema")]),t._v(":")]),t._v(" "),a("div",{staticClass:"language-javascript extra-class"},[a("pre",{pre:!0,attrs:{class:"language-javascript"}},[a("code",[a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"array"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("items")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"integer"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"integer"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("additionalItems")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token boolean"}},[t._v("true")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])]),a("p",[a("em",[t._v("valid")]),t._v(": "),a("code",[t._v("[]")]),t._v(", "),a("code",[t._v("[1, 2]")]),t._v(", "),a("code",[t._v("[1, 2, 3]")]),t._v(", "),a("code",[t._v('[1, 2, "abc"]')])]),t._v(" "),a("p",[a("em",[t._v("invalid")]),t._v(": "),a("code",[t._v('["abc"]')]),t._v(", "),a("code",[t._v('[1, "abc", 3]')])])]),t._v(" "),a("li",[a("p",[a("em",[t._v("schema")]),t._v(":")]),t._v(" "),a("div",{staticClass:"language-javascript extra-class"},[a("pre",{pre:!0,attrs:{class:"language-javascript"}},[a("code",[a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"array"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("items")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"integer"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"integer"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("additionalItems")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"string"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])]),a("p",[a("em",[t._v("valid")]),t._v(": "),a("code",[t._v("[]")]),t._v(", "),a("code",[t._v("[1, 2]")]),t._v(", "),a("code",[t._v('[1, 2, "abc"]')])]),t._v(" "),a("p",[a("em",[t._v("invalid")]),t._v(": "),a("code",[t._v('["abc"]')]),t._v(", "),a("code",[t._v("[1, 2, 3]")])])])]),t._v(" "),a("h3",{attrs:{id:"contains"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#contains"}},[t._v("#")]),t._v(" "),a("code",[t._v("contains")])]),t._v(" "),a("p",[t._v("The value of the keyword is a JSON Schema. The array is valid if it contains at least one item that is valid according to this schema.")]),t._v(" "),a("p",[a("strong",[t._v("Example")])]),t._v(" "),a("p",[a("em",[t._v("schema")]),t._v(": "),a("code",[t._v('{type: "array", contains: {type: "integer"}}')])]),t._v(" "),a("p",[a("em",[t._v("valid")]),t._v(": "),a("code",[t._v("[1]")]),t._v(", "),a("code",[t._v('[1, "foo"]')]),t._v(", any array with at least one integer")]),t._v(" "),a("p",[a("em",[t._v("invalid")]),t._v(": "),a("code",[t._v("[]")]),t._v(", "),a("code",[t._v('["foo", "bar"]')]),t._v(", any array without integers")]),t._v(" "),a("h3",{attrs:{id:"maxcontains-mincontains"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#maxcontains-mincontains"}},[t._v("#")]),t._v(" "),a("code",[t._v("maxContains")]),t._v(" / "),a("code",[t._v("minContains")]),t._v(" "),a("Badge",{attrs:{text:"NEW: draft 2019-09"}})],1),t._v(" "),a("p",[t._v("The value of these keywords should be an integer.")]),t._v(" "),a("p",[t._v("Without "),a("code",[t._v("contains")]),t._v(" keyword they are ignored (logs error or throws exception in ajv "),a("RouterLink",{attrs:{to:"/strict-mode.html"}},[t._v("strict mode")]),t._v(").")],1),t._v(" "),a("p",[t._v("The array is valid if it contains at least "),a("code",[t._v("minContains")]),t._v(" items and no more than "),a("code",[t._v("maxContains")]),t._v(" items that are valid against the schema in "),a("code",[t._v("contains")]),t._v(" keyword.")]),t._v(" "),a("p",[a("strong",[t._v("Example")])]),t._v(" "),a("p",[a("em",[t._v("schema")]),t._v(":")]),t._v(" "),a("div",{staticClass:"language-javascript extra-class"},[a("pre",{pre:!0,attrs:{class:"language-javascript"}},[a("code",[a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"array"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("contains")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"integer"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("minContains")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("2")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("maxContains")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("3")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])]),a("p",[a("em",[t._v("valid")]),t._v(": "),a("code",[t._v("[1, 2]")]),t._v(", "),a("code",[t._v('[1, 2, 3, "foo"]')]),t._v(", any array with 2 or 3 integers")]),t._v(" "),a("p",[a("em",[t._v("invalid")]),t._v(": "),a("code",[t._v("[]")]),t._v(", "),a("code",[t._v('[1, "foo"]')]),t._v(", "),a("code",[t._v("[1, 2, 3, 4]")]),t._v(", any array with fewer than 2 or more than 3 integers")]),t._v(" "),a("h3",{attrs:{id:"unevaluateditems"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#unevaluateditems"}},[t._v("#")]),t._v(" "),a("code",[t._v("unevaluatedItems")]),t._v(" "),a("Badge",{attrs:{text:"NEW: draft 2019-09"}})],1),t._v(" "),a("p",[t._v("The value of this keyword is a JSON Schema (can be a boolean).")]),t._v(" "),a("p",[t._v("This schema will be applied to all array items that were not evaluated by other keywords for items ("),a("code",[t._v("items")]),t._v(", "),a("code",[t._v("additionalItems")]),t._v(" and "),a("code",[t._v("contains")]),t._v(") in the current schema and all sub-schemas that were valid for this data instance. It includes:")]),t._v(" "),a("ul",[a("li",[t._v("all subschemas schemas in "),a("code",[t._v("allOf")]),t._v(" and "),a("code",[t._v("$ref")]),t._v(" keywords")]),t._v(" "),a("li",[t._v("valid sub-schemas in "),a("code",[t._v("oneOf")]),t._v(" and "),a("code",[t._v("anyOf")]),t._v(" keywords")]),t._v(" "),a("li",[t._v("sub-schema in "),a("code",[t._v("if")]),t._v(" keyword")]),t._v(" "),a("li",[t._v("sub-schemas in "),a("code",[t._v("then")]),t._v(" or "),a("code",[t._v("else")]),t._v(" keywords that were applied based on the validation result by "),a("code",[t._v("if")]),t._v(" keyword.")])]),t._v(" "),a("p",[t._v("The only scenario when this keyword would be applied to some items is when "),a("code",[t._v("items")]),t._v(" keyword value is an array of schemas and "),a("code",[t._v("additionalItems")]),t._v(" was not present (or did not apply, in case it was present in some invalid subschema).")]),t._v(" "),a("p",[t._v('Some user-defined keywords can also make items "evaluated".')]),t._v(" "),a("p",[a("strong",[t._v("Example")])]),t._v(" "),a("p",[a("em",[t._v("schema")]),t._v(":")]),t._v(" "),a("div",{staticClass:"language-javascript extra-class"},[a("pre",{pre:!0,attrs:{class:"language-javascript"}},[a("code",[a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"array"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("items")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"number"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"number"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("unevaluatedItems")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token boolean"}},[t._v("false")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("anyOf")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("items")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),a("span",{pre:!0,attrs:{class:"token boolean"}},[t._v("true")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token boolean"}},[t._v("true")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"number"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("items")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),a("span",{pre:!0,attrs:{class:"token boolean"}},[t._v("true")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token boolean"}},[t._v("true")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"boolean"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])]),a("p",[a("em",[t._v("valid")]),t._v(": "),a("code",[t._v("[1, 2, 3]")]),t._v(", "),a("code",[t._v("[1, 2, true]")])]),t._v(" "),a("p",[a("em",[t._v("invalid")]),t._v(":")]),t._v(" "),a("ul",[a("li",[a("code",[t._v("[1, 2]")]),t._v(" - the third item is not present")]),t._v(" "),a("li",[a("code",[t._v('[1, 2, "3"]')]),t._v(' - the third item is "unevaluated"')])]),t._v(" "),a("p",[t._v("See "),a("a",{attrs:{href:"https://github.com/json-schema-org/JSON-Schema-Test-Suite/blob/master/tests/draft2019-09/unevaluatedItems.json",target:"_blank",rel:"noopener noreferrer"}},[t._v("tests"),a("OutboundLink")],1),t._v(" for "),a("code",[t._v("unevaluatedItems")]),t._v(" keyword for other examples.")]),t._v(" "),a("h2",{attrs:{id:"keywords-for-objects"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#keywords-for-objects"}},[t._v("#")]),t._v(" Keywords for objects")]),t._v(" "),a("h3",{attrs:{id:"maxproperties-minproperties"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#maxproperties-minproperties"}},[t._v("#")]),t._v(" "),a("code",[t._v("maxProperties")]),t._v(" / "),a("code",[t._v("minProperties")])]),t._v(" "),a("p",[t._v("The value of the keywords should be a number. The data object to be valid should have not more (less) properties than the keyword value.")]),t._v(" "),a("p",[a("strong",[t._v("Example")])]),t._v(" "),a("p",[a("em",[t._v("schema")]),t._v(": "),a("code",[t._v('{type: "object", maxProperties: 2 }')])]),t._v(" "),a("p",[a("em",[t._v("valid")]),t._v(": "),a("code",[t._v("{}")]),t._v(", "),a("code",[t._v("{a: 1}")]),t._v(", "),a("code",[t._v('{a: "1", b: 2}')])]),t._v(" "),a("p",[a("em",[t._v("invalid")]),t._v(": "),a("code",[t._v("{a: 1, b: 2, c: 3}")])]),t._v(" "),a("h3",{attrs:{id:"required"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#required"}},[t._v("#")]),t._v(" "),a("code",[t._v("required")])]),t._v(" "),a("p",[t._v("The value of the keyword should be an array of unique strings. The data object to be valid should contain all properties with names equal to the elements in the keyword value.")]),t._v(" "),a("p",[a("strong",[t._v("Example")])]),t._v(" "),a("p",[a("em",[t._v("schema")]),t._v(": "),a("code",[t._v('{type: "object", required: ["a", "b"]}')])]),t._v(" "),a("p",[a("em",[t._v("valid")]),t._v(": "),a("code",[t._v("{a: 1, b: 2}")]),t._v(", "),a("code",[t._v("{a: 1, b: 2, c: 3}")])]),t._v(" "),a("p",[a("em",[t._v("invalid")]),t._v(": "),a("code",[t._v("{}")]),t._v(", "),a("code",[t._v("{a: 1}")]),t._v(", "),a("code",[t._v("{c: 3, d: 4}")])]),t._v(" "),a("h3",{attrs:{id:"properties"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#properties"}},[t._v("#")]),t._v(" "),a("code",[t._v("properties")])]),t._v(" "),a("p",[t._v("The value of the keyword should be a map with keys equal to data object properties. Each value in the map should be a JSON Schema. For data object to be valid the corresponding values in data object properties should be valid according to these schemas.")]),t._v(" "),a("div",{staticClass:"custom-block warning"},[a("p",{staticClass:"custom-block-title"},[t._v("Properties are not required")]),t._v(" "),a("p",[a("code",[t._v("properties")]),t._v(" keyword does not require that the properties mentioned in it are present in the object (see examples).")])]),t._v(" "),a("p",[a("strong",[t._v("Example")])]),t._v(" "),a("p",[a("em",[t._v("schema")]),t._v(":")]),t._v(" "),a("div",{staticClass:"language-javascript extra-class"},[a("pre",{pre:!0,attrs:{class:"language-javascript"}},[a("code",[a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"object"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("properties")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("foo")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"string"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("bar")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"number"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("minimum")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("2")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])]),a("p",[a("em",[t._v("valid")]),t._v(": "),a("code",[t._v("{}")]),t._v(", "),a("code",[t._v('{foo: "a"}')]),t._v(", "),a("code",[t._v('{foo: "a", bar: 2}')])]),t._v(" "),a("p",[a("em",[t._v("invalid")]),t._v(": "),a("code",[t._v("{foo: 1}")]),t._v(", "),a("code",[t._v('{foo: "a", bar: 1}')])]),t._v(" "),a("h3",{attrs:{id:"patternproperties"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#patternproperties"}},[t._v("#")]),t._v(" "),a("code",[t._v("patternProperties")])]),t._v(" "),a("p",[t._v("The value of this keyword should be a map where keys should be regular expressions and the values should be JSON Schemas. For data object to be valid the values in data object properties that match regular expression(s) should be valid according to the corresponding schema(s).")]),t._v(" "),a("p",[t._v("When the value in data object property matches multiple regular expressions it should be valid according to all the schemas for all matched regular expressions.")]),t._v(" "),a("div",{staticClass:"custom-block warning"},[a("p",{staticClass:"custom-block-title"},[t._v("Unexpected validation results")]),t._v(" "),a("ol",[a("li",[a("code",[t._v("patternProperties")]),t._v(" keyword does not require that properties matching patterns are present in the object (see examples).")]),t._v(" "),a("li",[t._v("By default, Ajv does not allow schemas where patterns in "),a("code",[t._v("patternProperties")]),t._v(" match any property name in "),a("code",[t._v("properties")]),t._v(" keyword - that leads to unexpected validation results. It can be allowed with option "),a("code",[t._v("allowMatchingProperties")]),t._v(". See "),a("RouterLink",{attrs:{to:"/strict-mode.html"}},[t._v("Strict mode")])],1)])]),t._v(" "),a("p",[a("strong",[t._v("Example")])]),t._v(" "),a("p",[a("em",[t._v("schema")]),t._v(":")]),t._v(" "),a("div",{staticClass:"language-javascript extra-class"},[a("pre",{pre:!0,attrs:{class:"language-javascript"}},[a("code",[a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"object"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("patternProperties")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token string-property property"}},[t._v('"^fo.*$"')]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"string"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token string-property property"}},[t._v('"^ba.*$"')]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"number"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])]),a("p",[a("em",[t._v("valid")]),t._v(": "),a("code",[t._v("{}")]),t._v(", "),a("code",[t._v('{foo: "a"}')]),t._v(", "),a("code",[t._v('{foo: "a", bar: 1}')])]),t._v(" "),a("p",[a("em",[t._v("invalid")]),t._v(": "),a("code",[t._v("{foo: 1}")]),t._v(", "),a("code",[t._v('{foo: "a", bar: "b"}')])]),t._v(" "),a("h3",{attrs:{id:"additionalproperties"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#additionalproperties"}},[t._v("#")]),t._v(" "),a("code",[t._v("additionalProperties")])]),t._v(" "),a("p",[t._v("The value of the keyword should be either a boolean or a JSON Schema.")]),t._v(" "),a("p",[t._v("If the value is "),a("code",[t._v("true")]),t._v(" the keyword is ignored.")]),t._v(" "),a("p",[t._v("If the value is "),a("code",[t._v("false")]),t._v(' the data object to be valid should not have "additional properties" (i.e. properties other than those used in "properties" keyword and those that match patterns in "patternProperties" keyword).')]),t._v(" "),a("p",[t._v('If the value is a schema for the data object to be valid the values in all "additional properties" should be valid according to this schema.')]),t._v(" "),a("p",[a("strong",[t._v("Examples")])]),t._v(" "),a("ol",[a("li",[a("p",[a("em",[t._v("schema")]),t._v(":")]),t._v(" "),a("div",{staticClass:"language-javascript extra-class"},[a("pre",{pre:!0,attrs:{class:"language-javascript"}},[a("code",[a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"object"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("properties")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("foo")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"number"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("patternProperties")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token string-property property"}},[t._v('"^.*r$"')]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"number"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("additionalProperties")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token boolean"}},[t._v("false")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])]),a("p",[a("em",[t._v("valid")]),t._v(": "),a("code",[t._v("{}")]),t._v(", "),a("code",[t._v("{foo: 1}")]),t._v(", "),a("code",[t._v("{foo: 1, bar: 2}")])]),t._v(" "),a("p",[a("em",[t._v("invalid")]),t._v(": "),a("code",[t._v("{a: 3}")]),t._v(", "),a("code",[t._v("{foo: 1, baz: 3}")])])]),t._v(" "),a("li",[a("p",[a("em",[t._v("schema")]),t._v(":")]),t._v(" "),a("div",{staticClass:"language-javascript extra-class"},[a("pre",{pre:!0,attrs:{class:"language-javascript"}},[a("code",[a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"object"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("properties")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("foo")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"number"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("patternProperties")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token string-property property"}},[t._v('"^.*r$"')]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"number"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("additionalProperties")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"string"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])]),a("p",[a("em",[t._v("valid")]),t._v(": "),a("code",[t._v("{}")]),t._v(", "),a("code",[t._v('{a: "b"}')]),t._v(", "),a("code",[t._v("{foo: 1}")]),t._v(", "),a("code",[t._v("{foo: 1, bar: 2}")]),t._v(", "),a("code",[t._v('{foo: 1, bar: 2, a: "b"}')])]),t._v(" "),a("p",[a("em",[t._v("invalid")]),t._v(": "),a("code",[t._v("{a: 3}")]),t._v(", "),a("code",[t._v("{foo: 1, baz: 3}")])])]),t._v(" "),a("li",[a("p",[a("em",[t._v("schema")]),t._v(":")]),t._v(" "),a("div",{staticClass:"language-javascript extra-class"},[a("pre",{pre:!0,attrs:{class:"language-javascript"}},[a("code",[a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"object"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("properties")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("foo")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"number"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("additionalProperties")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token boolean"}},[t._v("false")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("anyOf")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("properties")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("bar")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"number"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("properties")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("baz")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"number"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])]),a("p",[a("em",[t._v("valid")]),t._v(": "),a("code",[t._v("{}")]),t._v(", "),a("code",[t._v("{foo: 1}")])]),t._v(" "),a("p",[a("em",[t._v("invalid")]),t._v(": "),a("code",[t._v("{bar: 2}")]),t._v(", "),a("code",[t._v("{baz: 3}")]),t._v(", "),a("code",[t._v("{foo: 1, bar: 2}")]),t._v(", etc.")])])]),t._v(" "),a("h3",{attrs:{id:"dependencies"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#dependencies"}},[t._v("#")]),t._v(" "),a("code",[t._v("dependencies")]),t._v(" "),a("Badge",{attrs:{text:"deprecated in draft 2019-09",type:"warning"}})],1),t._v(" "),a("p",[t._v("This keyword is deprecated. The same functionality is available with keywords "),a("code",[t._v("dependentRequired")]),t._v(" and "),a("code",[t._v("dependentSchemas")]),t._v(".")]),t._v(" "),a("p",[t._v('The value of the keyword is a map with keys equal to data object properties. Each value in the map should be either an array of unique property names ("property dependency" - see '),a("a",{attrs:{href:"#%60dependentrequired%60"}},[a("code",[t._v("dependentRequired")])]),t._v(' keyword) or a JSON Schema ("schema dependency" - see '),a("a",{attrs:{href:"#%60dependentschemas%60"}},[a("code",[t._v("dependentSchemas")])]),t._v(" keyword).")]),t._v(" "),a("p",[t._v("For property dependency, if the data object contains a property that is a key in the keyword value, then to be valid the data object should also contain all properties from the array of properties.")]),t._v(" "),a("p",[t._v("For schema dependency, if the data object contains a property that is a key in the keyword value, then to be valid the data object itself (NOT the property value) should be valid according to the schema.")]),t._v(" "),a("p",[a("strong",[t._v("Examples")])]),t._v(" "),a("ol",[a("li",[a("p",[a("em",[t._v("schema (property dependency)")]),t._v(":")]),t._v(" "),a("div",{staticClass:"language-javascript extra-class"},[a("pre",{pre:!0,attrs:{class:"language-javascript"}},[a("code",[a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"object"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("dependencies")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("foo")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"bar"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"baz"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])]),a("p",[a("em",[t._v("valid")]),t._v(": "),a("code",[t._v("{foo: 1, bar: 2, baz: 3}")]),t._v(", "),a("code",[t._v("{}")]),t._v(", "),a("code",[t._v("{a: 1}")])]),t._v(" "),a("p",[a("em",[t._v("invalid")]),t._v(": "),a("code",[t._v("{foo: 1}")]),t._v(", "),a("code",[t._v("{foo: 1, bar: 2}")]),t._v(", "),a("code",[t._v("{foo: 1, baz: 3}")])])]),t._v(" "),a("li",[a("p",[a("em",[t._v("schema (schema dependency)")]),t._v(":")]),t._v(" "),a("div",{staticClass:"language-javascript extra-class"},[a("pre",{pre:!0,attrs:{class:"language-javascript"}},[a("code",[a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"object"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("dependencies")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("foo")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("properties")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("bar")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"number"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])]),a("p",[a("em",[t._v("valid")]),t._v(": "),a("code",[t._v("{}")]),t._v(", "),a("code",[t._v("{foo: 1}")]),t._v(", "),a("code",[t._v("{foo: 1, bar: 2}")]),t._v(", "),a("code",[t._v("{a: 1}")])]),t._v(" "),a("p",[a("em",[t._v("invalid")]),t._v(": "),a("code",[t._v('{foo: 1, bar: "a"}')])])])]),t._v(" "),a("h3",{attrs:{id:"dependentrequired"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#dependentrequired"}},[t._v("#")]),t._v(" "),a("code",[t._v("dependentRequired")]),t._v(" "),a("Badge",{attrs:{text:"NEW: draft 2019-09"}})],1),t._v(" "),a("p",[t._v("The value of this keyword should be a map with keys equal to data object properties. Each value in the map should be an array of unique property names.")]),t._v(" "),a("p",[t._v("If the data object contains a property that is a key in the keyword value, then to be valid the data object should also contain all properties from the corresponding array of properties in this keyword.")]),t._v(" "),a("p",[a("strong",[t._v("Example")])]),t._v(" "),a("p",[a("em",[t._v("schema")]),t._v(":")]),t._v(" "),a("div",{staticClass:"language-javascript extra-class"},[a("pre",{pre:!0,attrs:{class:"language-javascript"}},[a("code",[a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"object"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("dependentRequired")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("foo")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"bar"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"baz"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])]),a("p",[a("em",[t._v("valid")]),t._v(": "),a("code",[t._v("{foo: 1, bar: 2, baz: 3}")]),t._v(", "),a("code",[t._v("{}")]),t._v(", "),a("code",[t._v("{a: 1}")])]),t._v(" "),a("p",[a("em",[t._v("invalid")]),t._v(": "),a("code",[t._v("{foo: 1}")]),t._v(", "),a("code",[t._v("{foo: 1, bar: 2}")]),t._v(", "),a("code",[t._v("{foo: 1, baz: 3}")])]),t._v(" "),a("h3",{attrs:{id:"dependentschemas"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#dependentschemas"}},[t._v("#")]),t._v(" "),a("code",[t._v("dependentSchemas")]),t._v(" "),a("Badge",{attrs:{text:"NEW: draft 2019-09"}})],1),t._v(" "),a("p",[t._v("The value of the keyword should be a map with keys equal to data object properties. Each value in the map should be a JSON Schema.")]),t._v(" "),a("p",[t._v("If the data object contains a property that is a key in the keyword value, then to be valid the data object itself (NOT the property value) should be valid according to the corresponding schema in this keyword.")]),t._v(" "),a("p",[a("strong",[t._v("Example")])]),t._v(" "),a("p",[a("em",[t._v("schema")]),t._v(":")]),t._v(" "),a("div",{staticClass:"language-javascript extra-class"},[a("pre",{pre:!0,attrs:{class:"language-javascript"}},[a("code",[a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"object"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("dependentSchemas")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("foo")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("properties")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("bar")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"number"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])]),a("p",[a("em",[t._v("valid")]),t._v(": "),a("code",[t._v("{}")]),t._v(", "),a("code",[t._v("{foo: 1}")]),t._v(", "),a("code",[t._v("{foo: 1, bar: 2}")]),t._v(", "),a("code",[t._v("{a: 1}")])]),t._v(" "),a("p",[a("em",[t._v("invalid")]),t._v(": "),a("code",[t._v('{foo: 1, bar: "a"}')])]),t._v(" "),a("h3",{attrs:{id:"propertynames"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#propertynames"}},[t._v("#")]),t._v(" "),a("code",[t._v("propertyNames")])]),t._v(" "),a("p",[t._v("The value of this keyword is a JSON Schema.")]),t._v(" "),a("p",[t._v("For data object to be valid each property name in this object should be valid according to this schema.")]),t._v(" "),a("p",[a("strong",[t._v("Example")])]),t._v(" "),a("p",[a("em",[t._v("schema")]),t._v(" (requires "),a("code",[t._v("email")]),t._v(" format from "),a("a",{attrs:{href:"https://github.com/ajv-validator/ajv-formats",target:"_blank",rel:"noopener noreferrer"}},[t._v("ajv-formats"),a("OutboundLink")],1),t._v("):")]),t._v(" "),a("div",{staticClass:"language-javascript extra-class"},[a("pre",{pre:!0,attrs:{class:"language-javascript"}},[a("code",[a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"object"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("propertyNames")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("format")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"email"')]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])]),a("p",[a("em",[t._v("valid")]),t._v(": "),a("code",[t._v('{"foo@bar.com": "any", "bar@bar.com": "any"}')])]),t._v(" "),a("p",[a("em",[t._v("invalid")]),t._v(": "),a("code",[t._v('{foo: "any value"}')])]),t._v(" "),a("h3",{attrs:{id:"unevaluatedproperties"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#unevaluatedproperties"}},[t._v("#")]),t._v(" "),a("code",[t._v("unevaluatedProperties")]),t._v(" "),a("Badge",{attrs:{text:"NEW: draft 2019-09"}})],1),t._v(" "),a("p",[t._v("The value of this keyword is a JSON Schema (can be a boolean).")]),t._v(" "),a("p",[t._v("This schema will be applied to all properties that were not evaluated by other keywords for properties ("),a("code",[t._v("properties")]),t._v(", "),a("code",[t._v("patternProperties")]),t._v(" and "),a("code",[t._v("additionalProperties")]),t._v(") in the current schema and all sub-schemas that were valid for this data instance. It includes:")]),t._v(" "),a("ul",[a("li",[t._v("all subschemas schemas in "),a("code",[t._v("allOf")]),t._v(" and "),a("code",[t._v("$ref")]),t._v(" keywords")]),t._v(" "),a("li",[t._v("valid sub-schemas in "),a("code",[t._v("oneOf")]),t._v(" and "),a("code",[t._v("anyOf")]),t._v(" keywords")]),t._v(" "),a("li",[t._v("sub-schema in "),a("code",[t._v("if")]),t._v(" keyword")]),t._v(" "),a("li",[t._v("sub-schemas in "),a("code",[t._v("then")]),t._v(" or "),a("code",[t._v("else")]),t._v(" keywords that were applied based on the validation result by "),a("code",[t._v("if")]),t._v(" keyword.")])]),t._v(" "),a("p",[t._v('Some user-defined keywords can also make properties "evaluated".')]),t._v(" "),a("p",[a("strong",[t._v("Example")])]),t._v(" "),a("p",[a("em",[t._v("schema")]),t._v(":")]),t._v(" "),a("div",{staticClass:"language-javascript extra-class"},[a("pre",{pre:!0,attrs:{class:"language-javascript"}},[a("code",[a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"object"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("required")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"foo"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("properties")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("foo")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"number"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("unevaluatedProperties")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token boolean"}},[t._v("false")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("anyOf")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("required")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"bar"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("properties")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("bar")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"number"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("required")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"baz"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("properties")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("baz")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"number"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])]),a("p",[a("em",[t._v("valid")]),t._v(": "),a("code",[t._v("{foo: 1, bar: 2}")]),t._v(", "),a("code",[t._v("{foo: 1, baz: 2}")]),t._v(", "),a("code",[t._v("{foo: 1, bar: 2, baz: 3}")])]),t._v(" "),a("p",[a("em",[t._v("invalid")]),t._v(":")]),t._v(" "),a("ul",[a("li",[a("code",[t._v("{foo: 1}")]),t._v(" - neither "),a("code",[t._v("bar")]),t._v(" nor "),a("code",[t._v("baz")]),t._v(" are present")]),t._v(" "),a("li",[a("code",[t._v("{foo: 1, bar: 2, boo: 3}")]),t._v(" - "),a("code",[t._v("boo")]),t._v(" is unevaluated")]),t._v(" "),a("li",[a("code",[t._v('{foo: 1, bar: 2, baz: "3"}')]),t._v(" - not valid against the 2nd subschema, so "),a("code",[t._v("baz")]),t._v(' is "unevaluated".')])]),t._v(" "),a("p",[t._v("See "),a("a",{attrs:{href:"https://github.com/json-schema-org/JSON-Schema-Test-Suite/blob/master/tests/draft2019-09/unevaluatedProperties.json",target:"_blank",rel:"noopener noreferrer"}},[t._v("tests"),a("OutboundLink")],1),t._v(" for "),a("code",[t._v("unevaluatedProperties")]),t._v(" keyword for other examples.")]),t._v(" "),a("h3",{attrs:{id:"discriminator"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#discriminator"}},[t._v("#")]),t._v(" discriminator "),a("Badge",{attrs:{text:"NEW: OpenAPI"}})],1),t._v(" "),a("p",[t._v("Ajv has a limited support for "),a("code",[t._v("discriminator")]),t._v(" keyword: to optimize validation, error handling, and "),a("RouterLink",{attrs:{to:"/guide/modifying-data.html"}},[t._v("modifying data")]),t._v(" with "),a("a",{attrs:{href:"#oneof"}},[t._v("oneOf")]),t._v(" keyword.")],1),t._v(" "),a("p",[t._v("Its value should be an object with a property "),a("code",[t._v("propertyName")]),t._v(" - the name of the property used to discriminate between union members.")]),t._v(" "),a("p",[t._v("When using discriminator keyword only one subschema in "),a("code",[t._v("oneOf")]),t._v(" will be used, determined by the value of discriminator property.")]),t._v(" "),a("div",{staticClass:"custom-block warning"},[a("p",{staticClass:"custom-block-title"},[t._v("Use option discriminator")]),t._v(" "),a("p",[t._v("To use "),a("code",[t._v("discriminator")]),t._v(" keyword you have to use option "),a("code",[t._v("discriminator: true")]),t._v(" with Ajv constructor - it is not enabled by default.")])]),t._v(" "),a("p",[a("strong",[t._v("Example")])]),t._v(" "),a("p",[a("em",[t._v("schema")]),t._v(":")]),t._v(" "),a("div",{staticClass:"language-javascript extra-class"},[a("pre",{pre:!0,attrs:{class:"language-javascript"}},[a("code",[a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"object"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("discriminator")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("propertyName")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"foo"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("required")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"foo"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("oneOf")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("properties")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("foo")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"x"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("a")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"string"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("required")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"a"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("properties")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("foo")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("enum")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"y"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"z"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("b")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"string"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("required")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"b"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])]),a("p",[a("em",[t._v("valid")]),t._v(": "),a("code",[t._v('{foo: "x", a: "any"}')]),t._v(", "),a("code",[t._v('{foo: "y", b: "any"}')]),t._v(", "),a("code",[t._v('{foo: "z", b: "any"}')])]),t._v(" "),a("p",[a("em",[t._v("invalid")]),t._v(":")]),t._v(" "),a("ul",[a("li",[a("code",[t._v("{}")]),t._v(", "),a("code",[t._v("{foo: 1}")]),t._v(" - discriminator tag must be string")]),t._v(" "),a("li",[a("code",[t._v('{foo: "bar"}')]),t._v(" - discriminator tag value must be in oneOf subschema")]),t._v(" "),a("li",[a("code",[t._v('{foo: "x", b: "b"}')]),t._v(", "),a("code",[t._v('{foo: "y", a: "a"}')]),t._v(" - invalid object")])]),t._v(" "),a("p",[t._v("From the perspective of validation result "),a("code",[t._v("discriminator")]),t._v(" is defined as no-op (that is, removing discriminator will not change the validity of the data), but errors reported in case of invalid data will be different.")]),t._v(" "),a("p",[t._v("There are following requirements and limitations of using "),a("code",[t._v("discriminator")]),t._v(" keyword:")]),t._v(" "),a("ul",[a("li",[a("code",[t._v("mapping")]),t._v(" in discriminator object is not supported.")]),t._v(" "),a("li",[a("a",{attrs:{href:"#oneof"}},[t._v("oneOf")]),t._v(" keyword must be present in the same schema.")]),t._v(" "),a("li",[t._v("discriminator property should be "),a("a",{attrs:{href:"#required"}},[t._v("required")]),t._v(" either on the top level, as in the example, or in all "),a("code",[t._v("oneOf")]),t._v(" subschemas.")]),t._v(" "),a("li",[t._v("each "),a("code",[t._v("oneOf")]),t._v(" subschema must have "),a("a",{attrs:{href:"#properties"}},[t._v("properties")]),t._v(" keyword with discriminator property. The subschemas should be either inlined or included as direct references (only "),a("code",[t._v("$ref")]),t._v(" keyword without any extra keywords is allowed).")]),t._v(" "),a("li",[t._v("schema for discriminator property in each "),a("code",[t._v("oneOf")]),t._v(" subschema must be "),a("a",{attrs:{href:"#const"}},[t._v("const")]),t._v(" or "),a("a",{attrs:{href:"#enum"}},[t._v("enum")]),t._v(", with unique values across all subschemas.")])]),t._v(" "),a("p",[t._v("Not meeting any of these requirements would fail schema compilation.")]),t._v(" "),a("h2",{attrs:{id:"keywords-for-all-types"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#keywords-for-all-types"}},[t._v("#")]),t._v(" Keywords for all types")]),t._v(" "),a("h3",{attrs:{id:"enum"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#enum"}},[t._v("#")]),t._v(" "),a("code",[t._v("enum")])]),t._v(" "),a("p",[t._v("The value of the keyword should be an array of unique items of any types. The data is valid if it is deeply equal to one of items in the array.")]),t._v(" "),a("p",[a("strong",[t._v("Example")])]),t._v(" "),a("p",[a("em",[t._v("schema")]),t._v(": "),a("code",[t._v('{enum: [2, "foo", {foo: "bar" }, [1, 2, 3]]}')])]),t._v(" "),a("p",[a("em",[t._v("valid")]),t._v(": "),a("code",[t._v("2")]),t._v(", "),a("code",[t._v('"foo"')]),t._v(", "),a("code",[t._v('{foo: "bar"}')]),t._v(", "),a("code",[t._v("[1, 2, 3]")])]),t._v(" "),a("p",[a("em",[t._v("invalid")]),t._v(": "),a("code",[t._v("1")]),t._v(", "),a("code",[t._v('"bar"')]),t._v(", "),a("code",[t._v('{foo: "baz"}')]),t._v(", "),a("code",[t._v("[1, 2, 3, 4]")]),t._v(", any value not in enum")]),t._v(" "),a("h3",{attrs:{id:"const"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#const"}},[t._v("#")]),t._v(" "),a("code",[t._v("const")])]),t._v(" "),a("p",[t._v("The value of this keyword can be anything. The data is valid if it is deeply equal to the value of the keyword.")]),t._v(" "),a("p",[a("strong",[t._v("Example")])]),t._v(" "),a("p",[a("em",[t._v("schema")]),t._v(": "),a("code",[t._v('{const: "foo"}')])]),t._v(" "),a("p",[a("em",[t._v("valid")]),t._v(": "),a("code",[t._v('"foo"')])]),t._v(" "),a("p",[a("em",[t._v("invalid")]),t._v(": any other value")]),t._v(" "),a("p",[t._v("The same can be achieved with "),a("code",[t._v("enum")]),t._v(" keyword using the array with one item. But "),a("code",[t._v("const")]),t._v(" keyword is more than just a syntax sugar for "),a("code",[t._v("enum")]),t._v(". In combination with the "),a("RouterLink",{attrs:{to:"/guide/combining-schemas.html#data-reference"}},[t._v("$data reference")]),t._v(" it allows to define equality relations between different parts of the data. This cannot be achieved with "),a("code",[t._v("enum")]),t._v(" keyword even with "),a("code",[t._v("$data")]),t._v(" reference because "),a("code",[t._v("$data")]),t._v(" cannot be used in place of one item - it can only be used in place of the whole array in "),a("code",[t._v("enum")]),t._v(" keyword.")],1),t._v(" "),a("p",[a("strong",[t._v("Example")])]),t._v(" "),a("p",[a("em",[t._v("schema")]),t._v(":")]),t._v(" "),a("div",{staticClass:"language-javascript extra-class"},[a("pre",{pre:!0,attrs:{class:"language-javascript"}},[a("code",[a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"object"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("properties")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("foo")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"number"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("bar")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("$data")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"1/foo"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])]),a("p",[a("em",[t._v("valid")]),t._v(": "),a("code",[t._v("{foo: 1, bar: 1}")]),t._v(", "),a("code",[t._v("{}")])]),t._v(" "),a("p",[a("em",[t._v("invalid")]),t._v(": "),a("code",[t._v("{foo: 1}")]),t._v(", "),a("code",[t._v("{bar: 1}")]),t._v(", "),a("code",[t._v("{foo: 1, bar: 2}")])]),t._v(" "),a("h2",{attrs:{id:"compound-keywords"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#compound-keywords"}},[t._v("#")]),t._v(" Compound keywords")]),t._v(" "),a("h3",{attrs:{id:"not"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#not"}},[t._v("#")]),t._v(" "),a("code",[t._v("not")])]),t._v(" "),a("p",[t._v("The value of the keyword should be a JSON Schema. The data is valid if it is invalid according to this schema.")]),t._v(" "),a("p",[a("strong",[t._v("Example")])]),t._v(" "),a("p",[a("em",[t._v("schema")]),t._v(": "),a("code",[t._v('{type: "number", not: {minimum: 3}}')])]),t._v(" "),a("p",[a("em",[t._v("valid")]),t._v(": "),a("code",[t._v("1")]),t._v(", "),a("code",[t._v("2")])]),t._v(" "),a("p",[a("em",[t._v("invalid")]),t._v(": "),a("code",[t._v("3")]),t._v(", "),a("code",[t._v("4")])]),t._v(" "),a("h3",{attrs:{id:"oneof"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#oneof"}},[t._v("#")]),t._v(" "),a("code",[t._v("oneOf")])]),t._v(" "),a("p",[t._v("The value of the keyword should be an array of JSON Schemas. The data is valid if it matches exactly one JSON Schema from this array. Validators have to validate data against all schemas to establish validity according to this keyword.")]),t._v(" "),a("p",[a("strong",[t._v("Example")])]),t._v(" "),a("p",[a("em",[t._v("schema")]),t._v(":")]),t._v(" "),a("div",{staticClass:"language-javascript extra-class"},[a("pre",{pre:!0,attrs:{class:"language-javascript"}},[a("code",[a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"number"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("oneOf")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("maximum")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("3")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"integer"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])]),a("p",[a("em",[t._v("valid")]),t._v(": "),a("code",[t._v("1.5")]),t._v(", "),a("code",[t._v("2.5")]),t._v(", "),a("code",[t._v("4")]),t._v(", "),a("code",[t._v("5")])]),t._v(" "),a("p",[a("em",[t._v("invalid")]),t._v(": "),a("code",[t._v("2")]),t._v(", "),a("code",[t._v("3")]),t._v(", "),a("code",[t._v("4.5")]),t._v(", "),a("code",[t._v("5.5")])]),t._v(" "),a("h3",{attrs:{id:"anyof"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#anyof"}},[t._v("#")]),t._v(" "),a("code",[t._v("anyOf")])]),t._v(" "),a("p",[t._v('The value of the keyword should be an array of JSON Schemas. The data is valid if it is valid according to one or more JSON Schemas in this array. Validators only need to validate data against schemas in order until the first schema matches (or until all schemas have been tried). For this reason validating against this keyword is faster than against "oneOf" keyword in most cases.')]),t._v(" "),a("p",[a("strong",[t._v("Example")])]),t._v(" "),a("p",[a("em",[t._v("schema")]),t._v(":")]),t._v(" "),a("div",{staticClass:"language-javascript extra-class"},[a("pre",{pre:!0,attrs:{class:"language-javascript"}},[a("code",[a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"number"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("anyOf")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("maximum")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("3")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"integer"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])]),a("p",[a("em",[t._v("valid")]),t._v(": "),a("code",[t._v("1.5")]),t._v(", "),a("code",[t._v("2")]),t._v(", "),a("code",[t._v("2.5")]),t._v(", "),a("code",[t._v("3")]),t._v(", "),a("code",[t._v("4")]),t._v(", "),a("code",[t._v("5")])]),t._v(" "),a("p",[a("em",[t._v("invalid")]),t._v(": "),a("code",[t._v("4.5")]),t._v(", "),a("code",[t._v("5.5")])]),t._v(" "),a("h3",{attrs:{id:"allof"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#allof"}},[t._v("#")]),t._v(" "),a("code",[t._v("allOf")])]),t._v(" "),a("p",[t._v("The value of the keyword should be an array of JSON Schemas. The data is valid if it is valid according to all JSON Schemas in this array.")]),t._v(" "),a("p",[a("strong",[t._v("Example")])]),t._v(" "),a("p",[a("em",[t._v("schema")]),t._v(":")]),t._v(" "),a("div",{staticClass:"language-javascript extra-class"},[a("pre",{pre:!0,attrs:{class:"language-javascript"}},[a("code",[a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"number"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("allOf")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("maximum")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("3")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"integer"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])]),a("p",[a("em",[t._v("valid")]),t._v(": "),a("code",[t._v("2")]),t._v(", "),a("code",[t._v("3")])]),t._v(" "),a("p",[a("em",[t._v("invalid")]),t._v(": "),a("code",[t._v("1.5")]),t._v(", "),a("code",[t._v("2.5")]),t._v(", "),a("code",[t._v("4")]),t._v(", "),a("code",[t._v("4.5")]),t._v(", "),a("code",[t._v("5")]),t._v(", "),a("code",[t._v("5.5")])]),t._v(" "),a("h3",{attrs:{id:"if-then-else"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#if-then-else"}},[t._v("#")]),t._v(" "),a("code",[t._v("if")]),t._v("/"),a("code",[t._v("then")]),t._v("/"),a("code",[t._v("else")])]),t._v(" "),a("p",[t._v("These keywords allow to implement conditional validation. Their values should be valid JSON Schemas (object or boolean).")]),t._v(" "),a("p",[t._v("If "),a("code",[t._v("if")]),t._v(" keyword is absent, the validation succeeds.")]),t._v(" "),a("p",[t._v("If the data is valid against the sub-schema in "),a("code",[t._v("if")]),t._v(" keyword, then the validation result is equal to the result of data validation against the sub-schema in "),a("code",[t._v("then")]),t._v(" keyword (if "),a("code",[t._v("then")]),t._v(" is absent, the validation succeeds).")]),t._v(" "),a("p",[t._v("If the data is invalid against the sub-schema in "),a("code",[t._v("if")]),t._v(" keyword, then the validation result is equal to the result of data validation against the sub-schema in "),a("code",[t._v("else")]),t._v(" keyword (if "),a("code",[t._v("else")]),t._v(" is absent, the validation succeeds).")]),t._v(" "),a("p",[a("strong",[t._v("Examples")])]),t._v(" "),a("ol",[a("li",[a("p",[a("em",[t._v("schema")]),t._v(":")]),t._v(" "),a("div",{staticClass:"language-javascript extra-class"},[a("pre",{pre:!0,attrs:{class:"language-javascript"}},[a("code",[a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"object"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("if")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("properties")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("foo")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("minimum")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("10")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("then")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("required")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"bar"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("else")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("required")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"baz"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])]),a("p",[a("em",[t._v("valid")]),t._v(":")]),t._v(" "),a("ul",[a("li",[a("code",[t._v("{foo: 10, bar: true }")])]),t._v(" "),a("li",[a("code",[t._v("{}")])]),t._v(" "),a("li",[a("code",[t._v("{foo: 1, baz: true }")])])]),t._v(" "),a("p",[a("em",[t._v("invalid")]),t._v(":")]),t._v(" "),a("ul",[a("li",[a("code",[t._v("{foo: 10}")]),t._v(" ("),a("code",[t._v("bar")]),t._v(" is required)")]),t._v(" "),a("li",[a("code",[t._v("{foo: 10, baz: true }")]),t._v(" ("),a("code",[t._v("bar")]),t._v(" is required)")]),t._v(" "),a("li",[a("code",[t._v("{foo: 1}")]),t._v(" ("),a("code",[t._v("baz")]),t._v(" is required)")])])])]),t._v(" "),a("ol",{attrs:{start:"2"}},[a("li",[a("p",[a("em",[t._v("schema")]),t._v(":")]),t._v(" "),a("div",{staticClass:"language-javascript extra-class"},[a("pre",{pre:!0,attrs:{class:"language-javascript"}},[a("code",[a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"integer"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("minimum")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("1")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("maximum")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("1000")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("if")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("minimum")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("100")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("then")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("multipleOf")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("100")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("else")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("if")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("minimum")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("10")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("then")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("multipleOf")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("10")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])]),a("p",[a("em",[t._v("valid")]),t._v(": "),a("code",[t._v("1")]),t._v(", "),a("code",[t._v("5")]),t._v(", "),a("code",[t._v("10")]),t._v(", "),a("code",[t._v("20")]),t._v(", "),a("code",[t._v("50")]),t._v(", "),a("code",[t._v("100")]),t._v(", "),a("code",[t._v("200")]),t._v(", "),a("code",[t._v("500")]),t._v(", "),a("code",[t._v("1000")])]),t._v(" "),a("p",[a("em",[t._v("invalid")]),t._v(":")]),t._v(" "),a("ul",[a("li",[a("code",[t._v("-1")]),t._v(", "),a("code",[t._v("0")]),t._v(" (<1)")]),t._v(" "),a("li",[a("code",[t._v("2000")]),t._v(" (>1000)")]),t._v(" "),a("li",[a("code",[t._v("11")]),t._v(", "),a("code",[t._v("57")]),t._v(", "),a("code",[t._v("123")]),t._v(" (any integer with more than one non-zero digit)")]),t._v(" "),a("li",[t._v("non-integers")])])])]),t._v(" "),a("h2",{attrs:{id:"metadata-keywords"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#metadata-keywords"}},[t._v("#")]),t._v(" Metadata keywords")]),t._v(" "),a("p",[t._v("JSON Schema specification defines several metadata keywords that describe the schema itself but do not perform any validation.")]),t._v(" "),a("ul",[a("li",[a("code",[t._v("title")]),t._v(" and "),a("code",[t._v("description")]),t._v(": information about the data represented by that schema")]),t._v(" "),a("li",[a("code",[t._v("$comment")]),t._v(": information for developers. With option "),a("code",[t._v("$comment")]),t._v(" Ajv logs or passes the comment string to the user-supplied function. See "),a("RouterLink",{attrs:{to:"/api.html#options"}},[t._v("Options")]),t._v(".")],1),t._v(" "),a("li",[a("code",[t._v("default")]),t._v(": a default value of the data instance, see "),a("RouterLink",{attrs:{to:"/guide/modifying-data.html#assigning-defaults"}},[t._v("Assigning defaults")]),t._v(".")],1),t._v(" "),a("li",[a("code",[t._v("examples")]),t._v(": an array of data instances. Ajv does not check the validity of these instances against the schema.")]),t._v(" "),a("li",[a("code",[t._v("readOnly")]),t._v(" and "),a("code",[t._v("writeOnly")]),t._v(": marks data-instance as read-only or write-only in relation to the source of the data (database, api, etc.).")]),t._v(" "),a("li",[a("code",[t._v("contentEncoding")]),t._v(": "),a("a",{attrs:{href:"https://tools.ietf.org/html/rfc2045#section-6.1",target:"_blank",rel:"noopener noreferrer"}},[t._v("RFC 2045"),a("OutboundLink")],1),t._v(', e.g., "base64".')]),t._v(" "),a("li",[a("code",[t._v("contentMediaType")]),t._v(": "),a("a",{attrs:{href:"https://datatracker.ietf.org/doc/rfc2046/",target:"_blank",rel:"noopener noreferrer"}},[t._v("RFC 2046"),a("OutboundLink")],1),t._v(', e.g., "image/png".')])]),t._v(" "),a("div",{staticClass:"custom-block warning"},[a("p",{staticClass:"custom-block-title"},[t._v("Ignored keywords")]),t._v(" "),a("p",[t._v("Ajv does not implement validation of the keywords "),a("code",[t._v("examples")]),t._v(", "),a("code",[t._v("contentEncoding")]),t._v(" and "),a("code",[t._v("contentMediaType")]),t._v(" but it reserves them. If you want to create a plugin that implements any of them, it should remove these keywords from the instance.")])])],1)}),[],!1,null,null,null);a.default=r.exports}}]); \ No newline at end of file diff --git a/assets/js/66.60785931.js b/assets/js/66.60785931.js new file mode 100644 index 000000000..34f1d2bbc --- /dev/null +++ b/assets/js/66.60785931.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[66],{412:function(e,t,r){"use strict";r.r(t);var o=r(14),n=Object(o.a)({},(function(){var e=this,t=e._self._c;return t("ContentSlotsDistributor",{attrs:{"slot-key":e.$parent.slotKey}},[t("p",[t("a",{attrs:{href:"https://www.mozilla.org/en-US/moss/",target:"_blank",rel:"noopener noreferrer"}},[t("img",{attrs:{src:"/img/mozilla.svg",width:"240",height:"68"}}),t("OutboundLink")],1),t("img",{attrs:{src:"/img/gap.svg",width:"5%"}}),t("a",{attrs:{href:"https://openjsf.org/blog/2020/08/14/ajv-joins-openjs-foundation-as-an-incubation-project/",target:"_blank",rel:"noopener noreferrer"}},[t("img",{attrs:{src:"/img/openjs.png",width:"220",height:"68"}}),t("OutboundLink")],1)]),e._v(" "),t("p",[e._v("Ajv has been awarded a grant from Mozilla’s "),t("a",{attrs:{href:"https://www.mozilla.org/en-US/moss/",target:"_blank",rel:"noopener noreferrer"}},[e._v("Open Source Support (MOSS) program"),t("OutboundLink")],1),e._v(" in the “Foundational Technology” track! It will sponsor the development of Ajv support of "),t("a",{attrs:{href:"https://tools.ietf.org/html/draft-handrews-json-schema-02",target:"_blank",rel:"noopener noreferrer"}},[e._v("JSON Schema version 2019-09"),t("OutboundLink")],1),e._v(" and of "),t("a",{attrs:{href:"https://datatracker.ietf.org/doc/rfc8927/",target:"_blank",rel:"noopener noreferrer"}},[e._v("JSON Type Definition (RFC8927)"),t("OutboundLink")],1),e._v(".")]),e._v(" "),t("p",[e._v("Ajv also joined "),t("a",{attrs:{href:"https://openjsf.org/",target:"_blank",rel:"noopener noreferrer"}},[e._v("OpenJS Foundation"),t("OutboundLink")],1),e._v(" – having this support will help ensure the longevity and stability of Ajv for all its users.")]),e._v(" "),t("p",[e._v("This "),t("a",{attrs:{href:"https://www.poberezkin.com/posts/2020-08-14-ajv-json-validator-mozilla-open-source-grant-openjs-foundation.html",target:"_blank",rel:"noopener noreferrer"}},[e._v("blog post"),t("OutboundLink")],1),e._v(" has more details.")]),e._v(" "),t("p",[e._v("I am looking for the long term maintainers of Ajv – working with "),t("a",{attrs:{href:"https://www.thereadyset.co/",target:"_blank",rel:"noopener noreferrer"}},[e._v("ReadySet"),t("OutboundLink")],1),e._v(', also sponsored by Mozilla, to establish clear guidelines for the role of a "maintainer" and the contribution standards, and to encourage a wider, more inclusive, contribution from the community.')])])}),[],!1,null,null,null);t.default=n.exports}}]); \ No newline at end of file diff --git a/assets/js/78.32c4a672.js b/assets/js/78.32c4a672.js new file mode 100644 index 000000000..69a947b3c --- /dev/null +++ b/assets/js/78.32c4a672.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[78],{430:function(t,a,e){"use strict";e.r(a);var s=e(14),r=Object(s.a)({},(function(){var t=this,a=t._self._c;return a("ContentSlotsDistributor",{attrs:{"slot-key":t.$parent.slotKey}},[a("p",[a("a",{attrs:{href:"https://github.com/ajv-validator/ajv-formats",target:"_blank",rel:"noopener noreferrer"}},[t._v("ajv-formats repository"),a("OutboundLink")],1)]),t._v(" "),a("h1",{attrs:{id:"ajv-formats"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#ajv-formats"}},[t._v("#")]),t._v(" ajv-formats")]),t._v(" "),a("p",[t._v("JSON Schema formats for Ajv")]),t._v(" "),a("p",[a("a",{attrs:{href:"https://travis-ci.org/ajv-validator/ajv-formats",target:"_blank",rel:"noopener noreferrer"}},[a("img",{attrs:{src:"https://travis-ci.org/ajv-validator/ajv-formats.svg?branch=master",alt:"Build Status"}}),a("OutboundLink")],1),t._v(" "),a("a",{attrs:{href:"https://www.npmjs.com/package/ajv-formats",target:"_blank",rel:"noopener noreferrer"}},[a("img",{attrs:{src:"https://img.shields.io/npm/v/ajv-formats.svg",alt:"npm"}}),a("OutboundLink")],1),t._v(" "),a("a",{attrs:{href:"https://gitter.im/ajv-validator/ajv",target:"_blank",rel:"noopener noreferrer"}},[a("img",{attrs:{src:"https://img.shields.io/gitter/room/ajv-validator/ajv.svg",alt:"Gitter"}}),a("OutboundLink")],1),t._v(" "),a("a",{attrs:{href:"https://github.com/sponsors/epoberezkin",target:"_blank",rel:"noopener noreferrer"}},[a("img",{attrs:{src:"https://img.shields.io/badge/$-sponsors-brightgreen",alt:"GitHub Sponsors"}}),a("OutboundLink")],1)]),t._v(" "),a("h2",{attrs:{id:"usage"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#usage"}},[t._v("#")]),t._v(" Usage")]),t._v(" "),a("div",{staticClass:"language-javascript extra-class"},[a("pre",{pre:!0,attrs:{class:"language-javascript"}},[a("code",[a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// ESM/TypeScript import")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("import")]),t._v(" Ajv "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("from")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"ajv"')]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("import")]),t._v(" addFormats "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("from")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"ajv-formats"')]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// Node.js require:")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" Ajv "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("require")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"ajv"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" addFormats "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("require")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"ajv-formats"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n\n"),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" ajv "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("new")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("Ajv")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("addFormats")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("ajv"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n")])])]),a("h2",{attrs:{id:"formats"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#formats"}},[t._v("#")]),t._v(" Formats")]),t._v(" "),a("p",[t._v("The package defines these formats:")]),t._v(" "),a("ul",[a("li",[a("em",[t._v("date")]),t._v(": full-date according to "),a("a",{attrs:{href:"http://tools.ietf.org/html/rfc3339#section-5.6",target:"_blank",rel:"noopener noreferrer"}},[t._v("RFC3339"),a("OutboundLink")],1),t._v(".")]),t._v(" "),a("li",[a("em",[t._v("time")]),t._v(": time (time-zone is mandatory).")]),t._v(" "),a("li",[a("em",[t._v("date-time")]),t._v(": date-time (time-zone is mandatory).")]),t._v(" "),a("li",[a("em",[t._v("iso-time")]),t._v(": time with optional time-zone.")]),t._v(" "),a("li",[a("em",[t._v("iso-date-time")]),t._v(": date-time with optional time-zone.")]),t._v(" "),a("li",[a("em",[t._v("duration")]),t._v(": duration from "),a("a",{attrs:{href:"https://tools.ietf.org/html/rfc3339#appendix-A",target:"_blank",rel:"noopener noreferrer"}},[t._v("RFC3339"),a("OutboundLink")],1)]),t._v(" "),a("li",[a("em",[t._v("uri")]),t._v(": full URI.")]),t._v(" "),a("li",[a("em",[t._v("uri-reference")]),t._v(": URI reference, including full and relative URIs.")]),t._v(" "),a("li",[a("em",[t._v("uri-template")]),t._v(": URI template according to "),a("a",{attrs:{href:"https://tools.ietf.org/html/rfc6570",target:"_blank",rel:"noopener noreferrer"}},[t._v("RFC6570"),a("OutboundLink")],1)]),t._v(" "),a("li",[a("em",[t._v("url")]),t._v(" (deprecated): "),a("a",{attrs:{href:"https://url.spec.whatwg.org/#concept-url",target:"_blank",rel:"noopener noreferrer"}},[t._v("URL record"),a("OutboundLink")],1),t._v(".")]),t._v(" "),a("li",[a("em",[t._v("email")]),t._v(": email address.")]),t._v(" "),a("li",[a("em",[t._v("hostname")]),t._v(": host name according to "),a("a",{attrs:{href:"http://tools.ietf.org/html/rfc1034#section-3.5",target:"_blank",rel:"noopener noreferrer"}},[t._v("RFC1034"),a("OutboundLink")],1),t._v(".")]),t._v(" "),a("li",[a("em",[t._v("ipv4")]),t._v(": IP address v4.")]),t._v(" "),a("li",[a("em",[t._v("ipv6")]),t._v(": IP address v6.")]),t._v(" "),a("li",[a("em",[t._v("regex")]),t._v(": tests whether a string is a valid regular expression by passing it to RegExp constructor.")]),t._v(" "),a("li",[a("em",[t._v("uuid")]),t._v(": Universally Unique IDentifier according to "),a("a",{attrs:{href:"http://tools.ietf.org/html/rfc4122",target:"_blank",rel:"noopener noreferrer"}},[t._v("RFC4122"),a("OutboundLink")],1),t._v(".")]),t._v(" "),a("li",[a("em",[t._v("json-pointer")]),t._v(": JSON-pointer according to "),a("a",{attrs:{href:"https://tools.ietf.org/html/rfc6901",target:"_blank",rel:"noopener noreferrer"}},[t._v("RFC6901"),a("OutboundLink")],1),t._v(".")]),t._v(" "),a("li",[a("em",[t._v("relative-json-pointer")]),t._v(": relative JSON-pointer according to "),a("a",{attrs:{href:"http://tools.ietf.org/html/draft-luff-relative-json-pointer-00",target:"_blank",rel:"noopener noreferrer"}},[t._v("this draft"),a("OutboundLink")],1),t._v(".")]),t._v(" "),a("li",[a("em",[t._v("byte")]),t._v(": base64 encoded data according to the "),a("a",{attrs:{href:"https://spec.openapis.org/oas/v3.0.0#data-types",target:"_blank",rel:"noopener noreferrer"}},[t._v("openApi 3.0.0 specification"),a("OutboundLink")],1)]),t._v(" "),a("li",[a("em",[t._v("int32")]),t._v(": signed 32 bits integer according to the "),a("a",{attrs:{href:"https://spec.openapis.org/oas/v3.0.0#data-types",target:"_blank",rel:"noopener noreferrer"}},[t._v("openApi 3.0.0 specification"),a("OutboundLink")],1)]),t._v(" "),a("li",[a("em",[t._v("int64")]),t._v(": signed 64 bits according to the "),a("a",{attrs:{href:"https://spec.openapis.org/oas/v3.0.0#data-types",target:"_blank",rel:"noopener noreferrer"}},[t._v("openApi 3.0.0 specification"),a("OutboundLink")],1)]),t._v(" "),a("li",[a("em",[t._v("float")]),t._v(": float according to the "),a("a",{attrs:{href:"https://spec.openapis.org/oas/v3.0.0#data-types",target:"_blank",rel:"noopener noreferrer"}},[t._v("openApi 3.0.0 specification"),a("OutboundLink")],1)]),t._v(" "),a("li",[a("em",[t._v("double")]),t._v(": double according to the "),a("a",{attrs:{href:"https://spec.openapis.org/oas/v3.0.0#data-types",target:"_blank",rel:"noopener noreferrer"}},[t._v("openApi 3.0.0 specification"),a("OutboundLink")],1)]),t._v(" "),a("li",[a("em",[t._v("password")]),t._v(": password string according to the "),a("a",{attrs:{href:"https://spec.openapis.org/oas/v3.0.0#data-types",target:"_blank",rel:"noopener noreferrer"}},[t._v("openApi 3.0.0 specification"),a("OutboundLink")],1)]),t._v(" "),a("li",[a("em",[t._v("binary")]),t._v(": binary string according to the "),a("a",{attrs:{href:"https://spec.openapis.org/oas/v3.0.0#data-types",target:"_blank",rel:"noopener noreferrer"}},[t._v("openApi 3.0.0 specification"),a("OutboundLink")],1)])]),t._v(" "),a("p",[t._v("See regular expressions used for format validation and the sources that were used in "),a("a",{attrs:{href:"https://github.com/ajv-validator/ajv-formats/blob/master/src/formats.ts",target:"_blank",rel:"noopener noreferrer"}},[t._v("formats.ts"),a("OutboundLink")],1),t._v(".")]),t._v(" "),a("p",[a("strong",[t._v("Please note")]),t._v(": JSON Schema draft-07 also defines formats "),a("code",[t._v("iri")]),t._v(", "),a("code",[t._v("iri-reference")]),t._v(", "),a("code",[t._v("idn-hostname")]),t._v(" and "),a("code",[t._v("idn-email")]),t._v(" for URLs, hostnames and emails with international characters. These formats are available in "),a("a",{attrs:{href:"https://github.com/luzlab/ajv-formats-draft2019",target:"_blank",rel:"noopener noreferrer"}},[t._v("ajv-formats-draft2019"),a("OutboundLink")],1),t._v(" plugin.")]),t._v(" "),a("h2",{attrs:{id:"keywords-to-compare-values-formatmaximum-formatminimum-and-formatexclusivemaximum-formatexclusiveminimum"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#keywords-to-compare-values-formatmaximum-formatminimum-and-formatexclusivemaximum-formatexclusiveminimum"}},[t._v("#")]),t._v(" Keywords to compare values: "),a("code",[t._v("formatMaximum")]),t._v(" / "),a("code",[t._v("formatMinimum")]),t._v(" and "),a("code",[t._v("formatExclusiveMaximum")]),t._v(" / "),a("code",[t._v("formatExclusiveMinimum")])]),t._v(" "),a("p",[t._v("These keywords allow to define minimum/maximum constraints when the format keyword defines ordering ("),a("code",[t._v("compare")]),t._v(" function in format definition).")]),t._v(" "),a("p",[t._v("These keywords are added to ajv instance when ajv-formats is used without options or with option "),a("code",[t._v("keywords: true")]),t._v(".")]),t._v(" "),a("p",[t._v("These keywords apply only to strings. If the data is not a string, the validation succeeds.")]),t._v(" "),a("p",[t._v("The value of keywords "),a("code",[t._v("formatMaximum")]),t._v("/"),a("code",[t._v("formatMinimum")]),t._v(" and "),a("code",[t._v("formatExclusiveMaximum")]),t._v("/"),a("code",[t._v("formatExclusiveMinimum")]),t._v(" should be a string or "),a("a",{attrs:{href:"https://github.com/ajv-validator/ajv/blob/master/docs/guide/combining-schemas.md#data-reference",target:"_blank",rel:"noopener noreferrer"}},[t._v("$data reference"),a("OutboundLink")],1),t._v(". This value is the maximum (minimum) allowed value for the data to be valid as determined by "),a("code",[t._v("format")]),t._v(" keyword. If "),a("code",[t._v("format")]),t._v(" keyword is not present schema compilation will throw exception.")]),t._v(" "),a("p",[t._v("When these keyword are added, they also add comparison functions to formats "),a("code",[t._v('"date"')]),t._v(", "),a("code",[t._v('"time"')]),t._v(" and "),a("code",[t._v('"date-time"')]),t._v(". User-defined formats also can have comparison functions. See "),a("a",{attrs:{href:"https://github.com/ajv-validator/ajv/blob/master/docs/api.md#api-addformat",target:"_blank",rel:"noopener noreferrer"}},[t._v("addFormat"),a("OutboundLink")],1),t._v(" method.")]),t._v(" "),a("div",{staticClass:"language-javascript extra-class"},[a("pre",{pre:!0,attrs:{class:"language-javascript"}},[a("code",[a("span",{pre:!0,attrs:{class:"token function"}},[t._v("require")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"ajv-formats"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("ajv"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n\n"),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" schema "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"string"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("format")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"date"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("formatMinimum")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"2016-02-06"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("formatExclusiveMaximum")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"2016-12-27"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n\n"),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" validDataList "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"2016-02-06"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"2016-12-26"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),t._v("\n\n"),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" invalidDataList "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"2016-02-05"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"2016-12-27"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"abc"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),t._v("\n")])])]),a("h2",{attrs:{id:"options"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#options"}},[t._v("#")]),t._v(" Options")]),t._v(" "),a("p",[t._v("Options can be passed via the second parameter. Options value can be")]),t._v(" "),a("ol",[a("li",[t._v("The list of format names that will be added to ajv instance:")])]),t._v(" "),a("div",{staticClass:"language-javascript extra-class"},[a("pre",{pre:!0,attrs:{class:"language-javascript"}},[a("code",[a("span",{pre:!0,attrs:{class:"token function"}},[t._v("addFormats")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("ajv"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"date"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"time"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n")])])]),a("p",[a("strong",[t._v("Please note")]),t._v(": when ajv encounters an undefined format it throws exception (unless ajv instance was configured with "),a("code",[t._v("strict: false")]),t._v(" option). To allow specific undefined formats they have to be passed to ajv instance via "),a("code",[t._v("formats")]),t._v(" option with "),a("code",[t._v("true")]),t._v(" value:")]),t._v(" "),a("div",{staticClass:"language-javascript extra-class"},[a("pre",{pre:!0,attrs:{class:"language-javascript"}},[a("code",[a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" ajv "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("new")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("Ajv")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("formats")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("date")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token boolean"}},[t._v("true")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("time")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token boolean"}},[t._v("true")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v('// to ignore "date" and "time" formats in schemas.')]),t._v("\n")])])]),a("ol",{attrs:{start:"2"}},[a("li",[t._v("Format validation mode (default is "),a("code",[t._v('"full"')]),t._v(") with optional list of format names and "),a("code",[t._v("keywords")]),t._v(" option to add additional format comparison keywords:")])]),t._v(" "),a("div",{staticClass:"language-javascript extra-class"},[a("pre",{pre:!0,attrs:{class:"language-javascript"}},[a("code",[a("span",{pre:!0,attrs:{class:"token function"}},[t._v("addFormats")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("ajv"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("mode")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"fast"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n")])])]),a("p",[t._v("or")]),t._v(" "),a("div",{staticClass:"language-javascript extra-class"},[a("pre",{pre:!0,attrs:{class:"language-javascript"}},[a("code",[a("span",{pre:!0,attrs:{class:"token function"}},[t._v("addFormats")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("ajv"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("mode")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"fast"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("formats")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"date"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"time"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("keywords")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token boolean"}},[t._v("true")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n")])])]),a("p",[t._v("In "),a("code",[t._v('"fast"')]),t._v(" mode the following formats are simplified: "),a("code",[t._v('"date"')]),t._v(", "),a("code",[t._v('"time"')]),t._v(", "),a("code",[t._v('"date-time"')]),t._v(", "),a("code",[t._v('"iso-time"')]),t._v(", "),a("code",[t._v('"iso-date-time"')]),t._v(", "),a("code",[t._v('"uri"')]),t._v(", "),a("code",[t._v('"uri-reference"')]),t._v(", "),a("code",[t._v('"email"')]),t._v(". For example, "),a("code",[t._v('"date"')]),t._v(", "),a("code",[t._v('"time"')]),t._v(" and "),a("code",[t._v('"date-time"')]),t._v(" do not validate ranges in "),a("code",[t._v('"fast"')]),t._v(" mode, only string structure, and other formats have simplified regular expressions.")]),t._v(" "),a("h2",{attrs:{id:"tests"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#tests"}},[t._v("#")]),t._v(" Tests")]),t._v(" "),a("div",{staticClass:"language-bash extra-class"},[a("pre",{pre:!0,attrs:{class:"language-bash"}},[a("code",[a("span",{pre:!0,attrs:{class:"token function"}},[t._v("npm")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("install")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("git")]),t._v(" submodule update "),a("span",{pre:!0,attrs:{class:"token parameter variable"}},[t._v("--init")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("npm")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin class-name"}},[t._v("test")]),t._v("\n")])])]),a("h2",{attrs:{id:"license"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#license"}},[t._v("#")]),t._v(" License")]),t._v(" "),a("p",[a("a",{attrs:{href:"https://github.com/ajv-validator/ajv-formats/blob/master/LICENSE",target:"_blank",rel:"noopener noreferrer"}},[t._v("MIT"),a("OutboundLink")],1)])])}),[],!1,null,null,null);a.default=r.exports}}]); \ No newline at end of file diff --git a/assets/js/app.2e5335af.js b/assets/js/app.2e5335af.js new file mode 100644 index 000000000..faac3908c --- /dev/null +++ b/assets/js/app.2e5335af.js @@ -0,0 +1,16 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[0],[]]);!function(e){function t(t){for(var r,a,s=t[0],l=t[1],u=t[2],f=0,p=[];f
'};function o(e,t,n){return en?n:e}function i(e){return 100*(-1+e)}n.configure=function(e){var t,n;for(t in e)void 0!==(n=e[t])&&e.hasOwnProperty(t)&&(r[t]=n);return this},n.status=null,n.set=function(e){var t=n.isStarted();e=o(e,r.minimum,1),n.status=1===e?null:e;var l=n.render(!t),u=l.querySelector(r.barSelector),c=r.speed,f=r.easing;return l.offsetWidth,a((function(t){""===r.positionUsing&&(r.positionUsing=n.getPositioningCSS()),s(u,function(e,t,n){var o;return(o="translate3d"===r.positionUsing?{transform:"translate3d("+i(e)+"%,0,0)"}:"translate"===r.positionUsing?{transform:"translate("+i(e)+"%,0)"}:{"margin-left":i(e)+"%"}).transition="all "+t+"ms "+n,o}(e,c,f)),1===e?(s(l,{transition:"none",opacity:1}),l.offsetWidth,setTimeout((function(){s(l,{transition:"all "+c+"ms linear",opacity:0}),setTimeout((function(){n.remove(),t()}),c)}),c)):setTimeout(t,c)})),this},n.isStarted=function(){return"number"==typeof n.status},n.start=function(){n.status||n.set(0);var e=function(){setTimeout((function(){n.status&&(n.trickle(),e())}),r.trickleSpeed)};return r.trickle&&e(),this},n.done=function(e){return e||n.status?n.inc(.3+.5*Math.random()).set(1):this},n.inc=function(e){var t=n.status;return t?("number"!=typeof e&&(e=(1-t)*o(Math.random()*t,.1,.95)),t=o(t+e,0,.994),n.set(t)):n.start()},n.trickle=function(){return n.inc(Math.random()*r.trickleRate)},e=0,t=0,n.promise=function(r){return r&&"resolved"!==r.state()?(0===t&&n.start(),e++,t++,r.always((function(){0==--t?(e=0,n.done()):n.set((e-t)/e)})),this):this},n.render=function(e){if(n.isRendered())return document.getElementById("nprogress");u(document.documentElement,"nprogress-busy");var t=document.createElement("div");t.id="nprogress",t.innerHTML=r.template;var o,a=t.querySelector(r.barSelector),l=e?"-100":i(n.status||0),c=document.querySelector(r.parent);return s(a,{transition:"all 0 linear",transform:"translate3d("+l+"%,0,0)"}),r.showSpinner||(o=t.querySelector(r.spinnerSelector))&&p(o),c!=document.body&&u(c,"nprogress-custom-parent"),c.appendChild(t),t},n.remove=function(){c(document.documentElement,"nprogress-busy"),c(document.querySelector(r.parent),"nprogress-custom-parent");var e=document.getElementById("nprogress");e&&p(e)},n.isRendered=function(){return!!document.getElementById("nprogress")},n.getPositioningCSS=function(){var e=document.body.style,t="WebkitTransform"in e?"Webkit":"MozTransform"in e?"Moz":"msTransform"in e?"ms":"OTransform"in e?"O":"";return t+"Perspective"in e?"translate3d":t+"Transform"in e?"translate":"margin"};var a=function(){var e=[];function t(){var n=e.shift();n&&n(t)}return function(n){e.push(n),1==e.length&&t()}}(),s=function(){var e=["Webkit","O","Moz","ms"],t={};function n(n){return n=n.replace(/^-ms-/,"ms-").replace(/-([\da-z])/gi,(function(e,t){return t.toUpperCase()})),t[n]||(t[n]=function(t){var n=document.body.style;if(t in n)return t;for(var r,o=e.length,i=t.charAt(0).toUpperCase()+t.slice(1);o--;)if((r=e[o]+i)in n)return r;return t}(n))}function r(e,t,r){t=n(t),e.style[t]=r}return function(e,t){var n,o,i=arguments;if(2==i.length)for(n in t)void 0!==(o=t[n])&&t.hasOwnProperty(n)&&r(e,n,o);else r(e,i[1],i[2])}}();function l(e,t){return("string"==typeof e?e:f(e)).indexOf(" "+t+" ")>=0}function u(e,t){var n=f(e),r=n+t;l(n,t)||(e.className=r.substring(1))}function c(e,t){var n,r=f(e);l(e,t)&&(n=r.replace(" "+t+" "," "),e.className=n.substring(1,n.length-1))}function f(e){return(" "+(e.className||"")+" ").replace(/\s+/gi," ")}function p(e){e&&e.parentNode&&e.parentNode.removeChild(e)}return n})?r.call(t,n,t,e):r)||(e.exports=o)},function(e,t,n){"use strict";var r=n(0),o=n(45).f,i=n(12),a=n(90),s=n(33),l=n(60),u=n(118);e.exports=function(e,t){var n,c,f,p,d,v=e.target,h=e.global,m=e.stat;if(n=h?r:m?r[v]||s(v,{}):r[v]&&r[v].prototype)for(c in t){if(p=t[c],f=e.dontCallGetSet?(d=o(n,c))&&d.value:n[c],!u(h?c:v+(m?".":"#")+c,e.forced)&&void 0!==f){if(typeof p==typeof f)continue;l(p,f)}(e.sham||f&&f.sham)&&i(p,"sham",!0),a(n,c,p,e)}}},function(e,t,n){"use strict";var r=n(25),o=Function.prototype.call;e.exports=r?o.bind(o):function(){return o.apply(o,arguments)}},function(e,t,n){"use strict";var r=n(3);e.exports=!r((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")}))},function(e,t,n){"use strict";e.exports=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}}},function(e,t,n){"use strict";var r=n(46),o=n(28);e.exports=function(e){return r(o(e))}},function(e,t,n){"use strict";var r=n(47),o=TypeError;e.exports=function(e){if(r(e))throw new o("Can't call method on "+e);return e}},function(e,t,n){"use strict";var r=n(0),o=n(1),i=function(e){return o(e)?e:void 0};e.exports=function(e,t){return arguments.length<2?i(r[e]):r[e]&&r[e][t]}},function(e,t,n){"use strict";var r=n(1),o=n(100),i=TypeError;e.exports=function(e){if(r(e))return e;throw new i(o(e)+" is not a function")}},function(e,t,n){"use strict";var r=n(0),o=n(54),i=n(8),a=n(56),s=n(52),l=n(51),u=r.Symbol,c=o("wks"),f=l?u.for||u:u&&u.withoutSetter||a;e.exports=function(e){return i(c,e)||(c[e]=s&&i(u,e)?u[e]:f("Symbol."+e)),c[e]}},function(e,t,n){"use strict";var r=n(55),o=n(0),i=n(33),a=e.exports=o["__core-js_shared__"]||i("__core-js_shared__",{});(a.versions||(a.versions=[])).push({version:"3.37.0",mode:r?"pure":"global",copyright:"© 2014-2024 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.37.0/LICENSE",source:"https://github.com/zloirock/core-js"})},function(e,t,n){"use strict";var r=n(0),o=Object.defineProperty;e.exports=function(e,t){try{o(r,e,{value:t,configurable:!0,writable:!0})}catch(n){r[e]=t}return t}},function(e,t,n){"use strict";var r=n(28),o=Object;e.exports=function(e){return o(r(e))}},function(e,t,n){"use strict";var r=n(115);e.exports=function(e){return r(e.length)}},function(e,t,n){var r=n(142),o=n(10),i=Object.prototype,a=i.hasOwnProperty,s=i.propertyIsEnumerable,l=r(function(){return arguments}())?r:function(e){return o(e)&&a.call(e,"callee")&&!s.call(e,"callee")};e.exports=l},function(e,t,n){var r=n(9)(n(7),"Map");e.exports=r},function(e,t){e.exports=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}},function(e,t,n){var r=n(162),o=n(169),i=n(171),a=n(172),s=n(173);function l(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t-1&&e%1==0&&e<=9007199254740991}},function(e,t,n){var r=n(4),o=n(43),i=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,a=/^\w*$/;e.exports=function(e,t){if(r(e))return!1;var n=typeof e;return!("number"!=n&&"symbol"!=n&&"boolean"!=n&&null!=e&&!o(e))||(a.test(e)||!i.test(e)||null!=t&&e in Object(t))}},function(e,t,n){var r=n(11),o=n(10);e.exports=function(e){return"symbol"==typeof e||o(e)&&"[object Symbol]"==r(e)}},function(e,t){e.exports=function(e){return e}},function(e,t,n){"use strict";var r=n(5),o=n(24),i=n(96),a=n(26),s=n(27),l=n(48),u=n(8),c=n(57),f=Object.getOwnPropertyDescriptor;t.f=r?f:function(e,t){if(e=s(e),t=l(t),c)try{return f(e,t)}catch(e){}if(u(e,t))return a(!o(i.f,e,t),e[t])}},function(e,t,n){"use strict";var r=n(2),o=n(3),i=n(16),a=Object,s=r("".split);e.exports=o((function(){return!a("z").propertyIsEnumerable(0)}))?function(e){return"String"===i(e)?s(e,""):a(e)}:a},function(e,t,n){"use strict";e.exports=function(e){return null==e}},function(e,t,n){"use strict";var r=n(97),o=n(49);e.exports=function(e){var t=r(e,"string");return o(t)?t:t+""}},function(e,t,n){"use strict";var r=n(29),o=n(1),i=n(50),a=n(51),s=Object;e.exports=a?function(e){return"symbol"==typeof e}:function(e){var t=r("Symbol");return o(t)&&i(t.prototype,s(e))}},function(e,t,n){"use strict";var r=n(2);e.exports=r({}.isPrototypeOf)},function(e,t,n){"use strict";var r=n(52);e.exports=r&&!Symbol.sham&&"symbol"==typeof Symbol.iterator},function(e,t,n){"use strict";var r=n(53),o=n(3),i=n(0).String;e.exports=!!Object.getOwnPropertySymbols&&!o((function(){var e=Symbol("symbol detection");return!i(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&r&&r<41}))},function(e,t,n){"use strict";var r,o,i=n(0),a=n(98),s=i.process,l=i.Deno,u=s&&s.versions||l&&l.version,c=u&&u.v8;c&&(o=(r=c.split("."))[0]>0&&r[0]<4?1:+(r[0]+r[1])),!o&&a&&(!(r=a.match(/Edge\/(\d+)/))||r[1]>=74)&&(r=a.match(/Chrome\/(\d+)/))&&(o=+r[1]),e.exports=o},function(e,t,n){"use strict";var r=n(32);e.exports=function(e,t){return r[e]||(r[e]=t||{})}},function(e,t,n){"use strict";e.exports=!1},function(e,t,n){"use strict";var r=n(2),o=0,i=Math.random(),a=r(1..toString);e.exports=function(e){return"Symbol("+(void 0===e?"":e)+")_"+a(++o+i,36)}},function(e,t,n){"use strict";var r=n(5),o=n(3),i=n(102);e.exports=!r&&!o((function(){return 7!==Object.defineProperty(i("div"),"a",{get:function(){return 7}}).a}))},function(e,t,n){"use strict";var r=n(6),o=String,i=TypeError;e.exports=function(e){if(r(e))return e;throw new i(o(e)+" is not an object")}},function(e,t,n){"use strict";e.exports={}},function(e,t,n){"use strict";var r=n(8),o=n(109),i=n(45),a=n(15);e.exports=function(e,t,n){for(var s=o(t),l=a.f,u=i.f,c=0;cc))return!1;var p=l.get(e),d=l.get(t);if(p&&d)return p==t&&d==e;var v=-1,h=!0,m=2&n?new r:void 0;for(l.set(e,t),l.set(t,e);++v-1&&e%1==0&&e]/;e.exports=function(e){var t,n=""+e,o=r.exec(n);if(!o)return n;var i="",a=0,s=0;for(a=o.index;a79&&a<83||!i("reduce")},{reduce:function(e){var t=arguments.length;return o(this,e,t,t>1?arguments[1]:void 0)}})},function(e,t,n){"use strict";var r={}.propertyIsEnumerable,o=Object.getOwnPropertyDescriptor,i=o&&!r.call({1:2},1);t.f=i?function(e){var t=o(this,e);return!!t&&t.enumerable}:r},function(e,t,n){"use strict";var r=n(24),o=n(6),i=n(49),a=n(99),s=n(101),l=n(31),u=TypeError,c=l("toPrimitive");e.exports=function(e,t){if(!o(e)||i(e))return e;var n,l=a(e,c);if(l){if(void 0===t&&(t="default"),n=r(l,e,t),!o(n)||i(n))return n;throw new u("Can't convert object to primitive value")}return void 0===t&&(t="number"),s(e,t)}},function(e,t,n){"use strict";e.exports="undefined"!=typeof navigator&&String(navigator.userAgent)||""},function(e,t,n){"use strict";var r=n(30),o=n(47);e.exports=function(e,t){var n=e[t];return o(n)?void 0:r(n)}},function(e,t,n){"use strict";var r=String;e.exports=function(e){try{return r(e)}catch(e){return"Object"}}},function(e,t,n){"use strict";var r=n(24),o=n(1),i=n(6),a=TypeError;e.exports=function(e,t){var n,s;if("string"===t&&o(n=e.toString)&&!i(s=r(n,e)))return s;if(o(n=e.valueOf)&&!i(s=r(n,e)))return s;if("string"!==t&&o(n=e.toString)&&!i(s=r(n,e)))return s;throw new a("Can't convert object to primitive value")}},function(e,t,n){"use strict";var r=n(0),o=n(6),i=r.document,a=o(i)&&o(i.createElement);e.exports=function(e){return a?i.createElement(e):{}}},function(e,t,n){"use strict";var r=n(5),o=n(3);e.exports=r&&o((function(){return 42!==Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype}))},function(e,t,n){"use strict";var r=n(5),o=n(8),i=Function.prototype,a=r&&Object.getOwnPropertyDescriptor,s=o(i,"name"),l=s&&"something"===function(){}.name,u=s&&(!r||r&&a(i,"name").configurable);e.exports={EXISTS:s,PROPER:l,CONFIGURABLE:u}},function(e,t,n){"use strict";var r=n(2),o=n(1),i=n(32),a=r(Function.toString);o(i.inspectSource)||(i.inspectSource=function(e){return a(e)}),e.exports=i.inspectSource},function(e,t,n){"use strict";var r,o,i,a=n(107),s=n(0),l=n(6),u=n(12),c=n(8),f=n(32),p=n(108),d=n(59),v=s.TypeError,h=s.WeakMap;if(a||f.state){var m=f.state||(f.state=new h);m.get=m.get,m.has=m.has,m.set=m.set,r=function(e,t){if(m.has(e))throw new v("Object already initialized");return t.facade=e,m.set(e,t),t},o=function(e){return m.get(e)||{}},i=function(e){return m.has(e)}}else{var g=p("state");d[g]=!0,r=function(e,t){if(c(e,g))throw new v("Object already initialized");return t.facade=e,u(e,g,t),t},o=function(e){return c(e,g)?e[g]:{}},i=function(e){return c(e,g)}}e.exports={set:r,get:o,has:i,enforce:function(e){return i(e)?o(e):r(e,{})},getterFor:function(e){return function(t){var n;if(!l(t)||(n=o(t)).type!==e)throw new v("Incompatible receiver, "+e+" required");return n}}}},function(e,t,n){"use strict";var r=n(0),o=n(1),i=r.WeakMap;e.exports=o(i)&&/native code/.test(String(i))},function(e,t,n){"use strict";var r=n(54),o=n(56),i=r("keys");e.exports=function(e){return i[e]||(i[e]=o(e))}},function(e,t,n){"use strict";var r=n(29),o=n(2),i=n(110),a=n(117),s=n(58),l=o([].concat);e.exports=r("Reflect","ownKeys")||function(e){var t=i.f(s(e)),n=a.f;return n?l(t,n(e)):t}},function(e,t,n){"use strict";var r=n(111),o=n(116).concat("length","prototype");t.f=Object.getOwnPropertyNames||function(e){return r(e,o)}},function(e,t,n){"use strict";var r=n(2),o=n(8),i=n(27),a=n(112).indexOf,s=n(59),l=r([].push);e.exports=function(e,t){var n,r=i(e),u=0,c=[];for(n in r)!o(s,n)&&o(r,n)&&l(c,n);for(;t.length>u;)o(r,n=t[u++])&&(~a(c,n)||l(c,n));return c}},function(e,t,n){"use strict";var r=n(27),o=n(113),i=n(35),a=function(e){return function(t,n,a){var s=r(t),l=i(s);if(0===l)return!e&&-1;var u,c=o(a,l);if(e&&n!=n){for(;l>c;)if((u=s[c++])!=u)return!0}else for(;l>c;c++)if((e||c in s)&&s[c]===n)return e||c||0;return!e&&-1}};e.exports={includes:a(!0),indexOf:a(!1)}},function(e,t,n){"use strict";var r=n(61),o=Math.max,i=Math.min;e.exports=function(e,t){var n=r(e);return n<0?o(n+t,0):i(n,t)}},function(e,t,n){"use strict";var r=Math.ceil,o=Math.floor;e.exports=Math.trunc||function(e){var t=+e;return(t>0?o:r)(t)}},function(e,t,n){"use strict";var r=n(61),o=Math.min;e.exports=function(e){var t=r(e);return t>0?o(t,9007199254740991):0}},function(e,t,n){"use strict";e.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]},function(e,t,n){"use strict";t.f=Object.getOwnPropertySymbols},function(e,t,n){"use strict";var r=n(3),o=n(1),i=/#|\.prototype\./,a=function(e,t){var n=l[s(e)];return n===c||n!==u&&(o(t)?r(t):!!t)},s=a.normalize=function(e){return String(e).replace(i,".").toLowerCase()},l=a.data={},u=a.NATIVE="N",c=a.POLYFILL="P";e.exports=a},function(e,t,n){"use strict";var r=n(30),o=n(34),i=n(46),a=n(35),s=TypeError,l="Reduce of empty array with no initial value",u=function(e){return function(t,n,u,c){var f=o(t),p=i(f),d=a(f);if(r(n),0===d&&u<2)throw new s(l);var v=e?d-1:0,h=e?-1:1;if(u<2)for(;;){if(v in p){c=p[v],v+=h;break}if(v+=h,e?v<0:d<=v)throw new s(l)}for(;e?v>=0:d>v;v+=h)v in p&&(c=n(c,p[v],v,f));return c}};e.exports={left:u(!1),right:u(!0)}},function(e,t,n){"use strict";var r=n(3);e.exports=function(e,t){var n=[][e];return!!n&&r((function(){n.call(null,t||function(){return 1},1)}))}},function(e,t,n){"use strict";var r=n(0),o=n(16);e.exports="process"===o(r.process)},function(e,t,n){"use strict";var r=n(23),o=n(0),i=n(123),a=n(124),s=o.WebAssembly,l=7!==new Error("e",{cause:7}).cause,u=function(e,t){var n={};n[e]=a(e,t,l),r({global:!0,constructor:!0,arity:1,forced:l},n)},c=function(e,t){if(s&&s[e]){var n={};n[e]=a("WebAssembly."+e,t,l),r({target:"WebAssembly",stat:!0,constructor:!0,arity:1,forced:l},n)}};u("Error",(function(e){return function(t){return i(e,this,arguments)}})),u("EvalError",(function(e){return function(t){return i(e,this,arguments)}})),u("RangeError",(function(e){return function(t){return i(e,this,arguments)}})),u("ReferenceError",(function(e){return function(t){return i(e,this,arguments)}})),u("SyntaxError",(function(e){return function(t){return i(e,this,arguments)}})),u("TypeError",(function(e){return function(t){return i(e,this,arguments)}})),u("URIError",(function(e){return function(t){return i(e,this,arguments)}})),c("CompileError",(function(e){return function(t){return i(e,this,arguments)}})),c("LinkError",(function(e){return function(t){return i(e,this,arguments)}})),c("RuntimeError",(function(e){return function(t){return i(e,this,arguments)}}))},function(e,t,n){"use strict";var r=n(25),o=Function.prototype,i=o.apply,a=o.call;e.exports="object"==typeof Reflect&&Reflect.apply||(r?a.bind(i):function(){return a.apply(i,arguments)})},function(e,t,n){"use strict";var r=n(29),o=n(8),i=n(12),a=n(50),s=n(62),l=n(60),u=n(128),c=n(129),f=n(130),p=n(133),d=n(134),v=n(5),h=n(55);e.exports=function(e,t,n,m){var g=m?2:1,y=e.split("."),b=y[y.length-1],_=r.apply(null,y);if(_){var w=_.prototype;if(!h&&o(w,"cause")&&delete w.cause,!n)return _;var x=r("Error"),j=t((function(e,t){var n=f(m?t:e,void 0),r=m?new _(e):new _;return void 0!==n&&i(r,"message",n),d(r,j,r.stack,2),this&&a(w,this)&&c(r,this,j),arguments.length>g&&p(r,arguments[g]),r}));if(j.prototype=w,"Error"!==b?s?s(j,x):l(j,x,{name:!0}):v&&"stackTraceLimit"in _&&(u(j,_,"stackTraceLimit"),u(j,_,"prepareStackTrace")),l(j,_),!h)try{w.name!==b&&i(w,"name",b),w.constructor=j}catch(e){}return j}}},function(e,t,n){"use strict";var r=n(2),o=n(30);e.exports=function(e,t,n){try{return r(o(Object.getOwnPropertyDescriptor(e,t)[n]))}catch(e){}}},function(e,t,n){"use strict";var r=n(127),o=String,i=TypeError;e.exports=function(e){if(r(e))return e;throw new i("Can't set "+o(e)+" as a prototype")}},function(e,t,n){"use strict";var r=n(6);e.exports=function(e){return r(e)||null===e}},function(e,t,n){"use strict";var r=n(15).f;e.exports=function(e,t,n){n in e||r(e,n,{configurable:!0,get:function(){return t[n]},set:function(e){t[n]=e}})}},function(e,t,n){"use strict";var r=n(1),o=n(6),i=n(62);e.exports=function(e,t,n){var a,s;return i&&r(a=t.constructor)&&a!==n&&o(s=a.prototype)&&s!==n.prototype&&i(e,s),e}},function(e,t,n){"use strict";var r=n(91);e.exports=function(e,t){return void 0===e?arguments.length<2?"":t:r(e)}},function(e,t,n){"use strict";var r=n(132),o=n(1),i=n(16),a=n(31)("toStringTag"),s=Object,l="Arguments"===i(function(){return arguments}());e.exports=r?i:function(e){var t,n,r;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(n=function(e,t){try{return e[t]}catch(e){}}(t=s(e),a))?n:l?i(t):"Object"===(r=i(t))&&o(t.callee)?"Arguments":r}},function(e,t,n){"use strict";var r={};r[n(31)("toStringTag")]="z",e.exports="[object z]"===String(r)},function(e,t,n){"use strict";var r=n(6),o=n(12);e.exports=function(e,t){r(t)&&"cause"in t&&o(e,"cause",t.cause)}},function(e,t,n){"use strict";var r=n(12),o=n(135),i=n(136),a=Error.captureStackTrace;e.exports=function(e,t,n,s){i&&(a?a(e,t):r(e,"stack",o(n,s)))}},function(e,t,n){"use strict";var r=n(2),o=Error,i=r("".replace),a=String(new o("zxcasd").stack),s=/\n\s*at [^:]*:[^\n]*/,l=s.test(a);e.exports=function(e,t){if(l&&"string"==typeof e&&!o.prepareStackTrace)for(;t--;)e=i(e,s,"");return e}},function(e,t,n){"use strict";var r=n(3),o=n(26);e.exports=!r((function(){var e=new Error("a");return!("stack"in e)||(Object.defineProperty(e,"stack",o(1,7)),7!==e.stack)}))},function(e,t,n){"use strict";var r=n(5),o=n(138),i=TypeError,a=Object.getOwnPropertyDescriptor,s=r&&!function(){if(void 0!==this)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(e){return e instanceof TypeError}}();e.exports=s?function(e,t){if(o(e)&&!a(e,"length").writable)throw new i("Cannot set read only .length");return e.length=t}:function(e,t){return e.length=t}},function(e,t,n){"use strict";var r=n(16);e.exports=Array.isArray||function(e){return"Array"===r(e)}},function(e,t,n){"use strict";var r=TypeError;e.exports=function(e){if(e>9007199254740991)throw r("Maximum allowed index exceeded");return e}},function(e,t,n){var r=n(63),o=n(141);e.exports=function e(t,n,i,a,s){var l=-1,u=t.length;for(i||(i=o),s||(s=[]);++l0&&i(c)?n>1?e(c,n-1,i,a,s):r(s,c):a||(s[s.length]=c)}return s}},function(e,t,n){var r=n(13),o=n(36),i=n(4),a=r?r.isConcatSpreadable:void 0;e.exports=function(e){return i(e)||o(e)||!!(a&&e&&e[a])}},function(e,t,n){var r=n(11),o=n(10);e.exports=function(e){return o(e)&&"[object Arguments]"==r(e)}},function(e,t,n){var r=n(13),o=Object.prototype,i=o.hasOwnProperty,a=o.toString,s=r?r.toStringTag:void 0;e.exports=function(e){var t=i.call(e,s),n=e[s];try{e[s]=void 0;var r=!0}catch(e){}var o=a.call(e);return r&&(t?e[s]=n:delete e[s]),o}},function(e,t){var n=Object.prototype.toString;e.exports=function(e){return n.call(e)}},function(e,t,n){var r=n(146),o=n(202),i=n(44),a=n(4),s=n(212);e.exports=function(e){return"function"==typeof e?e:null==e?i:"object"==typeof e?a(e)?o(e[0],e[1]):r(e):s(e)}},function(e,t,n){var r=n(147),o=n(201),i=n(81);e.exports=function(e){var t=o(e);return 1==t.length&&t[0][2]?i(t[0][0],t[0][1]):function(n){return n===e||r(n,e,t)}}},function(e,t,n){var r=n(65),o=n(69);e.exports=function(e,t,n,i){var a=n.length,s=a,l=!i;if(null==e)return!s;for(e=Object(e);a--;){var u=n[a];if(l&&u[2]?u[1]!==e[u[0]]:!(u[0]in e))return!1}for(;++a-1}},function(e,t,n){var r=n(18);e.exports=function(e,t){var n=this.__data__,o=r(n,e);return o<0?(++this.size,n.push([e,t])):n[o][1]=t,this}},function(e,t,n){var r=n(17);e.exports=function(){this.__data__=new r,this.size=0}},function(e,t){e.exports=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}},function(e,t){e.exports=function(e){return this.__data__.get(e)}},function(e,t){e.exports=function(e){return this.__data__.has(e)}},function(e,t,n){var r=n(17),o=n(37),i=n(39);e.exports=function(e,t){var n=this.__data__;if(n instanceof r){var a=n.__data__;if(!o||a.length<199)return a.push([e,t]),this.size=++n.size,this;n=this.__data__=new i(a)}return n.set(e,t),this.size=n.size,this}},function(e,t,n){var r=n(67),o=n(159),i=n(38),a=n(68),s=/^\[object .+?Constructor\]$/,l=Function.prototype,u=Object.prototype,c=l.toString,f=u.hasOwnProperty,p=RegExp("^"+c.call(f).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");e.exports=function(e){return!(!i(e)||o(e))&&(r(e)?p:s).test(a(e))}},function(e,t,n){var r,o=n(160),i=(r=/[^.]+$/.exec(o&&o.keys&&o.keys.IE_PROTO||""))?"Symbol(src)_1."+r:"";e.exports=function(e){return!!i&&i in e}},function(e,t,n){var r=n(7)["__core-js_shared__"];e.exports=r},function(e,t){e.exports=function(e,t){return null==e?void 0:e[t]}},function(e,t,n){var r=n(163),o=n(17),i=n(37);e.exports=function(){this.size=0,this.__data__={hash:new r,map:new(i||o),string:new r}}},function(e,t,n){var r=n(164),o=n(165),i=n(166),a=n(167),s=n(168);function l(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t0){if(++t>=800)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}},function(e,t,n){var r=n(71),o=n(224),i=n(229),a=n(72),s=n(230),l=n(40);e.exports=function(e,t,n){var u=-1,c=o,f=e.length,p=!0,d=[],v=d;if(n)p=!1,c=i;else if(f>=200){var h=t?null:s(e);if(h)return l(h);p=!1,c=a,v=new r}else v=t?[]:d;e:for(;++u-1}},function(e,t,n){var r=n(226),o=n(227),i=n(228);e.exports=function(e,t,n){return t==t?i(e,t,n):r(e,o,n)}},function(e,t){e.exports=function(e,t,n,r){for(var o=e.length,i=n+(r?1:-1);r?i--:++i=0&&Math.floor(t)===t&&isFinite(e)}function h(e){return a(e)&&"function"==typeof e.then&&"function"==typeof e.catch}function m(e){return null==e?"":Array.isArray(e)||p(e)&&e.toString===f?JSON.stringify(e,g,2):String(e)}function g(e,t){return t&&t.__v_isRef?t.value:t}function y(e){var t=parseFloat(e);return isNaN(t)?e:t}function b(e,t){for(var n=Object.create(null),r=e.split(","),o=0;o-1)return e.splice(r,1)}}var x=Object.prototype.hasOwnProperty;function j(e,t){return x.call(e,t)}function k(e){var t=Object.create(null);return function(n){return t[n]||(t[n]=e(n))}}var S=/-(\w)/g,O=k((function(e){return e.replace(S,(function(e,t){return t?t.toUpperCase():""}))})),C=k((function(e){return e.charAt(0).toUpperCase()+e.slice(1)})),P=/\B([A-Z])/g,$=k((function(e){return e.replace(P,"-$1").toLowerCase()}));var E=Function.prototype.bind?function(e,t){return e.bind(t)}:function(e,t){function n(n){var r=arguments.length;return r?r>1?e.apply(t,arguments):e.call(t,n):e.call(t)}return n._length=e.length,n};function A(e,t){t=t||0;for(var n=e.length-t,r=new Array(n);n--;)r[n]=e[n+t];return r}function T(e,t){for(var n in t)e[n]=t[n];return e}function L(e){for(var t={},n=0;n0,Y=Z&&Z.indexOf("edge/")>0;Z&&Z.indexOf("android");var ee=Z&&/iphone|ipad|ipod|ios/.test(Z);Z&&/chrome\/\d+/.test(Z),Z&&/phantomjs/.test(Z);var te,ne=Z&&Z.match(/firefox\/(\d+)/),re={}.watch,oe=!1;if(G)try{var ie={};Object.defineProperty(ie,"passive",{get:function(){oe=!0}}),window.addEventListener("test-passive",null,ie)}catch(e){}var ae=function(){return void 0===te&&(te=!G&&"undefined"!=typeof global&&(global.process&&"server"===global.process.env.VUE_ENV)),te},se=G&&window.__VUE_DEVTOOLS_GLOBAL_HOOK__;function le(e){return"function"==typeof e&&/native code/.test(e.toString())}var ue,ce="undefined"!=typeof Symbol&&le(Symbol)&&"undefined"!=typeof Reflect&&le(Reflect.ownKeys);ue="undefined"!=typeof Set&&le(Set)?Set:function(){function e(){this.set=Object.create(null)}return e.prototype.has=function(e){return!0===this.set[e]},e.prototype.add=function(e){this.set[e]=!0},e.prototype.clear=function(){this.set=Object.create(null)},e}();var fe=null;function pe(e){void 0===e&&(e=null),e||fe&&fe._scope.off(),fe=e,e&&e._scope.on()}var de=function(){function e(e,t,n,r,o,i,a,s){this.tag=e,this.data=t,this.children=n,this.text=r,this.elm=o,this.ns=void 0,this.context=i,this.fnContext=void 0,this.fnOptions=void 0,this.fnScopeId=void 0,this.key=t&&t.key,this.componentOptions=a,this.componentInstance=void 0,this.parent=void 0,this.raw=!1,this.isStatic=!1,this.isRootInsert=!0,this.isComment=!1,this.isCloned=!1,this.isOnce=!1,this.asyncFactory=s,this.asyncMeta=void 0,this.isAsyncPlaceholder=!1}return Object.defineProperty(e.prototype,"child",{get:function(){return this.componentInstance},enumerable:!1,configurable:!0}),e}(),ve=function(e){void 0===e&&(e="");var t=new de;return t.text=e,t.isComment=!0,t};function he(e){return new de(void 0,void 0,void 0,String(e))}function me(e){var t=new de(e.tag,e.data,e.children&&e.children.slice(),e.text,e.elm,e.context,e.componentOptions,e.asyncFactory);return t.ns=e.ns,t.isStatic=e.isStatic,t.key=e.key,t.isComment=e.isComment,t.fnContext=e.fnContext,t.fnOptions=e.fnOptions,t.fnScopeId=e.fnScopeId,t.asyncMeta=e.asyncMeta,t.isCloned=!0,t}"function"==typeof SuppressedError&&SuppressedError;var ge=0,ye=[],be=function(){function e(){this._pending=!1,this.id=ge++,this.subs=[]}return e.prototype.addSub=function(e){this.subs.push(e)},e.prototype.removeSub=function(e){this.subs[this.subs.indexOf(e)]=null,this._pending||(this._pending=!0,ye.push(this))},e.prototype.depend=function(t){e.target&&e.target.addDep(this)},e.prototype.notify=function(e){var t=this.subs.filter((function(e){return e}));for(var n=0,r=t.length;n0&&(Ze((u=e(u,"".concat(n||"","_").concat(r)))[0])&&Ze(f)&&(p[c]=he(f.text+u[0].text),u.shift()),p.push.apply(p,u)):l(u)?Ze(f)?p[c]=he(f.text+u):""!==u&&p.push(he(u)):Ze(u)&&Ze(f)?p[c]=he(f.text+u.text):(s(t._isVList)&&a(u.tag)&&i(u.key)&&a(n)&&(u.key="__vlist".concat(n,"_").concat(r,"__")),p.push(u)));return p}(e):void 0}function Ze(e){return a(e)&&a(e.text)&&!1===e.isComment}function Xe(e,t){var n,r,i,s,l=null;if(o(e)||"string"==typeof e)for(l=new Array(e.length),n=0,r=e.length;n0,s=t?!!t.$stable:!a,l=t&&t.$key;if(t){if(t._normalized)return t._normalized;if(s&&o&&o!==r&&l===o.$key&&!a&&!o.$hasNormal)return o;for(var u in i={},t)t[u]&&"$"!==u[0]&&(i[u]=mt(e,n,u,t[u]))}else i={};for(var c in n)c in i||(i[c]=gt(n,c));return t&&Object.isExtensible(t)&&(t._normalized=i),H(i,"$stable",s),H(i,"$key",l),H(i,"$hasNormal",a),i}function mt(e,t,n,r){var i=function(){var t=fe;pe(e);var n=arguments.length?r.apply(null,arguments):r({}),i=(n=n&&"object"==typeof n&&!o(n)?[n]:Ge(n))&&n[0];return pe(t),n&&(!i||1===n.length&&i.isComment&&!vt(i))?void 0:n};return r.proxy&&Object.defineProperty(t,n,{get:i,enumerable:!0,configurable:!0}),i}function gt(e,t){return function(){return e[t]}}function yt(e){return{get attrs(){if(!e._attrsProxy){var t=e._attrsProxy={};H(t,"_v_attr_proxy",!0),bt(t,e.$attrs,r,e,"$attrs")}return e._attrsProxy},get listeners(){e._listenersProxy||bt(e._listenersProxy={},e.$listeners,r,e,"$listeners");return e._listenersProxy},get slots(){return function(e){e._slotsProxy||wt(e._slotsProxy={},e.$scopedSlots);return e._slotsProxy}(e)},emit:E(e.$emit,e),expose:function(t){t&&Object.keys(t).forEach((function(n){return Ue(e,t,n)}))}}}function bt(e,t,n,r,o){var i=!1;for(var a in t)a in e?t[a]!==n[a]&&(i=!0):(i=!0,_t(e,a,r,o));for(var a in e)a in t||(i=!0,delete e[a]);return i}function _t(e,t,n,r){Object.defineProperty(e,t,{enumerable:!0,configurable:!0,get:function(){return n[r][t]}})}function wt(e,t){for(var n in t)e[n]=t[n];for(var n in e)n in t||delete e[n]}var xt=null;function jt(e,t){return(e.__esModule||ce&&"Module"===e[Symbol.toStringTag])&&(e=e.default),c(e)?t.extend(e):e}function kt(e){if(o(e))for(var t=0;tdocument.createEvent("Event").timeStamp&&(un=function(){return cn.now()})}var fn=function(e,t){if(e.post){if(!t.post)return 1}else if(t.post)return-1;return e.id-t.id};function pn(){var e,t;for(ln=un(),an=!0,tn.sort(fn),sn=0;snsn&&tn[n].id>e.id;)n--;tn.splice(n+1,0,e)}else tn.push(e);on||(on=!0,Ft(pn))}}function vn(e,t){if(e){for(var n=Object.create(null),r=ce?Reflect.ownKeys(e):Object.keys(e),o=0;o-1)if(i&&!j(o,"default"))a=!1;else if(""===a||a===$(e)){var l=Nn(String,o.type);(l<0||s-1:"string"==typeof e?e.split(",").indexOf(t)>-1:!!d(e)&&e.test(t)}function Xn(e,t){var n=e.cache,r=e.keys,o=e._vnode,i=e.$vnode;for(var a in n){var s=n[a];if(s){var l=s.name;l&&!t(l)&&Qn(n,a,r,o)}}i.componentOptions.children=void 0}function Qn(e,t,n,r){var o=e[t];!o||r&&o.tag===r.tag||o.componentInstance.$destroy(),e[t]=null,w(n,t)}Kn.prototype._init=function(e){var t=this;t._uid=Vn++,t._isVue=!0,t.__v_skip=!0,t._scope=new Je(!0),t._scope.parent=void 0,t._scope._vm=!0,e&&e._isComponent?function(e,t){var n=e.$options=Object.create(e.constructor.options),r=t._parentVnode;n.parent=t.parent,n._parentVnode=r;var o=r.componentOptions;n.propsData=o.propsData,n._parentListeners=o.listeners,n._renderChildren=o.children,n._componentTag=o.tag,t.render&&(n.render=t.render,n.staticRenderFns=t.staticRenderFns)}(t,e):t.$options=En(Hn(t.constructor),e||{},t),t._renderProxy=t,t._self=t,function(e){var t=e.$options,n=t.parent;if(n&&!t.abstract){for(;n.$options.abstract&&n.$parent;)n=n.$parent;n.$children.push(e)}e.$parent=n,e.$root=n?n.$root:e,e.$children=[],e.$refs={},e._provided=n?n._provided:Object.create(null),e._watcher=null,e._inactive=null,e._directInactive=!1,e._isMounted=!1,e._isDestroyed=!1,e._isBeingDestroyed=!1}(t),function(e){e._events=Object.create(null),e._hasHookEvent=!1;var t=e.$options._parentListeners;t&&Gt(e,t)}(t),function(e){e._vnode=null,e._staticTrees=null;var t=e.$options,n=e.$vnode=t._parentVnode,o=n&&n.context;e.$slots=pt(t._renderChildren,o),e.$scopedSlots=n?ht(e.$parent,n.data.scopedSlots,e.$slots):r,e._c=function(t,n,r,o){return St(e,t,n,r,o,!1)},e.$createElement=function(t,n,r,o){return St(e,t,n,r,o,!0)};var i=n&&n.data;Te(e,"$attrs",i&&i.attrs||r,null,!0),Te(e,"$listeners",t._parentListeners||r,null,!0)}(t),en(t,"beforeCreate",void 0,!1),function(e){var t=vn(e.$options.inject,e);t&&(Pe(!1),Object.keys(t).forEach((function(n){Te(e,n,t[n])})),Pe(!0))}(t),Fn(t),function(e){var t=e.$options.provide;if(t){var n=u(t)?t.call(e):t;if(!c(n))return;for(var r=Be(e),o=ce?Reflect.ownKeys(n):Object.keys(n),i=0;i1?A(n):n;for(var r=A(arguments,1),o='event handler for "'.concat(e,'"'),i=0,a=n.length;iparseInt(this.max)&&Qn(e,t[0],t,this._vnode),this.vnodeToCache=null}}},created:function(){this.cache=Object.create(null),this.keys=[]},destroyed:function(){for(var e in this.cache)Qn(this.cache,e,this.keys)},mounted:function(){var e=this;this.cacheVNode(),this.$watch("include",(function(t){Xn(e,(function(e){return Zn(t,e)}))})),this.$watch("exclude",(function(t){Xn(e,(function(e){return!Zn(t,e)}))}))},updated:function(){this.cacheVNode()},render:function(){var e=this.$slots.default,t=kt(e),n=t&&t.componentOptions;if(n){var r=Gn(n),o=this.include,i=this.exclude;if(o&&(!r||!Zn(o,r))||i&&r&&Zn(i,r))return t;var a=this.cache,s=this.keys,l=null==t.key?n.Ctor.cid+(n.tag?"::".concat(n.tag):""):t.key;a[l]?(t.componentInstance=a[l].componentInstance,w(s,l),s.push(l)):(this.vnodeToCache=t,this.keyToCache=l),t.data.keepAlive=!0}return t||e&&e[0]}}};!function(e){var t={get:function(){return B}};Object.defineProperty(e,"config",t),e.util={warn:jn,extend:T,mergeOptions:En,defineReactive:Te},e.set=Le,e.delete=Re,e.nextTick=Ft,e.observable=function(e){return Ae(e),e},e.options=Object.create(null),z.forEach((function(t){e.options[t+"s"]=Object.create(null)})),e.options._base=e,T(e.options.components,er),function(e){e.use=function(e){var t=this._installedPlugins||(this._installedPlugins=[]);if(t.indexOf(e)>-1)return this;var n=A(arguments,1);return n.unshift(this),u(e.install)?e.install.apply(e,n):u(e)&&e.apply(null,n),t.push(e),this}}(e),function(e){e.mixin=function(e){return this.options=En(this.options,e),this}}(e),Wn(e),function(e){z.forEach((function(t){e[t]=function(e,n){return n?("component"===t&&p(n)&&(n.name=n.name||e,n=this.options._base.extend(n)),"directive"===t&&u(n)&&(n={bind:n,update:n}),this.options[t+"s"][e]=n,n):this.options[t+"s"][e]}}))}(e)}(Kn),Object.defineProperty(Kn.prototype,"$isServer",{get:ae}),Object.defineProperty(Kn.prototype,"$ssrContext",{get:function(){return this.$vnode&&this.$vnode.ssrContext}}),Object.defineProperty(Kn,"FunctionalRenderContext",{value:hn}),Kn.version="2.7.16";var tr=b("style,class"),nr=b("input,textarea,option,select,progress"),rr=b("contenteditable,draggable,spellcheck"),or=b("events,caret,typing,plaintext-only"),ir=b("allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,default,defaultchecked,defaultmuted,defaultselected,defer,disabled,enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,required,reversed,scoped,seamless,selected,sortable,truespeed,typemustmatch,visible"),ar="http://www.w3.org/1999/xlink",sr=function(e){return":"===e.charAt(5)&&"xlink"===e.slice(0,5)},lr=function(e){return sr(e)?e.slice(6,e.length):""},ur=function(e){return null==e||!1===e};function cr(e){for(var t=e.data,n=e,r=e;a(r.componentInstance);)(r=r.componentInstance._vnode)&&r.data&&(t=fr(r.data,t));for(;a(n=n.parent);)n&&n.data&&(t=fr(t,n.data));return function(e,t){if(a(e)||a(t))return pr(e,dr(t));return""}(t.staticClass,t.class)}function fr(e,t){return{staticClass:pr(e.staticClass,t.staticClass),class:a(e.class)?[e.class,t.class]:t.class}}function pr(e,t){return e?t?e+" "+t:e:t||""}function dr(e){return Array.isArray(e)?function(e){for(var t,n="",r=0,o=e.length;r-1?Ir(e,t,n):ir(t)?ur(n)?e.removeAttribute(t):(n="allowfullscreen"===t&&"EMBED"===e.tagName?"true":t,e.setAttribute(t,n)):rr(t)?e.setAttribute(t,function(e,t){return ur(t)||"false"===t?"false":"contenteditable"===e&&or(t)?t:"true"}(t,n)):sr(t)?ur(n)?e.removeAttributeNS(ar,lr(t)):e.setAttributeNS(ar,t,n):Ir(e,t,n)}function Ir(e,t,n){if(ur(n))e.removeAttribute(t);else{if(X&&!Q&&"TEXTAREA"===e.tagName&&"placeholder"===t&&""!==n&&!e.__ieph){var r=function(t){t.stopImmediatePropagation(),e.removeEventListener("input",r)};e.addEventListener("input",r),e.__ieph=!0}e.setAttribute(t,n)}}var Dr={create:Mr,update:Mr};function Fr(e,t){var n=t.elm,r=t.data,o=e.data;if(!(i(r.staticClass)&&i(r.class)&&(i(o)||i(o.staticClass)&&i(o.class)))){var s=cr(t),l=n._transitionClasses;a(l)&&(s=pr(s,dr(l))),s!==n._prevClass&&(n.setAttribute("class",s),n._prevClass=s)}}var Ur,zr={create:Fr,update:Fr};function Jr(e,t,n){var r=Ur;return function o(){var i=t.apply(null,arguments);null!==i&&Vr(e,o,n,r)}}var Br=At&&!(ne&&Number(ne[1])<=53);function qr(e,t,n,r){if(Br){var o=ln,i=t;t=i._wrapper=function(e){if(e.target===e.currentTarget||e.timeStamp>=o||e.timeStamp<=0||e.target.ownerDocument!==document)return i.apply(this,arguments)}}Ur.addEventListener(e,t,oe?{capture:n,passive:r}:n)}function Vr(e,t,n,r){(r||Ur).removeEventListener(e,t._wrapper||t,n)}function Hr(e,t){if(!i(e.data.on)||!i(t.data.on)){var n=t.data.on||{},r=e.data.on||{};Ur=t.elm||e.elm,function(e){if(a(e.__r)){var t=X?"change":"input";e[t]=[].concat(e.__r,e[t]||[]),delete e.__r}a(e.__c)&&(e.change=[].concat(e.__c,e.change||[]),delete e.__c)}(n),He(n,r,qr,Vr,Jr,t.context),Ur=void 0}}var Kr,Wr={create:Hr,update:Hr,destroy:function(e){return Hr(e,kr)}};function Gr(e,t){if(!i(e.data.domProps)||!i(t.data.domProps)){var n,r,o=t.elm,l=e.data.domProps||{},u=t.data.domProps||{};for(n in(a(u.__ob__)||s(u._v_attr_proxy))&&(u=t.data.domProps=T({},u)),l)n in u||(o[n]="");for(n in u){if(r=u[n],"textContent"===n||"innerHTML"===n){if(t.children&&(t.children.length=0),r===l[n])continue;1===o.childNodes.length&&o.removeChild(o.childNodes[0])}if("value"===n&&"PROGRESS"!==o.tagName){o._value=r;var c=i(r)?"":String(r);Zr(o,c)&&(o.value=c)}else if("innerHTML"===n&&mr(o.tagName)&&i(o.innerHTML)){(Kr=Kr||document.createElement("div")).innerHTML="".concat(r,"");for(var f=Kr.firstChild;o.firstChild;)o.removeChild(o.firstChild);for(;f.firstChild;)o.appendChild(f.firstChild)}else if(r!==l[n])try{o[n]=r}catch(e){}}}}function Zr(e,t){return!e.composing&&("OPTION"===e.tagName||function(e,t){var n=!0;try{n=document.activeElement!==e}catch(e){}return n&&e.value!==t}(e,t)||function(e,t){var n=e.value,r=e._vModifiers;if(a(r)){if(r.number)return y(n)!==y(t);if(r.trim)return n.trim()!==t.trim()}return n!==t}(e,t))}var Xr={create:Gr,update:Gr},Qr=k((function(e){var t={},n=/:(.+)/;return e.split(/;(?![^(]*\))/g).forEach((function(e){if(e){var r=e.split(n);r.length>1&&(t[r[0].trim()]=r[1].trim())}})),t}));function Yr(e){var t=eo(e.style);return e.staticStyle?T(e.staticStyle,t):t}function eo(e){return Array.isArray(e)?L(e):"string"==typeof e?Qr(e):e}var to,no=/^--/,ro=/\s*!important$/,oo=function(e,t,n){if(no.test(t))e.style.setProperty(t,n);else if(ro.test(n))e.style.setProperty($(t),n.replace(ro,""),"important");else{var r=ao(t);if(Array.isArray(n))for(var o=0,i=n.length;o-1?t.split(uo).forEach((function(t){return e.classList.add(t)})):e.classList.add(t);else{var n=" ".concat(e.getAttribute("class")||""," ");n.indexOf(" "+t+" ")<0&&e.setAttribute("class",(n+t).trim())}}function fo(e,t){if(t&&(t=t.trim()))if(e.classList)t.indexOf(" ")>-1?t.split(uo).forEach((function(t){return e.classList.remove(t)})):e.classList.remove(t),e.classList.length||e.removeAttribute("class");else{for(var n=" ".concat(e.getAttribute("class")||""," "),r=" "+t+" ";n.indexOf(r)>=0;)n=n.replace(r," ");(n=n.trim())?e.setAttribute("class",n):e.removeAttribute("class")}}function po(e){if(e){if("object"==typeof e){var t={};return!1!==e.css&&T(t,vo(e.name||"v")),T(t,e),t}return"string"==typeof e?vo(e):void 0}}var vo=k((function(e){return{enterClass:"".concat(e,"-enter"),enterToClass:"".concat(e,"-enter-to"),enterActiveClass:"".concat(e,"-enter-active"),leaveClass:"".concat(e,"-leave"),leaveToClass:"".concat(e,"-leave-to"),leaveActiveClass:"".concat(e,"-leave-active")}})),ho=G&&!Q,mo="transition",go="transitionend",yo="animation",bo="animationend";ho&&(void 0===window.ontransitionend&&void 0!==window.onwebkittransitionend&&(mo="WebkitTransition",go="webkitTransitionEnd"),void 0===window.onanimationend&&void 0!==window.onwebkitanimationend&&(yo="WebkitAnimation",bo="webkitAnimationEnd"));var _o=G?window.requestAnimationFrame?window.requestAnimationFrame.bind(window):setTimeout:function(e){return e()};function wo(e){_o((function(){_o(e)}))}function xo(e,t){var n=e._transitionClasses||(e._transitionClasses=[]);n.indexOf(t)<0&&(n.push(t),co(e,t))}function jo(e,t){e._transitionClasses&&w(e._transitionClasses,t),fo(e,t)}function ko(e,t,n){var r=Oo(e,t),o=r.type,i=r.timeout,a=r.propCount;if(!o)return n();var s="transition"===o?go:bo,l=0,u=function(){e.removeEventListener(s,c),n()},c=function(t){t.target===e&&++l>=a&&u()};setTimeout((function(){l0&&(n="transition",c=a,f=i.length):"animation"===t?u>0&&(n="animation",c=u,f=l.length):f=(n=(c=Math.max(a,u))>0?a>u?"transition":"animation":null)?"transition"===n?i.length:l.length:0,{type:n,timeout:c,propCount:f,hasTransform:"transition"===n&&So.test(r[mo+"Property"])}}function Co(e,t){for(;e.length1}function Lo(e,t){!0!==t.data.show&&$o(t)}var Ro=function(e){var t,n,r={},u=e.modules,c=e.nodeOps;for(t=0;tv?_(e,i(n[g+1])?null:n[g+1].elm,n,d,g,r):d>g&&x(t,f,v)}(f,h,g,n,u):a(g)?(a(e.text)&&c.setTextContent(f,""),_(f,null,g,0,g.length-1,n)):a(h)?x(h,0,h.length-1):a(e.text)&&c.setTextContent(f,""):e.text!==t.text&&c.setTextContent(f,t.text),a(v)&&a(d=v.hook)&&a(d=d.postpatch)&&d(e,t)}}}function O(e,t,n){if(s(n)&&a(e.parent))e.parent.data.pendingInsert=t;else for(var r=0;r-1,a.selected!==i&&(a.selected=i);else if(I(Fo(a),r))return void(e.selectedIndex!==s&&(e.selectedIndex=s));o||(e.selectedIndex=-1)}}function Do(e,t){return t.every((function(t){return!I(t,e)}))}function Fo(e){return"_value"in e?e._value:e.value}function Uo(e){e.target.composing=!0}function zo(e){e.target.composing&&(e.target.composing=!1,Jo(e.target,"input"))}function Jo(e,t){var n=document.createEvent("HTMLEvents");n.initEvent(t,!0,!0),e.dispatchEvent(n)}function Bo(e){return!e.componentInstance||e.data&&e.data.transition?e:Bo(e.componentInstance._vnode)}var qo={model:Mo,show:{bind:function(e,t,n){var r=t.value,o=(n=Bo(n)).data&&n.data.transition,i=e.__vOriginalDisplay="none"===e.style.display?"":e.style.display;r&&o?(n.data.show=!0,$o(n,(function(){e.style.display=i}))):e.style.display=r?i:"none"},update:function(e,t,n){var r=t.value;!r!=!t.oldValue&&((n=Bo(n)).data&&n.data.transition?(n.data.show=!0,r?$o(n,(function(){e.style.display=e.__vOriginalDisplay})):Eo(n,(function(){e.style.display="none"}))):e.style.display=r?e.__vOriginalDisplay:"none")},unbind:function(e,t,n,r,o){o||(e.style.display=e.__vOriginalDisplay)}}},Vo={name:String,appear:Boolean,css:Boolean,mode:String,type:String,enterClass:String,leaveClass:String,enterToClass:String,leaveToClass:String,enterActiveClass:String,leaveActiveClass:String,appearClass:String,appearActiveClass:String,appearToClass:String,duration:[Number,String,Object]};function Ho(e){var t=e&&e.componentOptions;return t&&t.Ctor.options.abstract?Ho(kt(t.children)):e}function Ko(e){var t={},n=e.$options;for(var r in n.propsData)t[r]=e[r];var o=n._parentListeners;for(var r in o)t[O(r)]=o[r];return t}function Wo(e,t){if(/\d-keep-alive$/.test(t.tag))return e("keep-alive",{props:t.componentOptions.propsData})}var Go=function(e){return e.tag||vt(e)},Zo=function(e){return"show"===e.name},Xo={name:"transition",props:Vo,abstract:!0,render:function(e){var t=this,n=this.$slots.default;if(n&&(n=n.filter(Go)).length){0;var r=this.mode;0;var o=n[0];if(function(e){for(;e=e.parent;)if(e.data.transition)return!0}(this.$vnode))return o;var i=Ho(o);if(!i)return o;if(this._leaving)return Wo(e,o);var a="__transition-".concat(this._uid,"-");i.key=null==i.key?i.isComment?a+"comment":a+i.tag:l(i.key)?0===String(i.key).indexOf(a)?i.key:a+i.key:i.key;var s=(i.data||(i.data={})).transition=Ko(this),u=this._vnode,c=Ho(u);if(i.data.directives&&i.data.directives.some(Zo)&&(i.data.show=!0),c&&c.data&&!function(e,t){return t.key===e.key&&t.tag===e.tag}(i,c)&&!vt(c)&&(!c.componentInstance||!c.componentInstance._vnode.isComment)){var f=c.data.transition=T({},s);if("out-in"===r)return this._leaving=!0,Ke(f,"afterLeave",(function(){t._leaving=!1,t.$forceUpdate()})),Wo(e,o);if("in-out"===r){if(vt(i))return u;var p,d=function(){p()};Ke(s,"afterEnter",d),Ke(s,"enterCancelled",d),Ke(f,"delayLeave",(function(e){p=e}))}}return o}}},Qo=T({tag:String,moveClass:String},Vo);function Yo(e){e.elm._moveCb&&e.elm._moveCb(),e.elm._enterCb&&e.elm._enterCb()}function ei(e){e.data.newPos=e.elm.getBoundingClientRect()}function ti(e){var t=e.data.pos,n=e.data.newPos,r=t.left-n.left,o=t.top-n.top;if(r||o){e.data.moved=!0;var i=e.elm.style;i.transform=i.WebkitTransform="translate(".concat(r,"px,").concat(o,"px)"),i.transitionDuration="0s"}}delete Qo.mode;var ni={Transition:Xo,TransitionGroup:{props:Qo,beforeMount:function(){var e=this,t=this._update;this._update=function(n,r){var o=Xt(e);e.__patch__(e._vnode,e.kept,!1,!0),e._vnode=e.kept,o(),t.call(e,n,r)}},render:function(e){for(var t=this.tag||this.$vnode.data.tag||"span",n=Object.create(null),r=this.prevChildren=this.children,o=this.$slots.default||[],i=this.children=[],a=Ko(this),s=0;s-1?yr[e]=t.constructor===window.HTMLUnknownElement||t.constructor===window.HTMLElement:yr[e]=/HTMLUnknownElement/.test(t.toString())},T(Kn.options.directives,qo),T(Kn.options.components,ni),Kn.prototype.__patch__=G?Ro:R,Kn.prototype.$mount=function(e,t){return function(e,t,n){var r;e.$el=t,e.$options.render||(e.$options.render=ve),en(e,"beforeMount"),r=function(){e._update(e._render(),n)},new Vt(e,r,R,{before:function(){e._isMounted&&!e._isDestroyed&&en(e,"beforeUpdate")}},!0),n=!1;var o=e._preWatchers;if(o)for(var i=0;i=0&&(t=e.slice(r),e=e.slice(0,r));var o=e.indexOf("?");return o>=0&&(n=e.slice(o+1),e=e.slice(0,o)),{path:e,query:n,hash:t}}(o.path||""),u=t&&t.path||"/",c=l.path?ji(l.path,u,n||o.append):u,f=function(e,t,n){void 0===t&&(t={});var r,o=n||ci;try{r=o(e||"")}catch(e){r={}}for(var i in t){var a=t[i];r[i]=Array.isArray(a)?a.map(ui):ui(a)}return r}(l.query,o.query,r&&r.options.parseQuery),p=o.hash||l.hash;return p&&"#"!==p.charAt(0)&&(p="#"+p),{_normalized:!0,path:c,query:f,hash:p}}var qi,Vi=function(){},Hi={name:"RouterLink",props:{to:{type:[String,Object],required:!0},tag:{type:String,default:"a"},custom:Boolean,exact:Boolean,exactPath:Boolean,append:Boolean,replace:Boolean,activeClass:String,exactActiveClass:String,ariaCurrentValue:{type:String,default:"page"},event:{type:[String,Array],default:"click"}},render:function(e){var t=this,n=this.$router,r=this.$route,o=n.resolve(this.to,r,this.append),i=o.location,a=o.route,s=o.href,l={},u=n.options.linkActiveClass,c=n.options.linkExactActiveClass,f=null==u?"router-link-active":u,p=null==c?"router-link-exact-active":c,d=null==this.activeClass?f:this.activeClass,v=null==this.exactActiveClass?p:this.exactActiveClass,h=a.redirectedFrom?di(null,Bi(a.redirectedFrom),null,n):a;l[v]=yi(r,h,this.exactPath),l[d]=this.exact||this.exactPath?l[v]:function(e,t){return 0===e.path.replace(pi,"/").indexOf(t.path.replace(pi,"/"))&&(!t.hash||e.hash===t.hash)&&function(e,t){for(var n in t)if(!(n in e))return!1;return!0}(e.query,t.query)}(r,h);var m=l[v]?this.ariaCurrentValue:null,g=function(e){Ki(e)&&(t.replace?n.replace(i,Vi):n.push(i,Vi))},y={click:Ki};Array.isArray(this.event)?this.event.forEach((function(e){y[e]=g})):y[this.event]=g;var b={class:l},_=!this.$scopedSlots.$hasNormal&&this.$scopedSlots.default&&this.$scopedSlots.default({href:s,route:a,navigate:g,isActive:l[d],isExactActive:l[v]});if(_){if(1===_.length)return _[0];if(_.length>1||!_.length)return 0===_.length?e():e("span",{},_)}if("a"===this.tag)b.on=y,b.attrs={href:s,"aria-current":m};else{var w=function e(t){var n;if(t)for(var r=0;r-1&&(s.params[p]=n.params[p]);return s.path=Ji(c.path,s.params),l(c,s,a)}if(s.path){s.params={};for(var d=0;d-1}function ka(e,t){return ja(e)&&e._isRouter&&(null==t||e.type===t)}function Sa(e,t,n){var r=function(o){o>=e.length?n():e[o]?t(e[o],(function(){r(o+1)})):r(o+1)};r(0)}function Oa(e){return function(t,n,r){var o=!1,i=0,a=null;Ca(e,(function(e,t,n,s){if("function"==typeof e&&void 0===e.cid){o=!0,i++;var l,u=Ea((function(t){var o;((o=t).__esModule||$a&&"Module"===o[Symbol.toStringTag])&&(t=t.default),e.resolved="function"==typeof t?t:qi.extend(t),n.components[s]=t,--i<=0&&r()})),c=Ea((function(e){var t="Failed to resolve async component "+s+": "+e;a||(a=ja(e)?e:new Error(t),r(a))}));try{l=e(u,c)}catch(e){c(e)}if(l)if("function"==typeof l.then)l.then(u,c);else{var f=l.component;f&&"function"==typeof f.then&&f.then(u,c)}}})),o||r()}}function Ca(e,t){return Pa(e.map((function(e){return Object.keys(e.components).map((function(n){return t(e.components[n],e.instances[n],e,n)}))})))}function Pa(e){return Array.prototype.concat.apply([],e)}var $a="function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag;function Ea(e){var t=!1;return function(){for(var n=[],r=arguments.length;r--;)n[r]=arguments[r];if(!t)return t=!0,e.apply(this,n)}}var Aa=function(e,t){this.router=e,this.base=function(e){if(!e)if(Wi){var t=document.querySelector("base");e=(e=t&&t.getAttribute("href")||"/").replace(/^https?:\/\/[^\/]+/,"")}else e="/";"/"!==e.charAt(0)&&(e="/"+e);return e.replace(/\/$/,"")}(t),this.current=hi,this.pending=null,this.ready=!1,this.readyCbs=[],this.readyErrorCbs=[],this.errorCbs=[],this.listeners=[]};function Ta(e,t,n,r){var o=Ca(e,(function(e,r,o,i){var a=function(e,t){"function"!=typeof e&&(e=qi.extend(e));return e.options[t]}(e,t);if(a)return Array.isArray(a)?a.map((function(e){return n(e,r,o,i)})):n(a,r,o,i)}));return Pa(r?o.reverse():o)}function La(e,t){if(t)return function(){return e.apply(t,arguments)}}Aa.prototype.listen=function(e){this.cb=e},Aa.prototype.onReady=function(e,t){this.ready?e():(this.readyCbs.push(e),t&&this.readyErrorCbs.push(t))},Aa.prototype.onError=function(e){this.errorCbs.push(e)},Aa.prototype.transitionTo=function(e,t,n){var r,o=this;try{r=this.router.match(e,this.current)}catch(e){throw this.errorCbs.forEach((function(t){t(e)})),e}var i=this.current;this.confirmTransition(r,(function(){o.updateRoute(r),t&&t(r),o.ensureURL(),o.router.afterHooks.forEach((function(e){e&&e(r,i)})),o.ready||(o.ready=!0,o.readyCbs.forEach((function(e){e(r)})))}),(function(e){n&&n(e),e&&!o.ready&&(ka(e,ya.redirected)&&i===hi||(o.ready=!0,o.readyErrorCbs.forEach((function(t){t(e)}))))}))},Aa.prototype.confirmTransition=function(e,t,n){var r=this,o=this.current;this.pending=e;var i,a,s=function(e){!ka(e)&&ja(e)&&(r.errorCbs.length?r.errorCbs.forEach((function(t){t(e)})):console.error(e)),n&&n(e)},l=e.matched.length-1,u=o.matched.length-1;if(yi(e,o)&&l===u&&e.matched[l]===o.matched[u])return this.ensureURL(),e.hash&&aa(this.router,o,e,!1),s(((a=wa(i=o,e,ya.duplicated,'Avoided redundant navigation to current location: "'+i.fullPath+'".')).name="NavigationDuplicated",a));var c=function(e,t){var n,r=Math.max(e.length,t.length);for(n=0;n0)){var t=this.router,n=t.options.scrollBehavior,r=ha&&n;r&&this.listeners.push(ia());var o=function(){var n=e.current,o=Ma(e.base);e.current===hi&&o===e._startLocation||e.transitionTo(o,(function(e){r&&aa(t,e,n,!0)}))};window.addEventListener("popstate",o),this.listeners.push((function(){window.removeEventListener("popstate",o)}))}},t.prototype.go=function(e){window.history.go(e)},t.prototype.push=function(e,t,n){var r=this,o=this.current;this.transitionTo(e,(function(e){ma(ki(r.base+e.fullPath)),aa(r.router,e,o,!1),t&&t(e)}),n)},t.prototype.replace=function(e,t,n){var r=this,o=this.current;this.transitionTo(e,(function(e){ga(ki(r.base+e.fullPath)),aa(r.router,e,o,!1),t&&t(e)}),n)},t.prototype.ensureURL=function(e){if(Ma(this.base)!==this.current.fullPath){var t=ki(this.base+this.current.fullPath);e?ma(t):ga(t)}},t.prototype.getCurrentLocation=function(){return Ma(this.base)},t}(Aa);function Ma(e){var t=window.location.pathname,n=t.toLowerCase(),r=e.toLowerCase();return!e||n!==r&&0!==n.indexOf(ki(r+"/"))||(t=t.slice(e.length)),(t||"/")+window.location.search+window.location.hash}var Na=function(e){function t(t,n,r){e.call(this,t,n),r&&function(e){var t=Ma(e);if(!/^\/#/.test(t))return window.location.replace(ki(e+"/#"+t)),!0}(this.base)||Ia()}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.setupListeners=function(){var e=this;if(!(this.listeners.length>0)){var t=this.router.options.scrollBehavior,n=ha&&t;n&&this.listeners.push(ia());var r=function(){var t=e.current;Ia()&&e.transitionTo(Da(),(function(r){n&&aa(e.router,r,t,!0),ha||za(r.fullPath)}))},o=ha?"popstate":"hashchange";window.addEventListener(o,r),this.listeners.push((function(){window.removeEventListener(o,r)}))}},t.prototype.push=function(e,t,n){var r=this,o=this.current;this.transitionTo(e,(function(e){Ua(e.fullPath),aa(r.router,e,o,!1),t&&t(e)}),n)},t.prototype.replace=function(e,t,n){var r=this,o=this.current;this.transitionTo(e,(function(e){za(e.fullPath),aa(r.router,e,o,!1),t&&t(e)}),n)},t.prototype.go=function(e){window.history.go(e)},t.prototype.ensureURL=function(e){var t=this.current.fullPath;Da()!==t&&(e?Ua(t):za(t))},t.prototype.getCurrentLocation=function(){return Da()},t}(Aa);function Ia(){var e=Da();return"/"===e.charAt(0)||(za("/"+e),!1)}function Da(){var e=window.location.href,t=e.indexOf("#");return t<0?"":e=e.slice(t+1)}function Fa(e){var t=window.location.href,n=t.indexOf("#");return(n>=0?t.slice(0,n):t)+"#"+e}function Ua(e){ha?ma(Fa(e)):window.location.hash=e}function za(e){ha?ga(Fa(e)):window.location.replace(Fa(e))}var Ja=function(e){function t(t,n){e.call(this,t,n),this.stack=[],this.index=-1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.push=function(e,t,n){var r=this;this.transitionTo(e,(function(e){r.stack=r.stack.slice(0,r.index+1).concat(e),r.index++,t&&t(e)}),n)},t.prototype.replace=function(e,t,n){var r=this;this.transitionTo(e,(function(e){r.stack=r.stack.slice(0,r.index).concat(e),t&&t(e)}),n)},t.prototype.go=function(e){var t=this,n=this.index+e;if(!(n<0||n>=this.stack.length)){var r=this.stack[n];this.confirmTransition(r,(function(){var e=t.current;t.index=n,t.updateRoute(r),t.router.afterHooks.forEach((function(t){t&&t(r,e)}))}),(function(e){ka(e,ya.duplicated)&&(t.index=n)}))}},t.prototype.getCurrentLocation=function(){var e=this.stack[this.stack.length-1];return e?e.fullPath:"/"},t.prototype.ensureURL=function(){},t}(Aa),Ba=function(e){void 0===e&&(e={}),this.app=null,this.apps=[],this.options=e,this.beforeHooks=[],this.resolveHooks=[],this.afterHooks=[],this.matcher=Xi(e.routes||[],this);var t=e.mode||"hash";switch(this.fallback="history"===t&&!ha&&!1!==e.fallback,this.fallback&&(t="hash"),Wi||(t="abstract"),this.mode=t,t){case"history":this.history=new Ra(this,e.base);break;case"hash":this.history=new Na(this,e.base,this.fallback);break;case"abstract":this.history=new Ja(this,e.base);break;default:0}},qa={currentRoute:{configurable:!0}};Ba.prototype.match=function(e,t,n){return this.matcher.match(e,t,n)},qa.currentRoute.get=function(){return this.history&&this.history.current},Ba.prototype.init=function(e){var t=this;if(this.apps.push(e),e.$once("hook:destroyed",(function(){var n=t.apps.indexOf(e);n>-1&&t.apps.splice(n,1),t.app===e&&(t.app=t.apps[0]||null),t.app||t.history.teardown()})),!this.app){this.app=e;var n=this.history;if(n instanceof Ra||n instanceof Na){var r=function(e){n.setupListeners(),function(e){var r=n.current,o=t.options.scrollBehavior;ha&&o&&"fullPath"in e&&aa(t,e,r,!1)}(e)};n.transitionTo(n.getCurrentLocation(),r,r)}n.listen((function(e){t.apps.forEach((function(t){t._route=e}))}))}},Ba.prototype.beforeEach=function(e){return Ha(this.beforeHooks,e)},Ba.prototype.beforeResolve=function(e){return Ha(this.resolveHooks,e)},Ba.prototype.afterEach=function(e){return Ha(this.afterHooks,e)},Ba.prototype.onReady=function(e,t){this.history.onReady(e,t)},Ba.prototype.onError=function(e){this.history.onError(e)},Ba.prototype.push=function(e,t,n){var r=this;if(!t&&!n&&"undefined"!=typeof Promise)return new Promise((function(t,n){r.history.push(e,t,n)}));this.history.push(e,t,n)},Ba.prototype.replace=function(e,t,n){var r=this;if(!t&&!n&&"undefined"!=typeof Promise)return new Promise((function(t,n){r.history.replace(e,t,n)}));this.history.replace(e,t,n)},Ba.prototype.go=function(e){this.history.go(e)},Ba.prototype.back=function(){this.go(-1)},Ba.prototype.forward=function(){this.go(1)},Ba.prototype.getMatchedComponents=function(e){var t=e?e.matched?e:this.resolve(e).route:this.currentRoute;return t?[].concat.apply([],t.matched.map((function(e){return Object.keys(e.components).map((function(t){return e.components[t]}))}))):[]},Ba.prototype.resolve=function(e,t,n){var r=Bi(e,t=t||this.history.current,n,this),o=this.match(r,t),i=o.redirectedFrom||o.fullPath;return{location:r,route:o,href:function(e,t,n){var r="hash"===n?"#"+t:t;return e?ki(e+"/"+r):r}(this.history.base,i,this.mode),normalizedTo:r,resolved:o}},Ba.prototype.getRoutes=function(){return this.matcher.getRoutes()},Ba.prototype.addRoute=function(e,t){this.matcher.addRoute(e,t),this.history.current!==hi&&this.history.transitionTo(this.history.getCurrentLocation())},Ba.prototype.addRoutes=function(e){this.matcher.addRoutes(e),this.history.current!==hi&&this.history.transitionTo(this.history.getCurrentLocation())},Object.defineProperties(Ba.prototype,qa);var Va=Ba;function Ha(e,t){return e.push(t),function(){var n=e.indexOf(t);n>-1&&e.splice(n,1)}}Ba.install=function e(t){if(!e.installed||qi!==t){e.installed=!0,qi=t;var n=function(e){return void 0!==e},r=function(e,t){var r=e.$options._parentVnode;n(r)&&n(r=r.data)&&n(r=r.registerRouteInstance)&&r(e,t)};t.mixin({beforeCreate:function(){n(this.$options.router)?(this._routerRoot=this,this._router=this.$options.router,this._router.init(this),t.util.defineReactive(this,"_route",this._router.history.current)):this._routerRoot=this.$parent&&this.$parent._routerRoot||this,r(this,this)},destroyed:function(){r(this)}}),Object.defineProperty(t.prototype,"$router",{get:function(){return this._routerRoot._router}}),Object.defineProperty(t.prototype,"$route",{get:function(){return this._routerRoot._route}}),t.component("RouterView",wi),t.component("RouterLink",Hi);var o=t.config.optionMergeStrategies;o.beforeRouteEnter=o.beforeRouteLeave=o.beforeRouteUpdate=o.created}},Ba.version="3.6.5",Ba.isNavigationFailure=ka,Ba.NavigationFailureType=ya,Ba.START_LOCATION=hi,Wi&&window.Vue&&window.Vue.use(Ba);n(95);n(122),n(88);var Ka={"components/AlgoliaSearchBox":()=>Promise.all([n.e(0),n.e(15)]).then(n.bind(null,372)),"components/DropdownLink":()=>Promise.all([n.e(0),n.e(16)]).then(n.bind(null,254)),"components/DropdownTransition":()=>Promise.all([n.e(0),n.e(40)]).then(n.bind(null,241)),"components/Home":()=>Promise.all([n.e(0),n.e(19)]).then(n.bind(null,299)),"components/NavLink":()=>n.e(42).then(n.bind(null,240)),"components/NavLinks":()=>Promise.all([n.e(0),n.e(13)]).then(n.bind(null,265)),"components/Navbar":()=>Promise.all([n.e(0),n.e(1)]).then(n.bind(null,369)),"components/Page":()=>Promise.all([n.e(0),n.e(12)]).then(n.bind(null,300)),"components/PageEdit":()=>Promise.all([n.e(0),n.e(20)]).then(n.bind(null,255)),"components/PageNav":()=>Promise.all([n.e(0),n.e(17)]).then(n.bind(null,267)),"components/Sidebar":()=>Promise.all([n.e(0),n.e(11)]).then(n.bind(null,301)),"components/SidebarButton":()=>Promise.all([n.e(0),n.e(41)]).then(n.bind(null,302)),"components/SidebarGroup":()=>Promise.all([n.e(0),n.e(3)]).then(n.bind(null,266)),"components/SidebarLink":()=>Promise.all([n.e(0),n.e(24)]).then(n.bind(null,256)),"components/SidebarLinks":()=>Promise.all([n.e(0),n.e(3)]).then(n.bind(null,253)),"global-components/Badge":()=>Promise.all([n.e(0),n.e(4)]).then(n.bind(null,390)),"global-components/CodeBlock":()=>Promise.all([n.e(0),n.e(5)]).then(n.bind(null,373)),"global-components/CodeGroup":()=>Promise.all([n.e(0),n.e(6)]).then(n.bind(null,374)),"layouts/404":()=>n.e(7).then(n.bind(null,375)),"layouts/Layout":()=>Promise.all([n.e(0),n.e(1),n.e(2)]).then(n.bind(null,376)),NotFound:()=>n.e(7).then(n.bind(null,375)),Layout:()=>Promise.all([n.e(0),n.e(1),n.e(2)]).then(n.bind(null,376))},Wa={"v-0b4d4089":()=>n.e(44).then(n.bind(null,391)),"v-2216e8dc":()=>n.e(10).then(n.bind(null,392)),"v-29ebca8e":()=>n.e(47).then(n.bind(null,393)),"v-094b9dee":()=>n.e(45).then(n.bind(null,394)),"v-7eb94829":()=>n.e(46).then(n.bind(null,395)),"v-126ea6be":()=>n.e(49).then(n.bind(null,396)),"v-51aaf849":()=>n.e(48).then(n.bind(null,397)),"v-003ee409":()=>n.e(50).then(n.bind(null,398)),"v-83a41dee":()=>n.e(52).then(n.bind(null,399)),"v-4d7f1c8a":()=>n.e(51).then(n.bind(null,400)),"v-49301ee2":()=>n.e(53).then(n.bind(null,401)),"v-d1f646ae":()=>n.e(54).then(n.bind(null,402)),"v-7cca31fe":()=>n.e(56).then(n.bind(null,403)),"v-76cafeae":()=>n.e(58).then(n.bind(null,404)),"v-f3391bf6":()=>n.e(59).then(n.bind(null,405)),"v-b5351e9e":()=>n.e(57).then(n.bind(null,406)),"v-3ad539ae":()=>n.e(61).then(n.bind(null,407)),"v-5e92fa09":()=>n.e(62).then(n.bind(null,408)),"v-62aa1369":()=>n.e(60).then(n.bind(null,409)),"v-8de1af1a":()=>n.e(63).then(n.bind(null,410)),"v-48953121":()=>n.e(64).then(n.bind(null,411)),"v-1dfe032e":()=>n.e(66).then(n.bind(null,412)),"v-1f38ca2e":()=>n.e(65).then(n.bind(null,413)),"v-27531941":()=>n.e(67).then(n.bind(null,414)),"v-464fd629":()=>n.e(55).then(n.bind(null,415)),"v-67c77489":()=>n.e(68).then(n.bind(null,416)),"v-c918a5fa":()=>n.e(69).then(n.bind(null,417)),"v-5a94ae89":()=>n.e(70).then(n.bind(null,418)),"v-2abeb1ab":()=>n.e(71).then(n.bind(null,419)),"v-959a2c2e":()=>n.e(72).then(n.bind(null,420)),"v-506a67bc":()=>n.e(73).then(n.bind(null,421)),"v-07fb5e62":()=>n.e(75).then(n.bind(null,422)),"v-7bf93309":()=>n.e(74).then(n.bind(null,423)),"v-19f2c039":()=>n.e(76).then(n.bind(null,424)),"v-b99d2c2e":()=>n.e(77).then(n.bind(null,425)),"v-7f55ccc9":()=>n.e(79).then(n.bind(null,426)),"v-bf7e876e":()=>n.e(80).then(n.bind(null,427)),"v-bb53a316":()=>n.e(81).then(n.bind(null,428)),"v-20f55eeb":()=>n.e(82).then(n.bind(null,429)),"v-6731dec1":()=>n.e(78).then(n.bind(null,430)),"v-114a7465":()=>n.e(85).then(n.bind(null,431)),"v-90fdf4e6":()=>n.e(84).then(n.bind(null,432)),"v-74774829":()=>n.e(83).then(n.bind(null,433))};function Ga(e){const t=Object.create(null);return function(n){return t[n]||(t[n]=e(n))}}const Za=/-(\w)/g,Xa=Ga(e=>e.replace(Za,(e,t)=>t?t.toUpperCase():"")),Qa=/\B([A-Z])/g,Ya=Ga(e=>e.replace(Qa,"-$1").toLowerCase()),es=Ga(e=>e.charAt(0).toUpperCase()+e.slice(1));function ts(e,t){if(!t)return;if(e(t))return e(t);return t.includes("-")?e(es(Xa(t))):e(es(t))||e(Ya(t))}const ns=Object.assign({},Ka,Wa),rs=e=>ns[e],os=e=>Wa[e],is=e=>Ka[e],as=e=>Kn.component(e);function ss(e){return ts(os,e)}function ls(e){return ts(is,e)}function us(e){return ts(rs,e)}function cs(e){return ts(as,e)}function fs(...e){return Promise.all(e.filter(e=>e).map(async e=>{if(!cs(e)&&us(e)){const t=await us(e)();Kn.component(e,t.default)}}))}function ps(e,t){"undefined"!=typeof window&&window.__VUEPRESS__&&(window.__VUEPRESS__[e]=t)}var ds=n(86),vs=n.n(ds),hs=n(87),ms=n.n(hs),gs={created(){if(this.siteMeta=this.$site.headTags.filter(([e])=>"meta"===e).map(([e,t])=>t),this.$ssrContext){const t=this.getMergedMetaTags();this.$ssrContext.title=this.$title,this.$ssrContext.lang=this.$lang,this.$ssrContext.pageMeta=(e=t)?e.map(e=>{let t="{t+=` ${n}="${ms()(e[n])}"`}),t+">"}).join("\n "):"",this.$ssrContext.canonicalLink=bs(this.$canonicalUrl)}var e},mounted(){this.currentMetaTags=[...document.querySelectorAll("meta")],this.updateMeta(),this.updateCanonicalLink()},methods:{updateMeta(){document.title=this.$title,document.documentElement.lang=this.$lang;const e=this.getMergedMetaTags();this.currentMetaTags=_s(e,this.currentMetaTags)},getMergedMetaTags(){const e=this.$page.frontmatter.meta||[];return vs()([{name:"description",content:this.$description}],e,this.siteMeta,ws)},updateCanonicalLink(){ys(),this.$canonicalUrl&&document.head.insertAdjacentHTML("beforeend",bs(this.$canonicalUrl))}},watch:{$page(){this.updateMeta(),this.updateCanonicalLink()}},beforeDestroy(){_s(null,this.currentMetaTags),ys()}};function ys(){const e=document.querySelector("link[rel='canonical']");e&&e.remove()}function bs(e=""){return e?``:""}function _s(e,t){if(t&&[...t].filter(e=>e.parentNode===document.head).forEach(e=>document.head.removeChild(e)),e)return e.map(e=>{const t=document.createElement("meta");return Object.keys(e).forEach(n=>{t.setAttribute(n,e[n])}),document.head.appendChild(t),t})}function ws(e){for(const t of["name","property","itemprop"])if(e.hasOwnProperty(t))return e[t]+t;return JSON.stringify(e)}var xs=n(22),js=n.n(xs),ks=[gs,{mounted(){js.a.configure({showSpinner:!1}),this.$router.beforeEach((e,t,n)=>{e.path===t.path||Kn.component(e.name)||js.a.start(),n()}),this.$router.afterEach(()=>{js.a.done(),this.isSidebarOpen=!1})}}],Ss={name:"GlobalLayout",computed:{layout(){const e=this.getLayout();return ps("layout",e),Kn.component(e)}},methods:{getLayout(){if(this.$page.path){const e=this.$page.frontmatter.layout;return e&&(this.$vuepress.getLayoutAsyncComponent(e)||this.$vuepress.getVueComponent(e))?e:"Layout"}return"NotFound"}}},Os=n(14),Cs=Object(Os.a)(Ss,(function(){return(0,this._self._c)(this.layout,{tag:"component"})}),[],!1,null,null,null).exports;!function(e,t,n){switch(t){case"components":e[t]||(e[t]={}),Object.assign(e[t],n);break;case"mixins":e[t]||(e[t]=[]),e[t].push(...n);break;default:throw new Error("Unknown option name.")}}(Cs,"mixins",ks);const Ps=[{name:"v-0b4d4089",path:"/api.html",component:Cs,beforeEnter:(e,t,n)=>{fs("Layout","v-0b4d4089").then(n)}},{name:"v-2216e8dc",path:"/",component:Cs,beforeEnter:(e,t,n)=>{fs("Layout","v-2216e8dc").then(n)}},{path:"/index.html",redirect:"/"},{name:"v-29ebca8e",path:"/coercion.html",component:Cs,beforeEnter:(e,t,n)=>{fs("Layout","v-29ebca8e").then(n)}},{name:"v-094b9dee",path:"/code_of_conduct/",component:Cs,beforeEnter:(e,t,n)=>{fs("Layout","v-094b9dee").then(n)}},{path:"/code_of_conduct/index.html",redirect:"/code_of_conduct/"},{path:"/code_of_conduct.html",redirect:"/code_of_conduct/"},{name:"v-7eb94829",path:"/codegen.html",component:Cs,beforeEnter:(e,t,n)=>{fs("Layout","v-7eb94829").then(n)}},{name:"v-126ea6be",path:"/contributing/",component:Cs,beforeEnter:(e,t,n)=>{fs("Layout","v-126ea6be").then(n)}},{path:"/contributing/index.html",redirect:"/contributing/"},{path:"/contributing.html",redirect:"/contributing/"},{name:"v-51aaf849",path:"/components.html",component:Cs,beforeEnter:(e,t,n)=>{fs("Layout","v-51aaf849").then(n)}},{name:"v-003ee409",path:"/faq.html",component:Cs,beforeEnter:(e,t,n)=>{fs("Layout","v-003ee409").then(n)}},{name:"v-83a41dee",path:"/guide/combining-schemas.html",component:Cs,beforeEnter:(e,t,n)=>{fs("Layout","v-83a41dee").then(n)}},{name:"v-4d7f1c8a",path:"/guide/async-validation.html",component:Cs,beforeEnter:(e,t,n)=>{fs("Layout","v-4d7f1c8a").then(n)}},{name:"v-49301ee2",path:"/guide/environments.html",component:Cs,beforeEnter:(e,t,n)=>{fs("Layout","v-49301ee2").then(n)}},{name:"v-d1f646ae",path:"/guide/formats.html",component:Cs,beforeEnter:(e,t,n)=>{fs("Layout","v-d1f646ae").then(n)}},{name:"v-7cca31fe",path:"/guide/managing-schemas.html",component:Cs,beforeEnter:(e,t,n)=>{fs("Layout","v-7cca31fe").then(n)}},{name:"v-76cafeae",path:"/guide/schema-language.html",component:Cs,beforeEnter:(e,t,n)=>{fs("Layout","v-76cafeae").then(n)}},{name:"v-f3391bf6",path:"/guide/typescript.html",component:Cs,beforeEnter:(e,t,n)=>{fs("Layout","v-f3391bf6").then(n)}},{name:"v-b5351e9e",path:"/guide/modifying-data.html",component:Cs,beforeEnter:(e,t,n)=>{fs("Layout","v-b5351e9e").then(n)}},{name:"v-3ad539ae",path:"/guide/why-ajv.html",component:Cs,beforeEnter:(e,t,n)=>{fs("Layout","v-3ad539ae").then(n)}},{name:"v-5e92fa09",path:"/json-schema.html",component:Cs,beforeEnter:(e,t,n)=>{fs("Layout","v-5e92fa09").then(n)}},{name:"v-62aa1369",path:"/guide/user-keywords.html",component:Cs,beforeEnter:(e,t,n)=>{fs("Layout","v-62aa1369").then(n)}},{name:"v-8de1af1a",path:"/json-type-definition.html",component:Cs,beforeEnter:(e,t,n)=>{fs("Layout","v-8de1af1a").then(n)}},{name:"v-48953121",path:"/keywords.html",component:Cs,beforeEnter:(e,t,n)=>{fs("Layout","v-48953121").then(n)}},{name:"v-1dfe032e",path:"/news/2020-08-14-mozilla-grant-openjs-foundation.html",component:Cs,beforeEnter:(e,t,n)=>{fs("Layout","v-1dfe032e").then(n)}},{name:"v-1f38ca2e",path:"/license.html",component:Cs,beforeEnter:(e,t,n)=>{fs("Layout","v-1f38ca2e").then(n)}},{name:"v-27531941",path:"/news/2020-12-15-ajv-version-7-released.html",component:Cs,beforeEnter:(e,t,n)=>{fs("Layout","v-27531941").then(n)}},{name:"v-464fd629",path:"/guide/getting-started.html",component:Cs,beforeEnter:(e,t,n)=>{fs("Layout","v-464fd629").then(n)}},{name:"v-67c77489",path:"/news/2021-03-07-ajv-supports-json-type-definition.html",component:Cs,beforeEnter:(e,t,n)=>{fs("Layout","v-67c77489").then(n)}},{name:"v-c918a5fa",path:"/news/2021-03-27-ajv-version-8-released.html",component:Cs,beforeEnter:(e,t,n)=>{fs("Layout","v-c918a5fa").then(n)}},{name:"v-5a94ae89",path:"/news/2021-04-24-ajv-online-event.html",component:Cs,beforeEnter:(e,t,n)=>{fs("Layout","v-5a94ae89").then(n)}},{name:"v-2abeb1ab",path:"/news/2021-05-24-ajv-online-event-video.html",component:Cs,beforeEnter:(e,t,n)=>{fs("Layout","v-2abeb1ab").then(n)}},{name:"v-959a2c2e",path:"/news/2021-07-22-ajv-microsoft-foss-fund-award.html",component:Cs,beforeEnter:(e,t,n)=>{fs("Layout","v-959a2c2e").then(n)}},{name:"v-506a67bc",path:"/news/",component:Cs,beforeEnter:(e,t,n)=>{fs("Layout","v-506a67bc").then(n)}},{path:"/news/index.html",redirect:"/news/"},{name:"v-07fb5e62",path:"/packages/",component:Cs,beforeEnter:(e,t,n)=>{fs("Layout","v-07fb5e62").then(n)}},{path:"/packages/index.html",redirect:"/packages/"},{name:"v-7bf93309",path:"/options.html",component:Cs,beforeEnter:(e,t,n)=>{fs("Layout","v-7bf93309").then(n)}},{name:"v-19f2c039",path:"/packages/ajv-cli.html",component:Cs,beforeEnter:(e,t,n)=>{fs("Layout","v-19f2c039").then(n)}},{name:"v-b99d2c2e",path:"/packages/ajv-errors.html",component:Cs,beforeEnter:(e,t,n)=>{fs("Layout","v-b99d2c2e").then(n)}},{name:"v-7f55ccc9",path:"/packages/ajv-i18n.html",component:Cs,beforeEnter:(e,t,n)=>{fs("Layout","v-7f55ccc9").then(n)}},{name:"v-bf7e876e",path:"/packages/ajv-keywords.html",component:Cs,beforeEnter:(e,t,n)=>{fs("Layout","v-bf7e876e").then(n)}},{name:"v-bb53a316",path:"/security.html",component:Cs,beforeEnter:(e,t,n)=>{fs("Layout","v-bb53a316").then(n)}},{name:"v-20f55eeb",path:"/standalone.html",component:Cs,beforeEnter:(e,t,n)=>{fs("Layout","v-20f55eeb").then(n)}},{name:"v-6731dec1",path:"/packages/ajv-formats.html",component:Cs,beforeEnter:(e,t,n)=>{fs("Layout","v-6731dec1").then(n)}},{name:"v-114a7465",path:"/v6-to-v8-migration.html",component:Cs,beforeEnter:(e,t,n)=>{fs("Layout","v-114a7465").then(n)}},{name:"v-90fdf4e6",path:"/testimonials.html",component:Cs,beforeEnter:(e,t,n)=>{fs("Layout","v-90fdf4e6").then(n)}},{name:"v-74774829",path:"/strict-mode.html",component:Cs,beforeEnter:(e,t,n)=>{fs("Layout","v-74774829").then(n)}},{path:"*",component:Cs}],$s={title:"Ajv JSON schema validator",description:"The fastest JSON schema Validator. Supports JSON Schema draft-04/06/07/2019-09/2020-12 and JSON Type Definition (RFC8927)",base:"/",headTags:[["link",{rel:"icon",href:"/favicon.ico"}],["meta",{charset:"utf-8"}],["meta",{property:"og:title",content:"Ajv JSON schema validator"}],["meta",{property:"og:description",content:"The fastest JSON schema Validator. Supports JSON Schema draft-04/06/07/2019-09/2020-12 and JSON Type Definition (RFC8927)"}],["meta",{property:"og:image",content:"https://ajv.js.org/img/ajv.png"}],["meta",{itemprop:"image",content:"https://ajv.js.org/img/ajv.png"}],["meta",{name:"twitter:card",content:"summary"}],["meta",{name:"twitter:title",content:"Ajv JSON schema validator"}],["meta",{name:"twitter:image:src",content:"https://ajv.js.org/img/ajv.png"}],["meta",{name:"apple-mobile-web-app-capable",content:"yes"}],["link",{rel:"apple-touch-icon",href:"/img/apple-touch-icon.png"}]],pages:[{title:"API Reference",frontmatter:{},regularPath:"/api.html",relativePath:"api.md",key:"v-0b4d4089",path:"/api.html",headers:[{level:2,title:"Ajv constructor and methods",slug:"ajv-constructor-and-methods"},{level:3,title:"new Ajv(options: object)",slug:"new-ajv-options-object"},{level:3,title:"ajv.compile(schema: object): (data: any) => boolean | Promise",slug:"ajv-compile-schema-object-data-any-boolean-promise-any"},{level:3,title:"ajv.compileSerializer(schema: object): (data: any) => string",slug:"ajv-compileserializer-schema-object-data-any-string"},{level:3,title:"ajv.compileParser(schema: object): (json: string) => any",slug:"ajv-compileparser-schema-object-json-string-any"},{level:3,title:"ajv.compileAsync(schema: object, meta?: boolean): Promise",slug:"ajv-compileasync-schema-object-meta-boolean-promise-function"},{level:3,title:"ajv.validate(schemaOrRef: object | string, data: any): boolean",slug:"ajv-validate-schemaorref-object-string-data-any-boolean"},{level:3,title:"ajv.addSchema(schema: object | object[], key?: string): Ajv",slug:"ajv-addschema-schema-object-object-key-string-ajv"},{level:3,title:"ajv.addMetaSchema(schema: object | object[], key?: string): Ajv",slug:"ajv-addmetaschema-schema-object-object-key-string-ajv"},{level:3,title:"ajv.validateSchema(schema: object): boolean",slug:"ajv-validateschema-schema-object-boolean"},{level:3,title:"ajv.getSchema(key: string): undefined | ((data: any) => boolean | Promise )",slug:"ajv-getschema-key-string-undefined-data-any-boolean-promise-any"},{level:3,title:"ajv.removeSchema(schemaOrRef: object | string | RegExp): Ajv",slug:"ajv-removeschema-schemaorref-object-string-regexp-ajv"},{level:3,title:"ajv.addFormat(name: string, format: Format): Ajv",slug:"ajv-addformat-name-string-format-format-ajv"},{level:3,title:"ajv.addKeyword(definition: string | object): Ajv",slug:"ajv-addkeyword-definition-string-object-ajv"},{level:3,title:"ajv.getKeyword(keyword: string): object | boolean",slug:"ajv-getkeyword-keyword-string-object-boolean"},{level:3,title:"ajv.removeKeyword(keyword: string): Ajv",slug:"ajv-removekeyword-keyword-string-ajv"},{level:3,title:"ajv.errorsText(errors?: object[], options?: object): string",slug:"ajv-errorstext-errors-object-options-object-string"},{level:2,title:"Validation errors",slug:"validation-errors"},{level:3,title:"Error objects",slug:"error-objects"},{level:3,title:"Error parameters",slug:"error-parameters"},{level:3,title:"Errors i18n",slug:"errors-i18n"},{level:3,title:"Error logging",slug:"error-logging"}]},{frontmatter:{homepage:!0,sidebar:!1},regularPath:"/",relativePath:"README.md",key:"v-2216e8dc",path:"/",headers:[{level:2,title:"Security and reliability for JavaScript applications",slug:"security-and-reliability-for-javascript-applications"},{level:3,title:"Write less code",slug:"write-less-code"},{level:3,title:"Super fast & secure",slug:"super-fast-secure"},{level:3,title:"Multi-standard",slug:"multi-standard"},{level:2,title:"Ajv sponsors",slug:"ajv-sponsors"},{level:2,title:"What users say",slug:"what-users-say"},{level:2,title:"News",slug:"news"},{level:2,title:"Who uses Ajv",slug:"who-uses-ajv"},{level:2,title:"Contributors",slug:"contributors"}]},{title:"Type coercion rules",frontmatter:{},regularPath:"/coercion.html",relativePath:"coercion.md",key:"v-29ebca8e",path:"/coercion.html",headers:[{level:2,title:"Coercion from string values",slug:"coercion-from-string-values"},{level:2,title:"Coercion from number values",slug:"coercion-from-number-values"},{level:2,title:"Coercion from boolean values",slug:"coercion-from-boolean-values"},{level:2,title:"Coercion from null",slug:"coercion-from-null"},{level:2,title:"Coercion to and from array",slug:"coercion-to-and-from-array"}]},{title:"Contributor Covenant Code of Conduct",frontmatter:{permalink:"/code_of_conduct"},regularPath:"/code_of_conduct.html",relativePath:"code_of_conduct.md",key:"v-094b9dee",path:"/code_of_conduct/",headers:[{level:3,title:"Our Pledge",slug:"our-pledge"},{level:3,title:"Our Standards",slug:"our-standards"},{level:3,title:"Our Responsibilities",slug:"our-responsibilities"},{level:3,title:"Scope",slug:"scope"},{level:3,title:"Enforcement",slug:"enforcement"},{level:3,title:"Attribution",slug:"attribution"}]},{title:"Code generation design",frontmatter:{},regularPath:"/codegen.html",relativePath:"codegen.md",key:"v-7eb94829",path:"/codegen.html",headers:[{level:2,title:"Safe code generation",slug:"safe-code-generation"},{level:2,title:"Code optimization",slug:"code-optimization"},{level:2,title:"User-defined keywords",slug:"user-defined-keywords"}]},{title:"Contributing guide",frontmatter:{permalink:"/contributing"},regularPath:"/contributing.html",relativePath:"contributing.md",key:"v-126ea6be",path:"/contributing/",headers:[{level:2,title:"Documentation",slug:"documentation"},{level:2,title:"Issues",slug:"issues"},{level:3,title:"Bug reports",slug:"bug-reports"},{level:3,title:"Security vulnerabilities",slug:"security-vulnerabilities"},{level:3,title:"Change proposals",slug:"change-proposals"},{level:3,title:"Browser and compatibility issues",slug:"browser-and-compatibility-issues"},{level:3,title:"Installation and dependency issues",slug:"installation-and-dependency-issues"},{level:3,title:"Using JSON Schema standard",slug:"using-json-schema-standard"},{level:3,title:"Ajv usage questions",slug:"ajv-usage-questions"},{level:2,title:"Code",slug:"code"},{level:3,title:"How we make decisions",slug:"how-we-make-decisions"},{level:3,title:"Development",slug:"development"},{level:3,title:"Pull requests",slug:"pull-requests"},{level:3,title:"Contributions license",slug:"contributions-license"}]},{title:"Code components",frontmatter:{},regularPath:"/components.html",relativePath:"components.md",key:"v-51aaf849",path:"/components.html",headers:[{level:2,title:"Ajv classes",slug:"ajv-classes"},{level:2,title:"Schema compilation",slug:"schema-compilation"},{level:2,title:"Other components",slug:"other-components"}]},{title:"Frequently Asked Questions",frontmatter:{},regularPath:"/faq.html",relativePath:"faq.md",key:"v-003ee409",path:"/faq.html",headers:[{level:2,title:"Using JSON schema",slug:"using-json-schema"},{level:2,title:"Ajv API for returning validation errors",slug:"ajv-api-for-returning-validation-errors"},{level:2,title:"Additional properties inside compound keywords anyOf, oneOf, etc.",slug:"additional-properties-inside-compound-keywords-anyof-oneof-etc"},{level:2,title:"Generating schemas with resolved references ($ref)",slug:"generating-schemas-with-resolved-references-ref"}]},{title:"Combining schemas",frontmatter:{},regularPath:"/guide/combining-schemas.html",relativePath:"guide/combining-schemas.md",key:"v-83a41dee",path:"/guide/combining-schemas.html",headers:[{level:2,title:"Combining schemas with $ref",slug:"combining-schemas-with-ref"},{level:2,title:"Extending recursive schemas",slug:"extending-recursive-schemas"},{level:2,title:"$data reference",slug:"data-reference"},{level:2,title:"$merge and $patch keywords",slug:"merge-and-patch-keywords"}]},{title:"Asynchronous validation",frontmatter:{},regularPath:"/guide/async-validation.html",relativePath:"guide/async-validation.md",key:"v-4d7f1c8a",path:"/guide/async-validation.html",headers:[{level:3,title:"Using transpilers",slug:"using-transpilers"}]},{title:"Execution environments",frontmatter:{},regularPath:"/guide/environments.html",relativePath:"guide/environments.md",key:"v-49301ee2",path:"/guide/environments.html",headers:[{level:2,title:"Server-side Node.js",slug:"server-side-node-js"},{level:2,title:"Short-lived environments",slug:"short-lived-environments"},{level:2,title:"Browsers",slug:"browsers"},{level:2,title:"ES5 environments",slug:"es5-environments"},{level:2,title:"CJS vs ESM exports",slug:"cjs-vs-esm-exports"},{level:2,title:"Other JavaScript environments",slug:"other-javascript-environments"},{level:2,title:"Command line interface",slug:"command-line-interface"}]},{title:"Format validation",frontmatter:{},regularPath:"/guide/formats.html",relativePath:"guide/formats.md",key:"v-d1f646ae",path:"/guide/formats.html",headers:[{level:2,title:"String formats",slug:"string-formats"},{level:2,title:"User-defined formats",slug:"user-defined-formats"},{level:2,title:"Formats and standalone validation code",slug:"formats-and-standalone-validation-code"}]},{title:"Managing schemas",frontmatter:{},regularPath:"/guide/managing-schemas.html",relativePath:"guide/managing-schemas.md",key:"v-7cca31fe",path:"/guide/managing-schemas.html",headers:[{level:2,title:"Re-using validation functions",slug:"re-using-validation-functions"},{level:2,title:"Standalone validation code",slug:"standalone-validation-code"},{level:2,title:"Compiling during initialization",slug:"compiling-during-initialization"},{level:2,title:"Using Ajv instance cache",slug:"using-ajv-instance-cache"},{level:3,title:"Cache key: schema vs key vs $id",slug:"cache-key-schema-vs-key-vs-id"},{level:3,title:"Pre-adding all schemas vs adding on demand",slug:"pre-adding-all-schemas-vs-adding-on-demand"},{level:3,title:"Asynchronous schema loading",slug:"asynchronous-schema-loading"},{level:2,title:"Caching schemas in your code",slug:"caching-schemas-in-your-code"}]},{title:"Choosing schema language",frontmatter:{tags:["JTD"]},regularPath:"/guide/schema-language.html",relativePath:"guide/schema-language.md",key:"v-76cafeae",path:"/guide/schema-language.html",headers:[{level:2,title:"JSON Type Definition",slug:"json-type-definition"},{level:2,title:"JSON Schema",slug:"json-schema"},{level:3,title:"draft-04",slug:"draft-04"},{level:3,title:"draft-07 (and draft-06)",slug:"draft-07-and-draft-06"},{level:3,title:"draft 2019-09 (and draft-2020-12)",slug:"draft-2019-09-and-draft-2020-12"},{level:2,title:"Comparison",slug:"comparison"},{level:3,title:"JSON Schema",slug:"json-schema-2"},{level:3,title:"JSON Type Definition",slug:"json-type-definition-2"}]},{title:"Using with TypeScript",frontmatter:{},regularPath:"/guide/typescript.html",relativePath:"guide/typescript.md",key:"v-f3391bf6",path:"/guide/typescript.html",headers:[{level:2,title:"Additional functionality",slug:"additional-functionality"},{level:2,title:"Utility types for schemas",slug:"utility-types-for-schemas"},{level:2,title:"Utility type for JTD data type",slug:"utility-type-for-jtd-data-type"},{level:2,title:"Type-safe error handling",slug:"type-safe-error-handling"},{level:2,title:"Type-safe parsers and serializers",slug:"type-safe-parsers-and-serializers"},{level:2,title:"Type-safe unions",slug:"type-safe-unions"}]},{title:"Modifying data during validation",frontmatter:{},regularPath:"/guide/modifying-data.html",relativePath:"guide/modifying-data.md",key:"v-b5351e9e",path:"/guide/modifying-data.html",headers:[{level:2,title:"General considerations",slug:"general-considerations"},{level:2,title:"Removing additional properties",slug:"removing-additional-properties"},{level:2,title:"Assigning defaults",slug:"assigning-defaults"},{level:2,title:"Coercing data types",slug:"coercing-data-types"}]},{title:"Why use AJV",frontmatter:{},regularPath:"/guide/why-ajv.html",relativePath:"guide/why-ajv.md",key:"v-3ad539ae",path:"/guide/why-ajv.html",headers:[{level:2,title:"Write less code",slug:"write-less-code"},{level:2,title:"Super fast & secure",slug:"super-fast-secure"},{level:2,title:"Multi-standard",slug:"multi-standard"}]},{title:"JSON Schema",frontmatter:{},regularPath:"/json-schema.html",relativePath:"json-schema.md",key:"v-5e92fa09",path:"/json-schema.html",headers:[{level:2,title:"JSON Schema versions",slug:"json-schema-versions"},{level:3,title:"draft-07",slug:"draft-07"},{level:3,title:"draft-2019-09",slug:"draft-2019-09"},{level:3,title:"draft-2020-12",slug:"draft-2020-12"},{level:3,title:"draft-06",slug:"draft-06"},{level:3,title:"draft-04",slug:"draft-04"},{level:2,title:"OpenAPI support",slug:"openapi-support"},{level:2,title:"JSON data type",slug:"json-data-type"},{level:3,title:"type",slug:"type"},{level:3,title:"nullable",slug:"nullable"},{level:2,title:"Keywords for numbers",slug:"keywords-for-numbers"},{level:3,title:"maximum / minimum and exclusiveMaximum / exclusiveMinimum",slug:"maximum-minimum-and-exclusivemaximum-exclusiveminimum"},{level:3,title:"multipleOf",slug:"multipleof"},{level:2,title:"Keywords for strings",slug:"keywords-for-strings"},{level:3,title:"maxLength / minLength",slug:"maxlength-minlength"},{level:3,title:"pattern",slug:"pattern"},{level:3,title:"format",slug:"format"},{level:2,title:"Keywords for arrays",slug:"keywords-for-arrays"},{level:3,title:"maxItems / minItems",slug:"maxitems-minitems"},{level:3,title:"uniqueItems",slug:"uniqueitems"},{level:3,title:"items",slug:"items"},{level:3,title:"prefixItems",slug:"prefixitems"},{level:3,title:"additionalItems",slug:"additionalitems"},{level:3,title:"contains",slug:"contains"},{level:3,title:"maxContains / minContains",slug:"maxcontains-mincontains"},{level:3,title:"unevaluatedItems",slug:"unevaluateditems"},{level:2,title:"Keywords for objects",slug:"keywords-for-objects"},{level:3,title:"maxProperties / minProperties",slug:"maxproperties-minproperties"},{level:3,title:"required",slug:"required"},{level:3,title:"properties",slug:"properties"},{level:3,title:"patternProperties",slug:"patternproperties"},{level:3,title:"additionalProperties",slug:"additionalproperties"},{level:3,title:"dependencies",slug:"dependencies"},{level:3,title:"dependentRequired",slug:"dependentrequired"},{level:3,title:"dependentSchemas",slug:"dependentschemas"},{level:3,title:"propertyNames",slug:"propertynames"},{level:3,title:"unevaluatedProperties",slug:"unevaluatedproperties"},{level:3,title:"discriminator",slug:"discriminator"},{level:2,title:"Keywords for all types",slug:"keywords-for-all-types"},{level:3,title:"enum",slug:"enum"},{level:3,title:"const",slug:"const"},{level:2,title:"Compound keywords",slug:"compound-keywords"},{level:3,title:"not",slug:"not"},{level:3,title:"oneOf",slug:"oneof"},{level:3,title:"anyOf",slug:"anyof"},{level:3,title:"allOf",slug:"allof"},{level:3,title:"if/then/else",slug:"if-then-else"},{level:2,title:"Metadata keywords",slug:"metadata-keywords"}]},{title:"User-defined keywords",frontmatter:{},regularPath:"/guide/user-keywords.html",relativePath:"guide/user-keywords.md",key:"v-62aa1369",path:"/guide/user-keywords.html"},{title:"JSON Type Definition",frontmatter:{},regularPath:"/json-type-definition.html",relativePath:"json-type-definition.md",key:"v-8de1af1a",path:"/json-type-definition.html",headers:[{level:2,title:"JTD schema forms",slug:"jtd-schema-forms"},{level:3,title:"Type form",slug:"type-form"},{level:3,title:"Enum form",slug:"enum-form"},{level:3,title:"Elements form",slug:"elements-form"},{level:3,title:"Properties form",slug:"properties-form"},{level:3,title:"Discriminator form",slug:"discriminator-form"},{level:3,title:"Values form",slug:"values-form"},{level:3,title:"Ref form",slug:"ref-form"},{level:3,title:"Empty form",slug:"empty-form"},{level:2,title:"JTDSchemaType",slug:"jtdschematype"},{level:3,title:"Most Schemas",slug:"most-schemas"},{level:3,title:"Ref Schemas",slug:"ref-schemas"},{level:3,title:"Notable Omissions",slug:"notable-omissions"},{level:2,title:"Extending JTD",slug:"extending-jtd"},{level:3,title:"Metadata schema member",slug:"metadata-schema-member"},{level:3,title:"Union keyword",slug:"union-keyword"},{level:3,title:"User-defined keywords",slug:"user-defined-keywords"},{level:2,title:"Validation errors",slug:"validation-errors"}]},{title:"User defined keywords",frontmatter:{},regularPath:"/keywords.html",relativePath:"keywords.md",key:"v-48953121",path:"/keywords.html",headers:[{level:2,title:"Common attributes of keyword definitions",slug:"common-attributes-of-keyword-definitions"},{level:3,title:"Define keyword with code generation function",slug:"define-keyword-with-code-generation-function"},{level:3,title:'Define keyword with "validate" function',slug:"define-keyword-with-validate-function"},{level:3,title:'Define keyword with "compile" function',slug:"define-keyword-with-compile-function"},{level:3,title:'Define keyword with "macro" function',slug:"define-keyword-with-macro-function"},{level:2,title:"Schema compilation context",slug:"schema-compilation-context"},{level:2,title:"Validation time variables",slug:"validation-time-variables"},{level:2,title:"Reporting errors",slug:"reporting-errors"}]},{title:"Mozilla MOSS grant and OpenJS Foundation",frontmatter:{news:!0,title:"Mozilla MOSS grant and OpenJS Foundation",date:"2020-08-14T00:00:00.000Z"},regularPath:"/news/2020-08-14-mozilla-grant-openjs-foundation.html",relativePath:"news/2020-08-14-mozilla-grant-openjs-foundation.md",key:"v-1dfe032e",path:"/news/2020-08-14-mozilla-grant-openjs-foundation.html",excerpt:'

\n

Ajv has been awarded a grant from Mozilla’s Open Source Support (MOSS) program in the “Foundational Technology” track! It will sponsor the development of Ajv support of JSON Schema version 2019-09 and of JSON Type Definition (RFC8927).

\n

Ajv also joined OpenJS Foundation – having this support will help ensure the longevity and stability of Ajv for all its users.

\n'},{frontmatter:{},regularPath:"/license.html",relativePath:"license.md",key:"v-1f38ca2e",path:"/license.html"},{title:"Ajv version 7 is released!",frontmatter:{news:!0,title:"Ajv version 7 is released!",date:"2020-12-15T00:00:00.000Z"},regularPath:"/news/2020-12-15-ajv-version-7-released.html",relativePath:"news/2020-12-15-ajv-version-7-released.md",key:"v-27531941",path:"/news/2020-12-15-ajv-version-7-released.html",excerpt:'

Ajv version 7 has these new features:

\n\n'},{title:"Getting started",frontmatter:{},regularPath:"/guide/getting-started.html",relativePath:"guide/getting-started.md",key:"v-464fd629",path:"/guide/getting-started.html",headers:[{level:2,title:"Install",slug:"install"},{level:2,title:"Basic data validation",slug:"basic-data-validation"},{level:2,title:"Parsing and serializing JSON",slug:"parsing-and-serializing-json"}]},{title:"Ajv supports JSON Type Definition",frontmatter:{news:!0,title:"Ajv supports JSON Type Definition",date:"2021-03-07T00:00:00.000Z"},regularPath:"/news/2021-03-07-ajv-supports-json-type-definition.html",relativePath:"news/2021-03-07-ajv-supports-json-type-definition.md",key:"v-67c77489",path:"/news/2021-03-07-ajv-supports-json-type-definition.html",excerpt:'

JSON Type Definition (JTD) is a new specification for defining JSON structures that is very simple to use, comparing with JSON Schema, less error prone, and it is published as RFC8927.

\n

See Choosing schema language for a detailed comparison between JSON Schema and JSON Type definition and informal specification.

\n'},{title:"Ajv version 8 is released!",frontmatter:{news:!0,title:"Ajv version 8 is released!",date:"2021-03-27T00:00:00.000Z"},regularPath:"/news/2021-03-27-ajv-version-8-released.html",relativePath:"news/2021-03-27-ajv-version-8-released.md",key:"v-c918a5fa",path:"/news/2021-03-27-ajv-version-8-released.html",excerpt:'

Ajv version 8 has these new features:

\n\n'},{title:"Ajv online event - May 20, 10am PT / 6pm UK",frontmatter:{news:!0,title:"Ajv online event - May 20, 10am PT / 6pm UK",date:"2021-04-24T00:00:00.000Z",more:!1},regularPath:"/news/2021-04-24-ajv-online-event.html",relativePath:"news/2021-04-24-ajv-online-event.md",key:"v-5a94ae89",path:"/news/2021-04-24-ajv-online-event.html",excerpt:'

We will talk about:

\n
    \n
  • new features of Ajv version 8.
  • \n
  • the improvements sponsored by Mozilla\'s MOSS grant.
  • \n
  • how Ajv is used in JavaScript applications.
  • \n
\n

Speakers:

\n
    \n
  • Evgeny Poberezkin, the creator of Ajv.
  • \n
  • Mehan Jayasuriya, Program Officer at Mozilla Foundation, leading the MOSS and other programs investing in the open source and community ecosystems.
  • \n
  • Matteo Collina, Technical Director at NearForm and Node.js Technical Steering Committee member, creator of Fastify web framework.
  • \n
  • Kin Lane, Chief Evangelist at Postman. Studying the tech, business & politics of APIs since 2010. Presidential Innovation Fellow during the Obama administration.
  • \n
  • Ulysse Carion, the creator of JSON Type Definition specification.
  • \n
\n

Gajus Kuizinas will host the event.

\n

Please register here.

\n'},{title:"Ajv online event video uploaded",frontmatter:{news:!0,title:"Ajv online event video uploaded",date:"2021-05-24T00:00:00.000Z",more:!1},regularPath:"/news/2021-05-24-ajv-online-event-video.html",relativePath:"news/2021-05-24-ajv-online-event-video.md",key:"v-2abeb1ab",path:"/news/2021-05-24-ajv-online-event-video.html",excerpt:'

Huge thanks to everybody who joined, and to the speakers! The video of the event is available on YouTube.

\n'},{title:"Microsoft FOSS award",frontmatter:{news:!0,title:"Microsoft FOSS award",date:"2021-07-22T00:00:00.000Z",more:!1},regularPath:"/news/2021-07-22-ajv-microsoft-foss-fund-award.html",relativePath:"news/2021-07-22-ajv-microsoft-foss-fund-award.md",key:"v-959a2c2e",path:"/news/2021-07-22-ajv-microsoft-foss-fund-award.html",excerpt:'

Ajv was awarded a sponsorship from Microsoft FOSS fund - huge thanks to Microsoft and the engineers who voted to support Ajv development.

\n

This award will contribute to a long term maintenance of Ajv.

\n'},{title:"Ajv News",frontmatter:{newsIndex:!0,editLink:!1},regularPath:"/news/",relativePath:"news/README.md",key:"v-506a67bc",path:"/news/"},{title:"Extending Ajv",frontmatter:{},regularPath:"/packages/",relativePath:"packages/README.md",key:"v-07fb5e62",path:"/packages/",headers:[{level:2,title:"Plugins",slug:"plugins"},{level:2,title:"Related packages",slug:"related-packages"}]},{title:"Ajv options",frontmatter:{},regularPath:"/options.html",relativePath:"options.md",key:"v-7bf93309",path:"/options.html",headers:[{level:2,title:"Usage",slug:"usage"},{level:2,title:"Option defaults",slug:"option-defaults"},{level:2,title:"Strict mode options",slug:"strict-mode-options"},{level:3,title:"strict",slug:"strict"},{level:3,title:"strictSchema",slug:"strictschema"},{level:3,title:"strictNumbers",slug:"strictnumbers"},{level:3,title:"strictTypes",slug:"stricttypes"},{level:3,title:"strictTuples",slug:"stricttuples"},{level:3,title:"strictRequired",slug:"strictrequired"},{level:3,title:"allowUnionTypes",slug:"allowuniontypes"},{level:3,title:"allowMatchingProperties",slug:"allowmatchingproperties"},{level:3,title:"validateFormats",slug:"validateformats"},{level:2,title:"Validation and reporting options",slug:"validation-and-reporting-options"},{level:3,title:"$data",slug:"data"},{level:3,title:"allErrors",slug:"allerrors"},{level:3,title:"verbose",slug:"verbose"},{level:3,title:"discriminator",slug:"discriminator"},{level:3,title:"unicodeRegExp",slug:"unicoderegexp"},{level:3,title:"timestamp",slug:"timestamp"},{level:3,title:"parseDate",slug:"parsedate"},{level:3,title:"allowDate",slug:"allowdate"},{level:3,title:"int32range",slug:"int32range"},{level:3,title:"$comment",slug:"comment"},{level:3,title:"formats",slug:"formats"},{level:3,title:"keywords",slug:"keywords"},{level:3,title:"schemas",slug:"schemas"},{level:3,title:"logger",slug:"logger"},{level:3,title:"loadSchema",slug:"loadschema"},{level:2,title:"Options to modify validated data",slug:"options-to-modify-validated-data"},{level:3,title:"removeAdditional",slug:"removeadditional"},{level:3,title:"useDefaults",slug:"usedefaults"},{level:3,title:"coerceTypes",slug:"coercetypes"},{level:2,title:"Advanced options",slug:"advanced-options"},{level:3,title:"meta",slug:"meta"},{level:3,title:"validateSchema",slug:"validateschema"},{level:3,title:"addUsedSchema",slug:"addusedschema"},{level:3,title:"inlineRefs",slug:"inlinerefs"},{level:3,title:"passContext",slug:"passcontext"},{level:3,title:"loopRequired",slug:"looprequired"},{level:3,title:"loopEnum",slug:"loopenum"},{level:3,title:"ownProperties",slug:"ownproperties"},{level:3,title:"multipleOfPrecision",slug:"multipleofprecision"},{level:3,title:"messages",slug:"messages"},{level:3,title:"uriResolver",slug:"uriresolver"},{level:3,title:"code",slug:"code"}]},{frontmatter:{editLink:"https://github.com/ajv-validator/ajv-cli/edit/master/README.md"},regularPath:"/packages/ajv-cli.html",relativePath:"packages/ajv-cli.md",key:"v-19f2c039",path:"/packages/ajv-cli.html",headers:[{level:2,title:"Contents",slug:"contents"},{level:2,title:"Installation",slug:"installation"},{level:2,title:"JSON schema language and version",slug:"json-schema-language-and-version"},{level:2,title:"Commands",slug:"commands"},{level:3,title:"Help command",slug:"help-command"},{level:3,title:"Validate data",slug:"validate-data"},{level:3,title:"Compile schemas",slug:"compile-schemas"},{level:3,title:"Migrate schemas",slug:"migrate-schemas"},{level:3,title:"Test validation result",slug:"test-validation-result"},{level:2,title:"Ajv options",slug:"ajv-options"},{level:2,title:"Version History",slug:"version-history"},{level:2,title:"Licence",slug:"licence"}]},{frontmatter:{editLink:"https://github.com/ajv-validator/ajv-errors/edit/master/README.md"},regularPath:"/packages/ajv-errors.html",relativePath:"packages/ajv-errors.md",key:"v-b99d2c2e",path:"/packages/ajv-errors.html",headers:[{level:2,title:"Contents",slug:"contents"},{level:2,title:"Install",slug:"install"},{level:2,title:"Usage",slug:"usage"},{level:3,title:"Single message",slug:"single-message"},{level:3,title:"Messages for keywords",slug:"messages-for-keywords"},{level:3,title:"Messages for properties and items",slug:"messages-for-properties-and-items"},{level:3,title:"Default message",slug:"default-message"},{level:2,title:"Templates",slug:"templates"},{level:2,title:"Options",slug:"options"},{level:2,title:"Supporters",slug:"supporters"},{level:2,title:"Enterprise support",slug:"enterprise-support"},{level:2,title:"Security contact",slug:"security-contact"},{level:2,title:"License",slug:"license"}]},{frontmatter:{editLink:"https://github.com/ajv-validator/ajv-i18n/edit/master/README.md"},regularPath:"/packages/ajv-i18n.html",relativePath:"packages/ajv-i18n.md",key:"v-7f55ccc9",path:"/packages/ajv-i18n.html",headers:[{level:2,title:"Supported locales",slug:"supported-locales"},{level:2,title:"Install",slug:"install"},{level:2,title:"Usage",slug:"usage"},{level:2,title:"Tests",slug:"tests"},{level:2,title:"Contributing",slug:"contributing"},{level:2,title:"Contributors of locales",slug:"contributors-of-locales"},{level:2,title:"Enterprise support",slug:"enterprise-support"},{level:2,title:"Security contact",slug:"security-contact"},{level:2,title:"License",slug:"license"}]},{frontmatter:{editLink:"https://github.com/ajv-validator/ajv-keywords/edit/master/README.md"},regularPath:"/packages/ajv-keywords.html",relativePath:"packages/ajv-keywords.md",key:"v-bf7e876e",path:"/packages/ajv-keywords.html",headers:[{level:2,title:"Contents",slug:"contents"},{level:2,title:"Install",slug:"install"},{level:2,title:"Usage",slug:"usage"},{level:2,title:"Keywords",slug:"keywords"},{level:3,title:"Types",slug:"types"},{level:3,title:"Keywords for numbers",slug:"keywords-for-numbers"},{level:3,title:"Keywords for strings",slug:"keywords-for-strings"},{level:3,title:"Keywords for arrays",slug:"keywords-for-arrays"},{level:3,title:"Keywords for objects",slug:"keywords-for-objects"},{level:3,title:"Keywords for all types",slug:"keywords-for-all-types"},{level:2,title:"Security contact",slug:"security-contact"},{level:2,title:"Open-source software support",slug:"open-source-software-support"},{level:2,title:"License",slug:"license"}]},{title:"Security considerations",frontmatter:{},regularPath:"/security.html",relativePath:"security.md",key:"v-bb53a316",path:"/security.html",headers:[{level:2,title:"Security contact",slug:"security-contact"},{level:2,title:"Untrusted schemas",slug:"untrusted-schemas"},{level:2,title:"Circular references in JavaScript objects",slug:"circular-references-in-javascript-objects"},{level:2,title:"Security risks of trusted schemas",slug:"security-risks-of-trusted-schemas"},{level:2,title:"ReDoS attack",slug:"redos-attack"},{level:2,title:"Content Security Policy",slug:"content-security-policy"}]},{title:"Standalone validation code",frontmatter:{},regularPath:"/standalone.html",relativePath:"standalone.md",key:"v-20f55eeb",path:"/standalone.html",headers:[{level:2,title:"Two-step process",slug:"two-step-process"},{level:3,title:"Generating function(s) using CLI",slug:"generating-function-s-using-cli"},{level:3,title:"Generating using the JS library",slug:"generating-using-the-js-library"},{level:2,title:"Using the validation function(s)",slug:"using-the-validation-function-s"},{level:3,title:"Validating a single schemas using the JS library - ES6 and CJS",slug:"validating-a-single-schemas-using-the-js-library-es6-and-cjs"},{level:3,title:"Validating multiple schemas using the JS library - ES6 and CJS",slug:"validating-multiple-schemas-using-the-js-library-es6-and-cjs"},{level:3,title:"Validating multiple schemas using the JS library - ES6 and ESM",slug:"validating-multiple-schemas-using-the-js-library-es6-and-esm"},{level:3,title:"Requirement at runtime",slug:"requirement-at-runtime"},{level:2,title:"Configuration and limitations",slug:"configuration-and-limitations"}]},{frontmatter:{editLink:"https://github.com/ajv-validator/ajv-formats/edit/master/README.md"},regularPath:"/packages/ajv-formats.html",relativePath:"packages/ajv-formats.md",key:"v-6731dec1",path:"/packages/ajv-formats.html",headers:[{level:2,title:"Usage",slug:"usage"},{level:2,title:"Formats",slug:"formats"},{level:2,title:"Keywords to compare values: formatMaximum / formatMinimum and formatExclusiveMaximum / formatExclusiveMinimum",slug:"keywords-to-compare-values-formatmaximum-formatminimum-and-formatexclusivemaximum-formatexclusiveminimum"},{level:2,title:"Options",slug:"options"},{level:2,title:"Tests",slug:"tests"},{level:2,title:"License",slug:"license"}]},{title:"Changes from Ajv v6.12.6 to v8.0.0",frontmatter:{},regularPath:"/v6-to-v8-migration.html",relativePath:"v6-to-v8-migration.md",key:"v-114a7465",path:"/v6-to-v8-migration.html",headers:[{level:2,title:"New features",slug:"new-features"},{level:2,title:"Better TypeScript support",slug:"better-typescript-support"},{level:2,title:"Potential migration difficulties",slug:"potential-migration-difficulties"},{level:2,title:"API changes",slug:"api-changes"},{level:3,title:"Added options",slug:"added-options"},{level:3,title:"Changed options",slug:"changed-options"},{level:3,title:"Removed options",slug:"removed-options"}]},{title:"What users say",frontmatter:{},regularPath:"/testimonials.html",relativePath:"testimonials.md",key:"v-90fdf4e6",path:"/testimonials.html"},{title:"Strict mode",frontmatter:{},regularPath:"/strict-mode.html",relativePath:"strict-mode.md",key:"v-74774829",path:"/strict-mode.html",headers:[{level:2,title:"JSON Type Definition schemas",slug:"json-type-definition-schemas"},{level:2,title:"JSON Schema schemas",slug:"json-schema-schemas"},{level:3,title:"Prohibit ignored keywords",slug:"prohibit-ignored-keywords"},{level:3,title:"Prevent unexpected validation",slug:"prevent-unexpected-validation"},{level:3,title:"Strict types",slug:"strict-types"},{level:3,title:"Strict number validation",slug:"strict-number-validation"}]}],themeConfig:{logo:"/img/ajv.svg",nav:[{text:"Home",link:"/"},{text:"Guide",items:[{link:"/guide/why-ajv",text:"Why use Ajv"},{link:"/guide/getting-started",text:"Getting started"},{link:"/guide/typescript",text:"Using with TypeScript"},{link:"/guide/schema-language",text:"Choosing schema language"},{link:"/guide/managing-schemas",text:"Managing schemas"},{link:"/guide/combining-schemas",text:"Combining schemas"},{link:"/guide/formats",text:"Format validation"},{link:"/guide/modifying-data",text:"Modifying data"},{link:"/guide/user-keywords",text:"User-defined keywords"},{link:"/guide/async-validation",text:"Asynchronous validation"},{link:"/guide/environments",text:"Execution environments"}]},{text:"Reference",items:[{link:"/api",text:"API Reference"},{link:"/options",text:"Ajv options"},{link:"/json-schema",text:"JSON Schema"},{link:"/json-type-definition",text:"JSON Type Definition"},{link:"/strict-mode",text:"Strict mode"},{link:"/standalone",text:"Standalone validation code"},{link:"/keywords",text:"User defined keywords"},{link:"/coercion",text:"Type coercion rules"}]},{text:"Learn more",items:[{text:"Extending Ajv",items:[{link:"/packages/",text:"Extending Ajv"},{link:"/packages/ajv-cli",text:"ajv-cli"},{link:"/packages/ajv-errors",text:"ajv-errors"},{link:"/packages/ajv-formats",text:"ajv-formats"},{link:"/packages/ajv-i18n",text:"ajv-i18n"},{link:"/packages/ajv-keywords",text:"ajv-keywords"}]},{text:"Contributors",items:[{link:"/contributing",text:"Contributing guide"},{link:"/codegen",text:"Code generation design"},{link:"/components",text:"Code components"},{link:"/code_of_conduct",text:"Code of Conduct"}]},{text:"Information",items:[{link:"/news/",text:"News"},{link:"/faq",text:"FAQ"},{link:"/security",text:"Security"},{link:"/v6-to-v8-migration",text:"Migrate from v6"},{link:"/testimonials",text:"What users say"},{link:"/license",text:"License"}]}]}],sidebar:[{title:"Guide",children:["/guide/why-ajv","/guide/getting-started","/guide/typescript","/guide/schema-language","/guide/managing-schemas","/guide/combining-schemas","/guide/formats","/guide/modifying-data","/guide/user-keywords","/guide/async-validation","/guide/environments"]},{title:"Reference",children:["/api","/options","/json-schema","/json-type-definition","/strict-mode","/standalone","/keywords","/coercion"]},{title:"Extending Ajv",children:[["/packages/","Extending Ajv"],["/packages/ajv-formats","ajv-formats"],["/packages/ajv-keywords","ajv-keywords"],["/packages/ajv-errors","ajv-errors"],["/packages/ajv-i18n","ajv-i18n"],["/packages/ajv-cli","ajv-cli"]]},{title:"Contributors",children:["/contributing","/codegen","/components",["/code_of_conduct","Code of conduct"]]},{title:"Information",children:["/news/","/faq","/security",["/v6-to-v8-migration","Migrate from v6 to v8"],"/testimonials",["/license","License"]]}],repo:"ajv-validator/ajv",docsDir:"docs",editLinks:!0,activeHeaderLinks:!1}};n(233);Kn.component("Button",()=>Promise.all([n.e(0),n.e(25)]).then(n.bind(null,377))),Kn.component("Column",()=>Promise.all([n.e(0),n.e(26)]).then(n.bind(null,378))),Kn.component("Columns",()=>Promise.all([n.e(0),n.e(27)]).then(n.bind(null,434))),Kn.component("Contributors",()=>Promise.all([n.e(0),n.e(21)]).then(n.bind(null,379))),Kn.component("Feature",()=>Promise.all([n.e(0),n.e(22)]).then(n.bind(null,380))),Kn.component("Features",()=>Promise.all([n.e(0),n.e(28)]).then(n.bind(null,435))),Kn.component("FooterColumn",()=>Promise.all([n.e(0),n.e(29)]).then(n.bind(null,381))),Kn.component("FooterColumns",()=>Promise.all([n.e(0),n.e(30)]).then(n.bind(null,436))),Kn.component("GitHub",()=>Promise.all([n.e(0),n.e(31)]).then(n.bind(null,382))),Kn.component("HeroSection",()=>Promise.all([n.e(0),n.e(23)]).then(n.bind(null,437))),Kn.component("HomePage",()=>Promise.all([n.e(0),n.e(32)]).then(n.bind(null,438))),Kn.component("HomeSection",()=>Promise.all([n.e(0),n.e(33)]).then(n.bind(null,383))),Kn.component("NewsHome",()=>Promise.all([n.e(0),n.e(34)]).then(n.bind(null,384))),Kn.component("NewsIndex",()=>n.e(43).then(n.bind(null,385))),Kn.component("NewsPost",()=>Promise.all([n.e(0),n.e(14)]).then(n.bind(null,386))),Kn.component("NewsPostMeta",()=>Promise.all([n.e(0),n.e(18)]).then(n.bind(null,387))),Kn.component("Projects",()=>Promise.all([n.e(0),n.e(35)]).then(n.bind(null,439))),Kn.component("Sponsors",()=>Promise.all([n.e(0),n.e(36)]).then(n.bind(null,388))),Kn.component("Subscribe",()=>Promise.all([n.e(0),n.e(37)]).then(n.bind(null,440))),Kn.component("Testimonial",()=>Promise.all([n.e(0),n.e(38)]).then(n.bind(null,389))),Kn.component("Testimonials",()=>Promise.all([n.e(0),n.e(39)]).then(n.bind(null,441))),Kn.component("Badge",()=>Promise.all([n.e(0),n.e(4)]).then(n.bind(null,390))),Kn.component("CodeBlock",()=>Promise.all([n.e(0),n.e(5)]).then(n.bind(null,373))),Kn.component("CodeGroup",()=>Promise.all([n.e(0),n.e(6)]).then(n.bind(null,374)));n(234);var Es=[{},({Vue:e})=>{e.mixin({computed:{$dataBlock(){return this.$options.__data__block__}}})},{},{}],As=[];class Ts extends class{constructor(){this.store=new Kn({data:{state:{}}})}$get(e){return this.store.state[e]}$set(e,t){Kn.set(this.store.state,e,t)}$emit(...e){this.store.$emit(...e)}$on(...e){this.store.$on(...e)}}{}Object.assign(Ts.prototype,{getPageAsyncComponent:ss,getLayoutAsyncComponent:ls,getAsyncComponent:us,getVueComponent:cs});var Ls={install(e){const t=new Ts;e.$vuepress=t,e.prototype.$vuepress=t}};function Rs(e,t){const n=t.toLowerCase();return e.options.routes.some(e=>e.path.toLowerCase()===n)}var Ms={props:{pageKey:String,slotKey:{type:String,default:"default"}},render(e){const t=this.pageKey||this.$parent.$page.key;return ps("pageKey",t),Kn.component(t)||Kn.component(t,ss(t)),Kn.component(t)?e(t):e("")}},Ns={functional:!0,props:{slotKey:String,required:!0},render:(e,{props:t,slots:n})=>e("div",{class:["content__"+t.slotKey]},n()[t.slotKey])},Is={computed:{openInNewWindowTitle(){return this.$themeLocaleConfig.openNewWindowText||"(opens new window)"}}},Ds=(n(235),n(236),Object(Os.a)(Is,(function(){var e=this._self._c;return e("span",[e("svg",{staticClass:"icon outbound",attrs:{xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",focusable:"false",x:"0px",y:"0px",viewBox:"0 0 100 100",width:"15",height:"15"}},[e("path",{attrs:{fill:"currentColor",d:"M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"}}),this._v(" "),e("polygon",{attrs:{fill:"currentColor",points:"45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"}})]),this._v(" "),e("span",{staticClass:"sr-only"},[this._v(this._s(this.openInNewWindowTitle))])])}),[],!1,null,null,null).exports),Fs={functional:!0,render(e,{parent:t,children:n}){if(t._isMounted)return n;t.$once("hook:mounted",()=>{t.$forceUpdate()})}};Kn.config.productionTip=!1,Kn.use(Va),Kn.use(Ls),Kn.mixin(function(e,t,n=Kn){!function(e){e.locales&&Object.keys(e.locales).forEach(t=>{e.locales[t].path=t});Object.freeze(e)}(t),n.$vuepress.$set("siteData",t);const r=new(e(n.$vuepress.$get("siteData"))),o=Object.getOwnPropertyDescriptors(Object.getPrototypeOf(r)),i={};return Object.keys(o).reduce((e,t)=>(t.startsWith("$")&&(e[t]=o[t].get),e),i),{computed:i}}(e=>class{setPage(e){this.__page=e}get $site(){return e}get $themeConfig(){return this.$site.themeConfig}get $frontmatter(){return this.$page.frontmatter}get $localeConfig(){const{locales:e={}}=this.$site;let t,n;for(const r in e)"/"===r?n=e[r]:0===this.$page.path.indexOf(r)&&(t=e[r]);return t||n||{}}get $siteTitle(){return this.$localeConfig.title||this.$site.title||""}get $canonicalUrl(){const{canonicalUrl:e}=this.$page.frontmatter;return"string"==typeof e&&e}get $title(){const e=this.$page,{metaTitle:t}=this.$page.frontmatter;if("string"==typeof t)return t;const n=this.$siteTitle,r=e.frontmatter.home?null:e.frontmatter.title||e.title;return n?r?r+" | "+n:n:r||"VuePress"}get $description(){const e=function(e){if(e){const t=e.filter(e=>"description"===e.name)[0];if(t)return t.content}}(this.$page.frontmatter.meta);return e||(this.$page.frontmatter.description||this.$localeConfig.description||this.$site.description||"")}get $lang(){return this.$page.frontmatter.lang||this.$localeConfig.lang||"en-US"}get $localePath(){return this.$localeConfig.path||"/"}get $themeLocaleConfig(){return(this.$site.themeConfig.locales||{})[this.$localePath]||{}}get $page(){return this.__page?this.__page:function(e,t){for(let n=0;nn||(e.hash?!Kn.$vuepress.$get("disableScrollBehavior")&&{selector:decodeURIComponent(e.hash)}:{x:0,y:0})});!function(e){e.beforeEach((t,n,r)=>{if(Rs(e,t.path))r();else if(/(\/|\.html)$/.test(t.path))if(/\/$/.test(t.path)){const n=t.path.replace(/\/$/,"")+".html";Rs(e,n)?r(n):r()}else r();else{const n=t.path+"/",o=t.path+".html";Rs(e,o)?r(o):Rs(e,n)?r(n):r()}})}(n);const r={};try{await Promise.all(Es.filter(e=>"function"==typeof e).map(t=>t({Vue:Kn,options:r,router:n,siteData:$s,isServer:e})))}catch(e){console.error(e)}return{app:new Kn(Object.assign(r,{router:n,render:e=>e("div",{attrs:{id:"app"}},[e("RouterView",{ref:"layout"}),e("div",{class:"global-ui"},As.map(t=>e(t)))])})),router:n}}(!1).then(({app:e,router:t})=>{t.onReady(()=>{e.$mount("#app")})})}]); \ No newline at end of file diff --git a/code_of_conduct/index.html b/code_of_conduct/index.html index 1324f611a..071f8199e 100644 --- a/code_of_conduct/index.html +++ b/code_of_conduct/index.html @@ -18,7 +18,7 @@ - + @@ -190,6 +190,6 @@ →

- + diff --git a/codegen.html b/codegen.html index ec1ad3d17..72daf1123 100644 --- a/codegen.html +++ b/codegen.html @@ -18,7 +18,7 @@ - + @@ -213,6 +213,6 @@ →

- + diff --git a/coercion.html b/coercion.html index 9326c0a15..a72f0ebb3 100644 --- a/coercion.html +++ b/coercion.html @@ -18,7 +18,7 @@ - + @@ -187,6 +187,6 @@ →

- + diff --git a/components.html b/components.html index 2c83e9f5e..f800c5979 100644 --- a/components.html +++ b/components.html @@ -18,7 +18,7 @@ - + @@ -187,6 +187,6 @@ →

- + diff --git a/contributing/index.html b/contributing/index.html index 484d41158..7ef11d588 100644 --- a/contributing/index.html +++ b/contributing/index.html @@ -18,7 +18,7 @@ - + @@ -192,6 +192,6 @@ →

- + diff --git a/faq.html b/faq.html index b7b2c0d25..d71038129 100644 --- a/faq.html +++ b/faq.html @@ -18,7 +18,7 @@ - + @@ -196,6 +196,6 @@ →

- + diff --git a/guide/async-validation.html b/guide/async-validation.html index 95e5bd50a..b73f32852 100644 --- a/guide/async-validation.html +++ b/guide/async-validation.html @@ -18,7 +18,7 @@ - + @@ -230,6 +230,6 @@ →

- + diff --git a/guide/combining-schemas.html b/guide/combining-schemas.html index 984769803..72f27b7c8 100644 --- a/guide/combining-schemas.html +++ b/guide/combining-schemas.html @@ -18,7 +18,7 @@ - + @@ -306,6 +306,6 @@ →

- + diff --git a/guide/environments.html b/guide/environments.html index 2877bdd04..19f0360b8 100644 --- a/guide/environments.html +++ b/guide/environments.html @@ -18,7 +18,7 @@ - + @@ -190,6 +190,6 @@ →

- + diff --git a/guide/formats.html b/guide/formats.html index 39e4507d8..4255169f4 100644 --- a/guide/formats.html +++ b/guide/formats.html @@ -18,7 +18,7 @@ - + @@ -192,6 +192,6 @@ →

- + diff --git a/guide/getting-started.html b/guide/getting-started.html index 31f391669..7a9c47f61 100644 --- a/guide/getting-started.html +++ b/guide/getting-started.html @@ -18,7 +18,7 @@ - + @@ -194,6 +194,6 @@ →

- + diff --git a/guide/managing-schemas.html b/guide/managing-schemas.html index e458eed72..0d67f662f 100644 --- a/guide/managing-schemas.html +++ b/guide/managing-schemas.html @@ -18,7 +18,7 @@ - + @@ -208,6 +208,6 @@ →

- + diff --git a/guide/modifying-data.html b/guide/modifying-data.html index a925394c2..27b27b506 100644 --- a/guide/modifying-data.html +++ b/guide/modifying-data.html @@ -18,7 +18,7 @@ - + @@ -322,6 +322,6 @@ →

- + diff --git a/guide/schema-language.html b/guide/schema-language.html index b31170512..901decd83 100644 --- a/guide/schema-language.html +++ b/guide/schema-language.html @@ -18,7 +18,7 @@ - + @@ -198,6 +198,6 @@ →

- + diff --git a/guide/typescript.html b/guide/typescript.html index 8a66664ce..e37518bd6 100644 --- a/guide/typescript.html +++ b/guide/typescript.html @@ -18,7 +18,7 @@ - + @@ -189,6 +189,6 @@ →

- + diff --git a/guide/user-keywords.html b/guide/user-keywords.html index 83f8966ce..fa375fa08 100644 --- a/guide/user-keywords.html +++ b/guide/user-keywords.html @@ -18,7 +18,7 @@ - + @@ -204,6 +204,6 @@ →

- + diff --git a/guide/why-ajv.html b/guide/why-ajv.html index 2465d544c..81146ae72 100644 --- a/guide/why-ajv.html +++ b/guide/why-ajv.html @@ -18,7 +18,7 @@ - + @@ -183,6 +183,6 @@ →

- + diff --git a/index.html b/index.html index efc528e72..c769b92a3 100644 --- a/index.html +++ b/index.html @@ -18,7 +18,7 @@ - + @@ -566,6 +566,6 @@ jboavida
- + diff --git a/json-schema.html b/json-schema.html index 6d9ecf167..38fdc6c13 100644 --- a/json-schema.html +++ b/json-schema.html @@ -18,7 +18,7 @@ - + @@ -185,7 +185,7 @@

and

{
   "type": ["string", "null"]
 }
-

nullable does not extend enum and const

If you use enum or const keywords, "nullable": true would not extend the list of allowed values - null value has to be explicitly added to enum (and const would fail, unless it is "const": null)

This is different from how nullable is defined in JSON Type Definition, where "nullable": true allows null value in addition to any data defined by the schema.

# Keywords for numbers

# maximum / minimum and exclusiveMaximum / exclusiveMinimum

The value of keyword maximum (minimum) should be a number. This value is the maximum (minimum) allowed value for the data to be valid.

The value of keyword exclusiveMaximum (exclusiveMinimum) should be a number. This value is the exclusive maximum (minimum) allowed value for the data to be valid (the data equal to this keyword value is invalid).

NO support for boolean keyword values

Boolean values for keywords exclusiveMaximum (exclusiveMinimum) are not supported.

Examples

  1. schema: {type: "number", maximum: 5}

    valid: 4, 5

    invalid: 6, 7

  2. schema: {type: "number", minimum: 5}

    valid: 5, 6

    invalid: 4, 4.5

  3. schema: {type: "number", exclusiveMinimum: 5}

    valid: 6, 7

    invalid: 4.5, 5

# multipleOf

The value of the keyword should be a number. The data to be valid should be a multiple of the keyword value (i.e. the result of division of the data on the value should be integer).

Examples

  1. schema: {type: "number", multipleOf: 5}

    valid: 5, 10

    invalid: 1, 4

  1. schema: {type: "number", multipleOf: 2.5}

    valid: 2.5, 5, 7.5

    invalid: 1, 4

# Keywords for strings

# maxLength / minLength

[Grapheme clusters](https://www.unicode.org/reports/tr29/tr29-17.html#Grapheme_Cluster_Boundaries) will count as multiple characters

Certain charsets have characters that are made up of multiple unicode characters. These "grapheme clusters" are counted as multiple characters.

The value of the keywords should be a number. The data to be valid should have length satisfying this rule. Unicode pairs are counted as a single character.

Examples

  1. schema: {type: "string", maxLength: 5}

    valid: "abc", "abcde"

    invalid: "abcdef"

  1. schema: {type: "string", minLength: 2}

    valid: "ab", "😀😀"

    invalid: "a", "😀"

# pattern

The value of the keyword should be a string. The data to be valid should match the regular expression defined by the keyword value.

Ajv uses new RegExp(value, "u") to create the regular expression that will be used to test data.

Example

schema: {type: "string", pattern: "[abc]+"}

valid: "a", "abcd", "cde"

invalid: "def", ""

# format

The value of the keyword should be a string. The data to be valid should match the format with this name.

Ajv does not include any formats, they can be added with ajv-formats (opens new window) plugin.

Example

schema: {type: "string", format: "ipv4"}

valid: "192.168.0.1"

invalid: "abc"

# Keywords for arrays

# maxItems / minItems

The value of the keywords should be a number. The data array to be valid should not have more (less) items than the keyword value.

Example

schema: {type: "array", maxItems: 3}

valid: [], [1], ["1", 2, "3"]

invalid: [1, 2, 3, 4]

# uniqueItems

The value of the keyword should be a boolean. If the keyword value is true, the data array to be valid should have unique items.

Example

schema: {type: "array", uniqueItems: true}

valid: [], [1], ["1", 2, "3"]

invalid: [1, 2, 1], [{a: 1, b: 2}, {b: 2, a: 1}]

# items

# items in draft-04, -06, -07 and -2019-09

items keyword changed in JSON Schema draft-2020-12

This section describes items keyword in all JSON Schema versions prior to draft-2020-12.

The value of the keyword should be a schema or an array of schemas.

If the keyword value is a schema, then for the data array to be valid each item of the array should be valid according to the schema. In this case the additionalItems keyword is ignored.

If the keyword value is an array, then items with indices less than the number of items in the keyword should be valid according to the schemas with the same indices. Whether additional items are valid will depend on additionalItems keyword.

Examples

  1. schema: {type: "array", items: {type: "integer"}}

    valid: [1,2,3], []

    invalid: [1,"abc"]

  2. schema:

    {
    +

    nullable does not extend enum and const

    If you use enum or const keywords, "nullable": true would not extend the list of allowed values - null value has to be explicitly added to enum (and const would fail, unless it is "const": null)

    This is different from how nullable is defined in JSON Type Definition, where "nullable": true allows null value in addition to any data defined by the schema.

    # Keywords for numbers

    # maximum / minimum and exclusiveMaximum / exclusiveMinimum

    The value of keyword maximum (minimum) should be a number. This value is the maximum (minimum) allowed value for the data to be valid.

    The value of keyword exclusiveMaximum (exclusiveMinimum) should be a number. This value is the exclusive maximum (minimum) allowed value for the data to be valid (the data equal to this keyword value is invalid).

    NO support for boolean keyword values

    Boolean values for keywords exclusiveMaximum (exclusiveMinimum) are not supported.

    Examples

    1. schema: {type: "number", maximum: 5}

      valid: 4, 5

      invalid: 6, 7

    2. schema: {type: "number", minimum: 5}

      valid: 5, 6

      invalid: 4, 4.5

    3. schema: {type: "number", exclusiveMinimum: 5}

      valid: 6, 7

      invalid: 4.5, 5

    # multipleOf

    The value of the keyword should be a number. The data to be valid should be a multiple of the keyword value (i.e. the result of division of the data on the value should be integer).

    Examples

    1. schema: {type: "number", multipleOf: 5}

      valid: 5, 10

      invalid: 1, 4

    1. schema: {type: "number", multipleOf: 2.5}

      valid: 2.5, 5, 7.5

      invalid: 1, 4

    # Keywords for strings

    # maxLength / minLength

    Grapheme clusters will count as multiple characters

    Certain charsets have characters that are made up of multiple Unicode code points. These grapheme clusters (opens new window) are counted as multiple in length calculations.

    The value of the keywords should be a number. The data to be valid should have length satisfying this rule. Unicode pairs are counted as a single character.

    Examples

    1. schema: {type: "string", maxLength: 5}

      valid: "abc", "abcde"

      invalid: "abcdef"

    1. schema: {type: "string", minLength: 2}

      valid: "ab", "😀😀"

      invalid: "a", "😀"

    # pattern

    The value of the keyword should be a string. The data to be valid should match the regular expression defined by the keyword value.

    Ajv uses new RegExp(value, "u") to create the regular expression that will be used to test data.

    Example

    schema: {type: "string", pattern: "[abc]+"}

    valid: "a", "abcd", "cde"

    invalid: "def", ""

    # format

    The value of the keyword should be a string. The data to be valid should match the format with this name.

    Ajv does not include any formats, they can be added with ajv-formats (opens new window) plugin.

    Example

    schema: {type: "string", format: "ipv4"}

    valid: "192.168.0.1"

    invalid: "abc"

    # Keywords for arrays

    # maxItems / minItems

    The value of the keywords should be a number. The data array to be valid should not have more (less) items than the keyword value.

    Example

    schema: {type: "array", maxItems: 3}

    valid: [], [1], ["1", 2, "3"]

    invalid: [1, 2, 3, 4]

    # uniqueItems

    The value of the keyword should be a boolean. If the keyword value is true, the data array to be valid should have unique items.

    Example

    schema: {type: "array", uniqueItems: true}

    valid: [], [1], ["1", 2, "3"]

    invalid: [1, 2, 1], [{a: 1, b: 2}, {b: 2, a: 1}]

    # items

    # items in draft-04, -06, -07 and -2019-09

    items keyword changed in JSON Schema draft-2020-12

    This section describes items keyword in all JSON Schema versions prior to draft-2020-12.

    The value of the keyword should be a schema or an array of schemas.

    If the keyword value is a schema, then for the data array to be valid each item of the array should be valid according to the schema. In this case the additionalItems keyword is ignored.

    If the keyword value is an array, then items with indices less than the number of items in the keyword should be valid according to the schemas with the same indices. Whether additional items are valid will depend on additionalItems keyword.

    Examples

    1. schema: {type: "array", items: {type: "integer"}}

      valid: [1,2,3], []

      invalid: [1,"abc"]

    2. schema:

      {
         type: "array",
         items: [{type: "integer"}, {type: "string"}]
       }
      @@ -419,6 +419,6 @@
             
             →
           

      - + diff --git a/json-type-definition.html b/json-type-definition.html index f07903061..00cab0610 100644 --- a/json-type-definition.html +++ b/json-type-definition.html @@ -18,7 +18,7 @@ - + @@ -331,6 +331,6 @@ →

      - + diff --git a/keywords.html b/keywords.html index 1bad72fe9..e9deb6c60 100644 --- a/keywords.html +++ b/keywords.html @@ -18,7 +18,7 @@ - + @@ -324,6 +324,6 @@ →

      - + diff --git a/license.html b/license.html index 612aec991..e79c2d067 100644 --- a/license.html +++ b/license.html @@ -18,7 +18,7 @@ - + @@ -195,6 +195,6 @@

      - + diff --git a/news/2020-08-14-mozilla-grant-openjs-foundation.html b/news/2020-08-14-mozilla-grant-openjs-foundation.html index 1521b4ccd..337dc14f4 100644 --- a/news/2020-08-14-mozilla-grant-openjs-foundation.html +++ b/news/2020-08-14-mozilla-grant-openjs-foundation.html @@ -18,7 +18,7 @@ - + @@ -181,6 +181,6 @@
    3. Mozilla MOSS grant and OpenJS Foundation

      (opens new window) (opens new window)

      Ajv has been awarded a grant from Mozilla’s Open Source Support (MOSS) program (opens new window) in the “Foundational Technology” track! It will sponsor the development of Ajv support of JSON Schema version 2019-09 (opens new window) and of JSON Type Definition (RFC8927) (opens new window).

      Ajv also joined OpenJS Foundation (opens new window) – having this support will help ensure the longevity and stability of Ajv for all its users.

      This blog post (opens new window) has more details.

      I am looking for the long term maintainers of Ajv – working with ReadySet (opens new window), also sponsored by Mozilla, to establish clear guidelines for the role of a "maintainer" and the contribution standards, and to encourage a wider, more inclusive, contribution from the community.

      - + diff --git a/news/2020-12-15-ajv-version-7-released.html b/news/2020-12-15-ajv-version-7-released.html index 975c7377b..d55fd536c 100644 --- a/news/2020-12-15-ajv-version-7-released.html +++ b/news/2020-12-15-ajv-version-7-released.html @@ -18,7 +18,7 @@ - + @@ -183,6 +183,6 @@

      Ajv version 7 has these new features:

      • support of JSON Schema draft-2019-09 features: unevaluatedProperties and unevaluatedItems, dynamic recursive references and other additional keywords.
      • to reduce the mistakes in JSON schemas and unexpected validation results, strict mode is added - it prohibits ignored or ambiguous JSON Schema elements.
      • to make code injection from untrusted schemas impossible, code generation is fully re-written to be safe and to allow code optimization (compiled schema code size is reduced by more than 10%).
      • to simplify Ajv extensions, the new keyword API that is used by pre-defined keywords is available to user-defined keywords - it is much easier to define any keywords now, especially with subschemas. ajv-keywords (opens new window) package was updated to use the new API (in v4.0.0 (opens new window))
      • schemas are compiled to ES6 code (ES5 code generation is also supported with an option).
      • to improve reliability and maintainability the code is migrated to TypeScript.

      Please note:

      • the support for JSON-Schema draft-04 is removed - if you have schemas using "id" attributes you have to replace them with "$id" (or continue using Ajv v6 (opens new window) that will be supported until 02/28/2021).
      • all formats are separated to ajv-formats package - they have to be explicitly added if you use them.

      See release notes (opens new window) for the details.

      To install the new version:

      npm install ajv
       

      See Getting started for code examples.

      - + diff --git a/news/2021-03-07-ajv-supports-json-type-definition.html b/news/2021-03-07-ajv-supports-json-type-definition.html index edbd5cede..ea88e6361 100644 --- a/news/2021-03-07-ajv-supports-json-type-definition.html +++ b/news/2021-03-07-ajv-supports-json-type-definition.html @@ -18,7 +18,7 @@ - + @@ -181,6 +181,6 @@

      Ajv supports JSON Type Definition

      JSON Type Definition (JTD) is a new specification for defining JSON structures that is very simple to use, comparing with JSON Schema, less error prone, and it is published as RFC8927 (opens new window).

      See Choosing schema language for a detailed comparison between JSON Schema and JSON Type definition and informal specification.

      In addition to validation, Ajv also supports:

      • generation of serializers and parsers from JTD schemas/ This is more efficient than native JSON serialization/parsing - you can combine JSON string parsing and validation in one function call.
      • utility type JTDSchemaType to convert your data type to the type of JTD schema and JTDDataType to convert the type of schema to the type of data.
      - + diff --git a/news/2021-03-27-ajv-version-8-released.html b/news/2021-03-27-ajv-version-8-released.html index 87491f762..f588eef7d 100644 --- a/news/2021-03-27-ajv-version-8-released.html +++ b/news/2021-03-27-ajv-version-8-released.html @@ -18,7 +18,7 @@ - + @@ -183,6 +183,6 @@

      Ajv version 8 has these new features:

      • support of JSON Schema draft-2020-12: prefixItems keyword and changed semantics of items keyword, dynamic recursive references.
      • OpenAPI discriminator keyword.
      • improved JSON Type Definition support:
        • errors consistent with JTD specification.
        • error objects with additional properties to simplify error handling
        • internationalized error messages with ajv-i18n
      • TypeScript: support type unions in JSONSchemaType

      See release notes (opens new window) for the details.

      To install the new version:

      npm install ajv
       

      See Getting started for code examples.

      - + diff --git a/news/2021-04-24-ajv-online-event.html b/news/2021-04-24-ajv-online-event.html index 9f5074145..05e7401ca 100644 --- a/news/2021-04-24-ajv-online-event.html +++ b/news/2021-04-24-ajv-online-event.html @@ -18,7 +18,7 @@ - + @@ -181,6 +181,6 @@

      Ajv online event - May 20, 10am PT / 6pm UK

      We will talk about:

      • new features of Ajv version 8.
      • the improvements sponsored by Mozilla's MOSS grant.
      • how Ajv is used in JavaScript applications.

      Speakers:

      Gajus Kuizinas (opens new window) will host the event.

      Please register here (opens new window).

      - + diff --git a/news/2021-05-24-ajv-online-event-video.html b/news/2021-05-24-ajv-online-event-video.html index c72cf0a0a..0bddd7637 100644 --- a/news/2021-05-24-ajv-online-event-video.html +++ b/news/2021-05-24-ajv-online-event-video.html @@ -18,7 +18,7 @@ - + @@ -181,6 +181,6 @@

      Ajv online event video uploaded

      Huge thanks to everybody who joined, and to the speakers! The video of the event is available on YouTube (opens new window).

      - + diff --git a/news/2021-07-22-ajv-microsoft-foss-fund-award.html b/news/2021-07-22-ajv-microsoft-foss-fund-award.html index bfc476d1c..4c233b721 100644 --- a/news/2021-07-22-ajv-microsoft-foss-fund-award.html +++ b/news/2021-07-22-ajv-microsoft-foss-fund-award.html @@ -18,7 +18,7 @@ - + @@ -181,6 +181,6 @@

      Microsoft FOSS award

      Ajv was awarded a sponsorship from Microsoft FOSS fund (opens new window) - huge thanks to Microsoft and the engineers who voted to support Ajv development.

      This award will contribute to a long term maintenance of Ajv.

      - + diff --git a/news/index.html b/news/index.html index e66748152..594ad84c0 100644 --- a/news/index.html +++ b/news/index.html @@ -18,7 +18,7 @@ - + @@ -237,6 +237,6 @@ →

      - + diff --git a/options.html b/options.html index 1c6c3284d..a030090d4 100644 --- a/options.html +++ b/options.html @@ -18,7 +18,7 @@ - + @@ -275,6 +275,6 @@ →

      - + diff --git a/packages/ajv-cli.html b/packages/ajv-cli.html index ce07c90f5..6ba9c4ebf 100644 --- a/packages/ajv-cli.html +++ b/packages/ajv-cli.html @@ -18,7 +18,7 @@ - + @@ -219,6 +219,6 @@ →

      - + diff --git a/packages/ajv-errors.html b/packages/ajv-errors.html index d6feaea83..645acd284 100644 --- a/packages/ajv-errors.html +++ b/packages/ajv-errors.html @@ -18,7 +18,7 @@ - + @@ -380,6 +380,6 @@ →

      - + diff --git a/packages/ajv-formats.html b/packages/ajv-formats.html index a50de8ffa..35bd8cca8 100644 --- a/packages/ajv-formats.html +++ b/packages/ajv-formats.html @@ -18,7 +18,7 @@ - + @@ -215,6 +215,6 @@ →

      - + diff --git a/packages/ajv-i18n.html b/packages/ajv-i18n.html index 1d542e35f..c00b377c4 100644 --- a/packages/ajv-i18n.html +++ b/packages/ajv-i18n.html @@ -18,7 +18,7 @@ - + @@ -215,6 +215,6 @@ →

      - + diff --git a/packages/ajv-keywords.html b/packages/ajv-keywords.html index ca6bf67ca..0709a925c 100644 --- a/packages/ajv-keywords.html +++ b/packages/ajv-keywords.html @@ -18,7 +18,7 @@ - + @@ -558,6 +558,6 @@ →

      - + diff --git a/packages/index.html b/packages/index.html index a0a5de0d6..a718d8d37 100644 --- a/packages/index.html +++ b/packages/index.html @@ -18,7 +18,7 @@ - + @@ -187,6 +187,6 @@ →

      - + diff --git a/security.html b/security.html index d981116e6..94f806b16 100644 --- a/security.html +++ b/security.html @@ -18,7 +18,7 @@ - + @@ -200,6 +200,6 @@ →

      - + diff --git a/standalone.html b/standalone.html index 12a4cacd4..ce602b6b9 100644 --- a/standalone.html +++ b/standalone.html @@ -18,7 +18,7 @@ - + @@ -348,6 +348,6 @@ →

      - + diff --git a/strict-mode.html b/strict-mode.html index 90d90f543..b4583275b 100644 --- a/strict-mode.html +++ b/strict-mode.html @@ -18,7 +18,7 @@ - + @@ -294,6 +294,6 @@ →

      - + diff --git a/testimonials.html b/testimonials.html index c1b2a818e..bae72c3ca 100644 --- a/testimonials.html +++ b/testimonials.html @@ -18,7 +18,7 @@ - + @@ -188,6 +188,6 @@ →

      - + diff --git a/v6-to-v8-migration.html b/v6-to-v8-migration.html index 9ac66afbf..5b9125abf 100644 --- a/v6-to-v8-migration.html +++ b/v6-to-v8-migration.html @@ -18,7 +18,7 @@ - + @@ -191,6 +191,6 @@ →

      - +