diff --git a/404.html b/404.html index 9ca7eac0a..020f1b8c0 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 a5f59f988..3eeefdefc 100644 --- a/api.html +++ b/api.html @@ -18,8 +18,8 @@ - - + +
- + diff --git a/assets/css/0.styles.430f8012.css b/assets/css/0.styles.430f8012.css new file mode 100644 index 000000000..d5e98f4d0 --- /dev/null +++ b/assets/css/0.styles.430f8012.css @@ -0,0 +1 @@ +code[class*=language-],pre[class*=language-]{color:#ccc;background:none;font-family:Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace;font-size:1em;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;hyphens:none}pre[class*=language-]{padding:1em;margin:.5em 0;overflow:auto}:not(pre)>code[class*=language-],pre[class*=language-]{background:#2d2d2d}:not(pre)>code[class*=language-]{padding:.1em;border-radius:.3em;white-space:normal}.token.block-comment,.token.cdata,.token.comment,.token.doctype,.token.prolog{color:#999}.token.punctuation{color:#ccc}.token.attr-name,.token.deleted,.token.namespace,.token.tag{color:#e2777a}.token.function-name{color:#6196cc}.token.boolean,.token.function,.token.number{color:#f08d49}.token.class-name,.token.constant,.token.property,.token.symbol{color:#f8c555}.token.atrule,.token.builtin,.token.important,.token.keyword,.token.selector{color:#cc99cd}.token.attr-value,.token.char,.token.regex,.token.string,.token.variable{color:#7ec699}.token.entity,.token.operator,.token.url{color:#67cdcc}.token.bold,.token.important{font-weight:700}.token.italic{font-style:italic}.token.entity{cursor:help}.token.inserted{color:green}.theme-default-content code{color:#545252;padding:.25rem .5rem;margin:0;font-size:.85em;background-color:rgba(27,31,35,.05);border-radius:3px}.theme-default-content code .token.deleted{color:#ec5975}.theme-default-content code .token.inserted{color:#07aab4}.theme-default-content pre,.theme-default-content pre[class*=language-]{line-height:1.4;padding:1.25rem 1.5rem;margin:.85rem 0;background-color:#282c34;border-radius:6px;overflow:auto}.theme-default-content pre[class*=language-] code,.theme-default-content pre code{color:#fff;padding:0;background-color:transparent;border-radius:0}div[class*=language-]{position:relative;background-color:#282c34;border-radius:6px}div[class*=language-] .highlight-lines{-webkit-user-select:none;user-select:none;padding-top:1.3rem;position:absolute;top:0;left:0;width:100%;line-height:1.4}div[class*=language-] .highlight-lines .highlighted{background-color:rgba(0,0,0,.66)}div[class*=language-] pre,div[class*=language-] pre[class*=language-]{background:transparent;position:relative;z-index:1}div[class*=language-]:before{position:absolute;z-index:3;top:.8em;right:1em;font-size:.75rem;color:hsla(0,0%,100%,.4)}div[class*=language-]:not(.line-numbers-mode) .line-numbers-wrapper{display:none}div[class*=language-].line-numbers-mode .highlight-lines .highlighted{position:relative}div[class*=language-].line-numbers-mode .highlight-lines .highlighted:before{content:" ";position:absolute;z-index:3;left:0;top:0;display:block;width:3.5rem;height:100%;background-color:rgba(0,0,0,.66)}div[class*=language-].line-numbers-mode pre{padding-left:4.5rem;vertical-align:middle}div[class*=language-].line-numbers-mode .line-numbers-wrapper{position:absolute;top:0;width:3.5rem;text-align:center;color:hsla(0,0%,100%,.3);padding:1.25rem 0;line-height:1.4}div[class*=language-].line-numbers-mode .line-numbers-wrapper br{-webkit-user-select:none;user-select:none}div[class*=language-].line-numbers-mode .line-numbers-wrapper .line-number{position:relative;z-index:4;-webkit-user-select:none;user-select:none;font-size:.85em}div[class*=language-].line-numbers-mode:after{content:"";position:absolute;z-index:2;top:0;left:0;width:3.5rem;height:100%;border-radius:6px 0 0 6px;border-right:1px solid rgba(0,0,0,.66);background-color:#282c34}div[class~=language-js]:before{content:"js"}div[class~=language-ts]:before{content:"ts"}div[class~=language-html]:before{content:"html"}div[class~=language-md]:before{content:"md"}div[class~=language-vue]:before{content:"vue"}div[class~=language-css]:before{content:"css"}div[class~=language-sass]:before{content:"sass"}div[class~=language-scss]:before{content:"scss"}div[class~=language-less]:before{content:"less"}div[class~=language-stylus]:before{content:"stylus"}div[class~=language-go]:before{content:"go"}div[class~=language-java]:before{content:"java"}div[class~=language-c]:before{content:"c"}div[class~=language-sh]:before{content:"sh"}div[class~=language-yaml]:before{content:"yaml"}div[class~=language-py]:before{content:"py"}div[class~=language-docker]:before{content:"docker"}div[class~=language-dockerfile]:before{content:"dockerfile"}div[class~=language-makefile]:before{content:"makefile"}div[class~=language-javascript]:before{content:"js"}div[class~=language-typescript]:before{content:"ts"}div[class~=language-markup]:before{content:"html"}div[class~=language-markdown]:before{content:"md"}div[class~=language-json]:before{content:"json"}div[class~=language-ruby]:before{content:"rb"}div[class~=language-python]:before{content:"py"}div[class~=language-bash]:before{content:"sh"}div[class~=language-php]:before{content:"php"}.custom-block .custom-block-title{font-weight:600;margin-bottom:-.4rem}.custom-block.danger,.custom-block.tip,.custom-block.warning{padding:.1rem 1.5rem;border-left-width:.5rem;border-left-style:solid;margin:1rem 0}.custom-block.tip{background-color:#f3f5f7;border-color:#42b983}.custom-block.warning{background-color:rgba(255,229,100,.3);border-color:#e7c000;color:#6b5900}.custom-block.warning .custom-block-title{color:#b29400}.custom-block.warning a{color:#292828}.custom-block.danger{background-color:#ffe6e6;border-color:#c00;color:#4d0000}.custom-block.danger .custom-block-title{color:#900}.custom-block.danger a{color:#292828}.custom-block.details{display:block;position:relative;border-radius:2px;margin:1.6em 0;padding:1.6em;background-color:#eee}.custom-block.details h4{margin-top:0}.custom-block.details figure:last-child,.custom-block.details p:last-child{margin-bottom:0;padding-bottom:0}.custom-block.details summary{outline:none;cursor:pointer}.arrow{display:inline-block;width:0;height:0}.arrow.up{border-bottom:6px solid #ccc}.arrow.down,.arrow.up{border-left:4px solid transparent;border-right:4px solid transparent}.arrow.down{border-top:6px solid #ccc}.arrow.right{border-left:6px solid #ccc}.arrow.left,.arrow.right{border-top:4px solid transparent;border-bottom:4px solid transparent}.arrow.left{border-right:6px solid #ccc}.theme-default-content:not(.custom){max-width:740px;margin:0 auto;padding:2rem 2.5rem}@media (max-width:959px){.theme-default-content:not(.custom){padding:2rem}}@media (max-width:480px){.theme-default-content:not(.custom){padding:1.5rem}}.table-of-contents .badge{vertical-align:middle}body,html{padding:0;margin:0;background-color:#fff}body{font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-size:16px;color:#292828}.page{padding-left:20rem}.navbar{z-index:20;right:0;height:3.6rem;background-color:#fff;box-sizing:border-box;border-bottom:1px solid #eaecef}.navbar,.sidebar-mask{position:fixed;top:0;left:0}.sidebar-mask{z-index:9;width:100vw;height:100vh;display:none}.sidebar{font-size:16px;background-color:#fff;width:20rem;position:fixed;z-index:10;margin:0;top:3.6rem;left:0;bottom:0;box-sizing:border-box;border-right:1px solid #eaecef;overflow-y:auto}.theme-default-content:not(.custom)>:first-child{margin-top:3.6rem}.theme-default-content:not(.custom) a:hover{text-decoration:underline}.theme-default-content:not(.custom) p.demo{padding:1rem 1.5rem;border:1px solid #ddd;border-radius:4px}.theme-default-content:not(.custom) img{max-width:100%}.theme-default-content.custom{padding:0;margin:0}.theme-default-content.custom img{max-width:100%}a{font-weight:500;text-decoration:none}a,p a code{color:#07aab4}p a code{font-weight:400}kbd{background:#eee;border:.15rem solid #ddd;border-bottom:.25rem solid #ddd;border-radius:.15rem;padding:0 .15em}blockquote{font-size:1rem;color:#999;border-left:.2rem solid #dfe2e5;margin:1rem 0;padding:.25rem 0 .25rem 1rem}blockquote>p{margin:0}ol,ul{padding-left:1.2em}strong{font-weight:600}h1,h2,h3,h4,h5,h6{font-weight:600;line-height:1.25}.theme-default-content:not(.custom)>h1,.theme-default-content:not(.custom)>h2,.theme-default-content:not(.custom)>h3,.theme-default-content:not(.custom)>h4,.theme-default-content:not(.custom)>h5,.theme-default-content:not(.custom)>h6{margin-top:-3.1rem;padding-top:4.6rem;margin-bottom:0}.theme-default-content:not(.custom)>h1:first-child,.theme-default-content:not(.custom)>h2:first-child,.theme-default-content:not(.custom)>h3:first-child,.theme-default-content:not(.custom)>h4:first-child,.theme-default-content:not(.custom)>h5:first-child,.theme-default-content:not(.custom)>h6:first-child{margin-top:-1.5rem;margin-bottom:1rem}.theme-default-content:not(.custom)>h1:first-child+.custom-block,.theme-default-content:not(.custom)>h1:first-child+p,.theme-default-content:not(.custom)>h1:first-child+pre,.theme-default-content:not(.custom)>h2:first-child+.custom-block,.theme-default-content:not(.custom)>h2:first-child+p,.theme-default-content:not(.custom)>h2:first-child+pre,.theme-default-content:not(.custom)>h3:first-child+.custom-block,.theme-default-content:not(.custom)>h3:first-child+p,.theme-default-content:not(.custom)>h3:first-child+pre,.theme-default-content:not(.custom)>h4:first-child+.custom-block,.theme-default-content:not(.custom)>h4:first-child+p,.theme-default-content:not(.custom)>h4:first-child+pre,.theme-default-content:not(.custom)>h5:first-child+.custom-block,.theme-default-content:not(.custom)>h5:first-child+p,.theme-default-content:not(.custom)>h5:first-child+pre,.theme-default-content:not(.custom)>h6:first-child+.custom-block,.theme-default-content:not(.custom)>h6:first-child+p,.theme-default-content:not(.custom)>h6:first-child+pre{margin-top:2rem}h1:focus .header-anchor,h1:hover .header-anchor,h2:focus .header-anchor,h2:hover .header-anchor,h3:focus .header-anchor,h3:hover .header-anchor,h4:focus .header-anchor,h4:hover .header-anchor,h5:focus .header-anchor,h5:hover .header-anchor,h6:focus .header-anchor,h6:hover .header-anchor{opacity:1}h1{font-size:2.2rem}h2{font-size:1.65rem;padding-bottom:.3rem;border-bottom:1px solid #eaecef}h3{font-size:1.35rem}a.header-anchor{font-size:.85em;float:left;margin-left:-.87em;padding-right:.23em;margin-top:.125em;opacity:0}a.header-anchor:focus,a.header-anchor:hover{text-decoration:none}.line-number,code,kbd{font-family:source-code-pro,Menlo,Monaco,Consolas,Courier New,monospace}ol,p,ul{line-height:1.7}hr{border:0;border-top:1px solid #eaecef}table{border-collapse:collapse;margin:1rem 0;display:block;overflow-x:auto}tr{border-top:1px solid #dfe2e5}tr:nth-child(2n){background-color:#f6f8fa}td,th{border:1px solid #dfe2e5;padding:.6em 1em}.theme-container.sidebar-open .sidebar-mask{display:block}.theme-container.no-navbar .theme-default-content:not(.custom)>h1,.theme-container.no-navbar h2,.theme-container.no-navbar h3,.theme-container.no-navbar h4,.theme-container.no-navbar h5,.theme-container.no-navbar h6{margin-top:1.5rem;padding-top:0}.theme-container.no-navbar .sidebar{top:0}@media (min-width:720px){.theme-container.no-sidebar .sidebar{display:none}.theme-container.no-sidebar .page{padding-left:0}}@media (max-width:959px){.sidebar{font-size:15px;width:16.4rem}.page{padding-left:16.4rem}}@media (max-width:719px){.sidebar{top:0;padding-top:3.6rem;transform:translateX(-100%);transition:transform .2s ease}.page{padding-left:0}.theme-container.sidebar-open .sidebar{transform:translateX(0)}.theme-container.no-navbar .sidebar{padding-top:0}}@media (max-width:480px){h1{font-size:1.9rem}.theme-default-content div[class*=language-]{margin:.85rem -1.5rem;border-radius:0}}img+span>.icon.outbound{display:none}body{font-family:Raleway;font-weight:400}strong{font-weight:550}h1,h2,h3,h4,h5,h6{font-family:IstokWeb;font-weight:400}.custom-block.tip{border-color:#23c8d2;background-color:#f7f7f3;color:#292828}.custom-block.tip .custom-block-title{color:#292828}.custom-block.warning{border-color:#f1f440;background-color:#f7f7f3;color:#292828}.custom-block.warning .custom-block-title{color:#292828}.custom-block.danger{border-color:#f5775b;background-color:#f7f7f3;color:#292828}.custom-block.danger .custom-block-title{color:#292828}.sidebar nav.nav-links div.nav-item{display:none}span.badge{font-family:Raleway;font-weight:500}.theme-code-group .token.string{color:#7ec699}.theme-code-group button.theme-code-group__nav-tab.theme-code-group__nav-tab-active{border-color:#7ec699}.navbar span.site-name{font-family:IstokWeb;font-weight:500;font-size:1.6em}p.sidebar-heading{font-weight:500;font-size:1em}a.sidebar-link.active{font-weight:500!important}@font-face{font-family:Raleway;src:url(/fonts/Raleway-VariableFont_wght.ttf)}@font-face{font-family:IstokWeb;src:url(/fonts/IstokWeb-Regular.ttf);font-weight:400}#nprogress{pointer-events:none}#nprogress .bar{background:#07aab4;position:fixed;z-index:1031;top:0;left:0;width:100%;height:2px}#nprogress .peg{display:block;position:absolute;right:0;width:100px;height:100%;box-shadow:0 0 10px #07aab4,0 0 5px #07aab4;opacity:1;transform:rotate(3deg) translateY(-4px)}#nprogress .spinner{display:block;position:fixed;z-index:1031;top:15px;right:15px}#nprogress .spinner-icon{width:18px;height:18px;box-sizing:border-box;border-color:#07aab4 transparent transparent #07aab4;border-style:solid;border-width:2px;border-radius:50%;animation:nprogress-spinner .4s linear infinite}.nprogress-custom-parent{overflow:hidden;position:relative}.nprogress-custom-parent #nprogress .bar,.nprogress-custom-parent #nprogress .spinner{position:absolute}@keyframes nprogress-spinner{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}.icon.outbound{color:#aaa;display:inline-block;vertical-align:middle;position:relative;top:-1px}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.algolia-search-wrapper>span{vertical-align:middle}.algolia-search-wrapper .algolia-autocomplete{line-height:normal}.algolia-search-wrapper .algolia-autocomplete .ds-dropdown-menu{background-color:#fff;border:1px solid #999;border-radius:4px;font-size:16px;margin:6px 0 0;padding:4px;text-align:left}.algolia-search-wrapper .algolia-autocomplete .ds-dropdown-menu:before{border-color:#999}.algolia-search-wrapper .algolia-autocomplete .ds-dropdown-menu [class*=ds-dataset-]{border:none;padding:0}.algolia-search-wrapper .algolia-autocomplete .ds-dropdown-menu .ds-suggestions{margin-top:0}.algolia-search-wrapper .algolia-autocomplete .ds-dropdown-menu .ds-suggestion{border-bottom:1px solid #eaecef}.algolia-search-wrapper .algolia-autocomplete .algolia-docsearch-suggestion--highlight{color:#2c815b}.algolia-search-wrapper .algolia-autocomplete .algolia-docsearch-suggestion{border-color:#eaecef;padding:0}.algolia-search-wrapper .algolia-autocomplete .algolia-docsearch-suggestion .algolia-docsearch-suggestion--category-header{padding:5px 10px;margin-top:0;background:#07aab4;color:#fff;font-weight:600}.algolia-search-wrapper .algolia-autocomplete .algolia-docsearch-suggestion .algolia-docsearch-suggestion--category-header .algolia-docsearch-suggestion--highlight{background:hsla(0,0%,100%,.6)}.algolia-search-wrapper .algolia-autocomplete .algolia-docsearch-suggestion .algolia-docsearch-suggestion--wrapper{padding:0}.algolia-search-wrapper .algolia-autocomplete .algolia-docsearch-suggestion .algolia-docsearch-suggestion--title{font-weight:600;margin-bottom:0;color:#292828}.algolia-search-wrapper .algolia-autocomplete .algolia-docsearch-suggestion .algolia-docsearch-suggestion--subcategory-column{vertical-align:top;padding:5px 7px 5px 5px;border-color:#eaecef;background:#f1f3f5}.algolia-search-wrapper .algolia-autocomplete .algolia-docsearch-suggestion .algolia-docsearch-suggestion--subcategory-column:after{display:none}.algolia-search-wrapper .algolia-autocomplete .algolia-docsearch-suggestion .algolia-docsearch-suggestion--subcategory-column-text{color:#555}.algolia-search-wrapper .algolia-autocomplete .algolia-docsearch-footer{border-color:#eaecef}.algolia-search-wrapper .algolia-autocomplete .ds-cursor .algolia-docsearch-suggestion--content{background-color:#e7edf3!important;color:#292828}@media (min-width:719px){.algolia-search-wrapper .algolia-autocomplete .algolia-docsearch-suggestion .algolia-docsearch-suggestion--subcategory-column{float:none;width:150px;min-width:150px;display:table-cell}.algolia-search-wrapper .algolia-autocomplete .algolia-docsearch-suggestion .algolia-docsearch-suggestion--content{float:none;display:table-cell;width:100%;vertical-align:top}.algolia-search-wrapper .algolia-autocomplete .algolia-docsearch-suggestion .ds-dropdown-menu{min-width:515px!important}}@media (max-width:719px){.algolia-search-wrapper .ds-dropdown-menu{min-width:calc(100vw - 4rem)!important;max-width:calc(100vw - 4rem)!important}.algolia-search-wrapper .algolia-docsearch-suggestion--wrapper{padding:5px 7px 5px 5px!important}.algolia-search-wrapper .algolia-docsearch-suggestion--subcategory-column{padding:0!important;background:#fff!important}.algolia-search-wrapper .algolia-docsearch-suggestion--subcategory-column-text:after{content:" > ";font-size:10px;line-height:14.4px;display:inline-block;width:5px;margin:-3px 3px 0;vertical-align:middle}}.home{padding:3.6rem 2rem 0;max-width:960px;margin:0 auto;display:block}.home .hero{text-align:center}.home .hero img{max-width:100%;max-height:280px;display:block;margin:3rem auto 1.5rem}.home .hero h1{font-size:3rem}.home .hero .action,.home .hero .description,.home .hero h1{margin:1.8rem auto}.home .hero .description{max-width:35rem;font-size:1.6rem;line-height:1.3;color:#807d7d}.home .hero .action-button{display:inline-block;font-size:1.2rem;color:#fff;background-color:#07aab4;padding:.8rem 1.6rem;border-radius:4px;transition:background-color .1s ease;box-sizing:border-box;border-bottom:1px solid #0699a2}.home .hero .action-button:hover{background-color:#08c7d3}.home .features{border-top:1px solid #eaecef;padding:1.2rem 0;margin-top:2.5rem;display:flex;flex-wrap:wrap;align-items:flex-start;align-content:stretch;justify-content:space-between}.home .feature{flex-grow:1;flex-basis:30%;max-width:30%}.home .feature h2{font-size:1.4rem;font-weight:500;border-bottom:none;padding-bottom:0;color:#3f3d3d}.home .feature p{color:#5f5d5d}.home .footer{padding:2.5rem;border-top:1px solid #eaecef;text-align:center;color:#5f5d5d}@media (max-width:719px){.home .features{flex-direction:column}.home .feature{max-width:100%;padding:0 2.5rem}}@media (max-width:480px){.home{padding-left:1.5rem;padding-right:1.5rem}.home .hero img{max-height:210px;margin:2rem auto 1.2rem}.home .hero h1{font-size:2rem}.home .hero .action,.home .hero .description,.home .hero h1{margin:1.2rem auto}.home .hero .description{font-size:1.2rem}.home .hero .action-button{font-size:1rem;padding:.6rem 1.2rem}.home .feature h2{font-size:1.25rem}}.page,.page[data-v-22624a70]{padding-bottom:2rem;display:block}.page-edit{max-width:740px;margin:0 auto;padding:2rem 2.5rem}@media (max-width:959px){.page-edit{padding:2rem}}@media (max-width:480px){.page-edit{padding:1.5rem}}.page-edit{padding-top:1rem;padding-bottom:1rem;overflow:auto}.page-edit .edit-link{display:inline-block}.page-edit .edit-link a{color:#5f5d5d;margin-right:.25rem}.page-edit .last-updated{float:right;font-size:.9em}.page-edit .last-updated .prefix{font-weight:500;color:#5f5d5d}.page-edit .last-updated .time{font-weight:400;color:#767676}@media (max-width:719px){.page-edit .edit-link{margin-bottom:.5rem}.page-edit .last-updated{font-size:.8em;float:none;text-align:left}}.page-nav{max-width:740px;margin:0 auto;padding:2rem 2.5rem}@media (max-width:959px){.page-nav{padding:2rem}}@media (max-width:480px){.page-nav{padding:1.5rem}}.page-nav{padding-top:1rem;padding-bottom:0}.page-nav .inner{min-height:2rem;margin-top:0;border-top:1px solid #eaecef;padding-top:1rem;overflow:auto}.page-nav .next{float:right}.sidebar ul{padding:0;margin:0;list-style-type:none}.sidebar a{display:inline-block}.sidebar .nav-links{display:none;border-bottom:1px solid #eaecef;padding:.5rem 0 .75rem}.sidebar .nav-links a{font-weight:600}.sidebar .nav-links .nav-item,.sidebar .nav-links .repo-link{display:block;line-height:1.25rem;font-size:1.1em;padding:.5rem 0 .5rem 1.5rem}.sidebar>.sidebar-links{padding:1.5rem 0}.sidebar>.sidebar-links>li>a.sidebar-link{font-size:1.1em;line-height:1.7;font-weight:700}.sidebar>.sidebar-links>li:not(:first-child){margin-top:.75rem}@media (max-width:719px){.sidebar .nav-links{display:block}.sidebar .nav-links .dropdown-wrapper .nav-dropdown .dropdown-item a.router-link-active:after{top:calc(1rem - 2px)}.sidebar>.sidebar-links{padding:1rem 0}}.sidebar-group .sidebar-group{padding-left:.5em}.sidebar-group:not(.collapsable) .sidebar-heading:not(.clickable){cursor:auto;color:inherit}.sidebar-group.is-sub-group{padding-left:0}.sidebar-group.is-sub-group>.sidebar-heading{font-size:.95em;line-height:1.4;font-weight:400;padding-left:2rem}.sidebar-group.is-sub-group>.sidebar-heading:not(.clickable){opacity:.5}.sidebar-group.is-sub-group>.sidebar-group-items{padding-left:1rem}.sidebar-group.is-sub-group>.sidebar-group-items>li>.sidebar-link{font-size:.95em;border-left:none}.sidebar-group.depth-2>.sidebar-heading{border-left:none}.sidebar-heading{color:#292828;transition:color .15s ease;cursor:pointer;font-size:1.1em;font-weight:700;padding:.35rem 1.5rem .35rem 1.25rem;width:100%;box-sizing:border-box;margin:0;border-left:.25rem solid transparent}.sidebar-heading.open,.sidebar-heading:hover{color:inherit}.sidebar-heading .arrow{position:relative;top:-.12em;left:.5em}.sidebar-heading.clickable.active{font-weight:600;color:#07aab4;border-left-color:#07aab4}.sidebar-heading.clickable:hover{color:#07aab4}.sidebar-group-items{transition:height .1s ease-out;font-size:.95em;overflow:hidden}.badge[data-v-6eb0829b]{display:inline-block;font-size:14px;height:18px;line-height:18px;border-radius:3px;padding:0 6px;color:#fff;background-color:#42b983}.badge.green[data-v-6eb0829b],.badge.tip[data-v-6eb0829b]{background-color:#23c8d2}.badge.error[data-v-6eb0829b]{background-color:#f5775b}.badge.warn[data-v-6eb0829b],.badge.warning[data-v-6eb0829b],.badge.yellow[data-v-6eb0829b]{background-color:#e9c400}.badge+.badge[data-v-6eb0829b]{margin-left:5px}.theme-code-block[data-v-311ec9b4]{display:none}.theme-code-block__active[data-v-311ec9b4]{display:block}.theme-code-block>pre[data-v-311ec9b4]{background-color:orange}.theme-code-group__nav[data-v-5cad0a2e]{margin-bottom:-35px;background-color:#282c34;padding-bottom:22px;border-top-left-radius:6px;border-top-right-radius:6px;padding-left:10px;padding-top:10px}.theme-code-group__ul[data-v-5cad0a2e]{margin:auto 0;padding-left:0;display:inline-flex;list-style:none}.theme-code-group__nav-tab[data-v-5cad0a2e]{border:0;padding:5px;cursor:pointer;background-color:transparent;font-size:.85em;line-height:1.4;color:hsla(0,0%,100%,.9);font-weight:600}.theme-code-group__nav-tab-active[data-v-5cad0a2e]{border-bottom:1px solid #42b983}.pre-blank[data-v-5cad0a2e]{color:#42b983}a.button[data-v-439d4a3b]{display:block;width:114px;height:38px;line-height:38px;background-color:#23c8d2;border-radius:6px;color:#fff;text-align:center;font-weight:600}.column[data-v-71066fea]{margin-bottom:22px}@media only screen and (min-width:719px){.column.left[data-v-71066fea]{width:33%;margin-right:5%}.column.right[data-v-71066fea]{width:62%}}@media only screen and (min-width:719px){.columns[data-v-6d930324]{display:flex}}.contributor[data-v-074475b8]{width:3.26em;height:3.26em;border-radius:50%;text-indent:-9999px;display:inline-block;background:no-repeat url(/assets/img/contributors.dfa0ba17.jpg);background-size:auto 102%;margin:0 .67em .67em 0;border:2px solid var(--second)}@media only screen and (min-width:414px){.contributor[data-v-074475b8]{width:3.625em;height:3.625em;margin:0 .8em .8em 0}}div[data-v-20681dd8]{height:200px;box-sizing:border-box;padding:28px;border-radius:8px;position:relative;color:#fff;margin-bottom:25px}@media only screen and (min-width:480px){div[data-v-20681dd8]{height:160px}}@media only screen and (min-width:719px){div[data-v-20681dd8]{width:31.25%;height:225px;margin-right:3%;margin-bottom:0}}div h3[data-v-20681dd8]{margin:0}@media only screen and (min-width:959px){div h3[data-v-20681dd8]{font-size:1.75em}}div h3 .header-anchor[data-v-20681dd8]{display:none}@media only screen and (min-width:959px){div p[data-v-20681dd8]{font-size:1.25em}}div.less-code[data-v-20681dd8]{background-color:#23c8d2}div.fast-secure[data-v-20681dd8]{background-color:#409cff}div.multi-spec[data-v-20681dd8]{background-color:#f5775b}@media only screen and (min-width:719px){div[data-v-20681dd8]:last-child{margin-right:0}}a[data-v-20681dd8]{position:absolute;bottom:24px;right:24px;color:#fff}.features[data-v-30c230c6]{padding:60px 0}@media only screen and (min-width:719px){.features[data-v-30c230c6]{display:flex}}@media only screen and (min-width:719px){div[data-v-f7c18a96]{width:25%}}p a[data-v-f7c18a96]{color:#292828;font-weight:400}p a[data-v-f7c18a96]:hover{text-decoration:underline}@media only screen and (max-width:719px){p[data-v-f7c18a96]{margin:0;line-height:30px}}.column img[data-v-f7c18a96]{display:block;margin:0 auto}.column.ajv img[data-v-f7c18a96]{margin:0;width:100px}@media only screen and (max-width:719px){.column.ajv img[data-v-f7c18a96]{margin-bottom:34px}}.column.links a[data-v-f7c18a96]{color:#292828;font-weight:400}@media only screen and (max-width:719px){.column.sponsors a[data-v-f7c18a96]:first-child{display:block;margin-top:80px}}.column.sponsors img[data-v-f7c18a96]{width:140px;padding:0 20px 15px}span[data-v-3ac601d9]{vertical-align:-8px;padding-left:20px}@media only screen and (max-width:719px){span[data-v-3ac601d9]{vertical-align:-21px}}.footer-columns[data-v-de1d7950]{padding:20px 0 60px;border-bottom:1px solid #c4c4c4}@media only screen and (min-width:719px){.footer-columns[data-v-de1d7950]{display:flex}}.hero-section[data-v-37c67372]{width:100%;padding:3.6rem 0 50px;overflow:hidden;background:linear-gradient(304.33deg,hsla(0,0%,92.9%,.31) -7.48%,#c6e1ff 30.07%,hsla(0,0%,92.9%,.26) 82.76%)}.hero-section .section-content[data-v-37c67372]{position:relative;max-width:1000px;padding:0 50px;margin:0 auto}@media only screen and (max-width:719px){.hero-section .section-content[data-v-37c67372]{padding:0 40px}}@media only screen and (max-width:480px){.hero-section .section-content[data-v-37c67372]{padding:0 30px}}.hero-section .section-content .section-content-wrapper[data-v-37c67372]{position:relative;z-index:2}.hero-section .hero-image[data-v-37c67372]{position:absolute;z-index:1;width:658px;top:-400px;left:-25px}@media only screen and (min-width:480px){.hero-section .hero-image[data-v-37c67372]{width:823px;top:-500px;left:50px}}@media only screen and (min-width:719px){.hero-section .hero-image[data-v-37c67372]{top:-430px;left:330px}}@media only screen and (min-width:959px){.hero-section .hero-image[data-v-37c67372]{width:1097px;top:-575px;left:425px}}.hero-section .header-anchor[data-v-37c67372]{display:none}.hero-section h1[data-v-37c67372]{font-size:2em;margin-top:200px}.hero-section h2[data-v-37c67372]{border-bottom:none}@media only screen and (min-width:480px){.hero-section h1[data-v-37c67372]{font-size:3em}.hero-section h2[data-v-37c67372]{font-size:1.75em}}@media only screen and (min-width:719px){.hero-section h1[data-v-37c67372],.hero-section h2[data-v-37c67372]{margin-left:48px}}@media only screen and (min-width:959px){.hero-section h1[data-v-37c67372]{font-size:4em}.hero-section h2[data-v-37c67372]{font-size:2.25em}.hero-section h1[data-v-37c67372],.hero-section h2[data-v-37c67372]{margin-left:64px}}.homepage[data-v-07ee638e]{padding:0;box-sizing:content-box}.home-section[data-v-aed41194]{width:100%;padding:3.6rem 0 50px}.home-section .section-content[data-v-aed41194]{max-width:1000px;padding:0 50px;margin:0 auto}@media only screen and (max-width:719px){.home-section .section-content[data-v-aed41194]{padding:0 40px}}@media only screen and (max-width:480px){.home-section .section-content[data-v-aed41194]{padding:0 30px}}.home-section[data-v-aed41194] .theme-code-group button{position:relative;outline:none;z-index:1}.home-section.contributors[data-v-aed41194],.home-section.footer[data-v-aed41194],.home-section.testimonials[data-v-aed41194]{background:linear-gradient(295.26deg,hsla(0,0%,91%,.8) 26.65%,hsla(0,0%,100%,.04) 83.48%)}.home-section.footer p[data-v-aed41194]{padding:20px 0 0;text-align:center;color:#292828}.home-section.footer p a[data-v-aed41194]{color:#292828;font-weight:400}.home-section.footer p a[data-v-aed41194]:hover{text-decoration:underline}.post[data-v-a228e400]{display:flex;border-bottom:1px solid #eaecef}.post[data-v-a228e400]:last-child{border-bottom:none}.post a.read-more[data-v-a228e400]{float:right;margin:28px 0}p.subscribe[data-v-a228e400]{margin-top:2em}p.subscribe a.all-news[data-v-a228e400]{display:block;margin-top:1rem}@media only screen and (min-width:480px){p.subscribe a.all-news[data-v-a228e400]{display:inline-block;float:right;margin-top:0}}.post-meta>div[data-v-f7ce3066]{display:inline-flex}.pub-date[data-v-f7ce3066]{color:grey}.projects p[data-v-7ef3dfe8]{max-width:1100px;padding:0}.projects img[data-v-7ef3dfe8]{display:inline-block;max-width:240px;height:40px;line-height:40px;vertical-align:middle}@media only screen and (max-width:719px){.projects img[data-v-7ef3dfe8]{max-width:160px;height:30px;line-height:30px}}.projects a[data-v-7ef3dfe8]{display:inline-block;height:40px;line-height:40px;vertical-align:middle;margin:0 36px 30px 0;font-size:28px;font-weight:500;color:#292828}@media only screen and (max-width:719px){.projects a[data-v-7ef3dfe8]{margin:0 24px 20px 0;height:30px;line-height:30px;font-size:20px}}.projects a[data-v-7ef3dfe8]:hover{text-decoration:none}.projects a span[data-v-7ef3dfe8]{display:none}.sponsors[data-v-c1b00a8c]{max-width:800px;margin:0 auto}.sponsors h2[data-v-c1b00a8c]{margin-left:0;text-decoration:none}.sponsors h2 a.header-anchor[data-v-c1b00a8c]{width:auto;margin-right:0}.sponsors p[data-v-c1b00a8c]{font-size:24px}.sponsors.bronze img[data-v-c1b00a8c],.sponsors.gold img[data-v-c1b00a8c],.sponsors.platinum img[data-v-c1b00a8c]{width:100%}.sponsors.bronze a[data-v-c1b00a8c],.sponsors.gold a[data-v-c1b00a8c],.sponsors.platinum a[data-v-c1b00a8c]{margin-bottom:10px;display:inline-block}@media only screen and (min-width:480px){.sponsors.bronze a[data-v-c1b00a8c],.sponsors.gold a[data-v-c1b00a8c],.sponsors.platinum a[data-v-c1b00a8c]{margin-bottom:0}}.sponsors.bronze a[data-v-c1b00a8c]:last-child,.sponsors.gold a[data-v-c1b00a8c]:last-child,.sponsors.platinum a[data-v-c1b00a8c]:last-child{margin-right:0}.sponsors.platinum a[data-v-c1b00a8c]{width:100%;display:block}@media only screen and (min-width:480px){.sponsors.platinum a[data-v-c1b00a8c]{display:inline-block;width:45%;margin-right:8%}}.sponsors.gold a[data-v-c1b00a8c]{width:45%;margin-right:4%}@media only screen and (min-width:480px){.sponsors.gold a[data-v-c1b00a8c]{width:31%;margin-right:2%}}.sponsors.bronze a[data-v-c1b00a8c]{width:45%;margin-right:4%}@media only screen and (min-width:480px){.sponsors.bronze a[data-v-c1b00a8c]{width:22%;margin-right:3%}}form[data-v-410e8fc2]{display:inline-block}label[data-v-410e8fc2]{display:block;margin-bottom:1rem}@media only screen and (min-width:719px){label[data-v-410e8fc2]{display:inline-block;margin-bottom:0}}button[data-v-410e8fc2],input[data-v-410e8fc2]{font-family:Raleway;font-size:16px;border:0 solid;outline:none}input[data-v-410e8fc2]{border:1px solid #cfd4db;height:2rem;width:180px;border-radius:2rem;padding:0 .5rem;margin:0 .5rem 0 0}input[data-v-410e8fc2]:focus{border-color:#07aab4}@media only screen and (min-width:719px){input[data-v-410e8fc2]{width:200px;margin:0 1rem}}button[data-v-410e8fc2]{width:114px;height:36px;line-height:36px;padding-top:0;background-color:#23c8d2;border-radius:6px;color:#fff;text-align:center;font-weight:600;display:block;margin-top:1em}@media only screen and (min-width:414px){button[data-v-410e8fc2]{display:inline-block;margin-top:0}}div.testimonial-content[data-v-2c05e654]{background-position:50%;overflow:hidden;width:280px;background-repeat:no-repeat}div.testimonial-content.blue[data-v-2c05e654]{background-image:url(/assets/img/testimonials-blue.868231a8.svg)}div.testimonial-content.green[data-v-2c05e654]{background-image:url(/assets/img/testimonials-green.6fdaa89c.svg)}div.testimonial-content p[data-v-2c05e654]{margin:.9em 0;font-size:15px}@media only screen and (max-width:374px){div.testimonial-content.blue[data-v-2c05e654],div.testimonial-content.green[data-v-2c05e654]{background-image:none;padding:0}div.testimonial-content.blue p[data-v-2c05e654],div.testimonial-content.green p[data-v-2c05e654]{font-size:15px}}@media only screen and (max-width:500px){div.testimonial-content[data-v-2c05e654]{width:100%;background-size:350px 156px;padding:0 calc(50% - 100px);box-sizing:border-box}div.testimonial-content p[data-v-2c05e654]{font-size:12px}}@media only screen and (min-width:500px){div.testimonial-content[data-v-2c05e654]{height:212px;padding:0 75px;margin:40px auto 0}}@media only screen and (min-width:959px){div.testimonial-content[data-v-2c05e654]{padding:0 calc(25% - 140px)}}.header-anchor[data-v-2c05e654]{display:none}.testimonials[data-v-729b0721]{padding:20px 0}@media only screen and (min-width:959px){.testimonials[data-v-729b0721]{display:flex}}.searchbox{display:inline-block;position:relative;width:200px;height:32px!important;white-space:nowrap;box-sizing:border-box;visibility:visible!important}.searchbox .algolia-autocomplete{display:block;width:100%;height:100%}.searchbox__wrapper{width:100%;height:100%;z-index:999;position:relative}.searchbox__input{display:inline-block;box-sizing:border-box;transition:box-shadow .4s ease,background .4s ease;border:0;border-radius:16px;box-shadow:inset 0 0 0 1px #ccc;background:#fff!important;padding:0 26px 0 32px;width:100%;height:100%;vertical-align:middle;white-space:normal;font-size:12px;-webkit-appearance:none;-moz-appearance:none;appearance:none}.searchbox__input::-webkit-search-cancel-button,.searchbox__input::-webkit-search-decoration,.searchbox__input::-webkit-search-results-button,.searchbox__input::-webkit-search-results-decoration{display:none}.searchbox__input:hover{box-shadow:inset 0 0 0 1px #b3b3b3}.searchbox__input:active,.searchbox__input:focus{outline:0;box-shadow:inset 0 0 0 1px #aaa;background:#fff}.searchbox__input::-moz-placeholder{color:#aaa}.searchbox__input::placeholder{color:#aaa}.searchbox__submit{position:absolute;top:0;margin:0;border:0;border-radius:16px 0 0 16px;background-color:rgba(69,142,225,0);padding:0;width:32px;height:100%;vertical-align:middle;text-align:center;font-size:inherit;-webkit-user-select:none;-moz-user-select:none;user-select:none;right:inherit;left:0}.searchbox__submit:before{display:inline-block;margin-right:-4px;height:100%;vertical-align:middle;content:""}.searchbox__submit:active,.searchbox__submit:hover{cursor:pointer}.searchbox__submit:focus{outline:0}.searchbox__submit svg{width:14px;height:14px;vertical-align:middle;fill:#6d7e96}.searchbox__reset{display:block;position:absolute;top:8px;right:8px;margin:0;border:0;background:none;cursor:pointer;padding:0;font-size:inherit;-webkit-user-select:none;-moz-user-select:none;user-select:none;fill:rgba(0,0,0,.5)}.searchbox__reset.hide{display:none}.searchbox__reset:focus{outline:0}.searchbox__reset svg{display:block;margin:4px;width:8px;height:8px}.searchbox__input:valid~.searchbox__reset{display:block;animation-name:sbx-reset-in;animation-duration:.15s}@keyframes sbx-reset-in{0%{transform:translate3d(-20%,0,0);opacity:0}to{transform:none;opacity:1}}.algolia-autocomplete.algolia-autocomplete-right .ds-dropdown-menu{right:0!important;left:inherit!important}.algolia-autocomplete.algolia-autocomplete-right .ds-dropdown-menu:before{right:48px}.algolia-autocomplete.algolia-autocomplete-left .ds-dropdown-menu{left:0!important;right:inherit!important}.algolia-autocomplete.algolia-autocomplete-left .ds-dropdown-menu:before{left:48px}.algolia-autocomplete .ds-dropdown-menu{top:-6px;border-radius:4px;margin:6px 0 0;padding:0;text-align:left;height:auto;position:relative;background:transparent;border:none;z-index:999;max-width:600px;min-width:500px;box-shadow:0 1px 0 0 rgba(0,0,0,.2),0 2px 3px 0 rgba(0,0,0,.1)}.algolia-autocomplete .ds-dropdown-menu:before{display:block;position:absolute;content:"";width:14px;height:14px;background:#fff;z-index:1000;top:-7px;border-top:1px solid #d9d9d9;border-right:1px solid #d9d9d9;transform:rotate(-45deg);border-radius:2px}.algolia-autocomplete .ds-dropdown-menu .ds-suggestions{position:relative;z-index:1000;margin-top:8px}.algolia-autocomplete .ds-dropdown-menu .ds-suggestions a:hover{text-decoration:none}.algolia-autocomplete .ds-dropdown-menu .ds-suggestion{cursor:pointer}.algolia-autocomplete .ds-dropdown-menu .ds-suggestion.ds-cursor .algolia-docsearch-suggestion.suggestion-layout-simple,.algolia-autocomplete .ds-dropdown-menu .ds-suggestion.ds-cursor .algolia-docsearch-suggestion:not(.suggestion-layout-simple) .algolia-docsearch-suggestion--content{background-color:rgba(69,142,225,.05)}.algolia-autocomplete .ds-dropdown-menu [class^=ds-dataset-]{position:relative;border:1px solid #d9d9d9;background:#fff;border-radius:4px;overflow:auto;padding:0 8px 8px}.algolia-autocomplete .ds-dropdown-menu *{box-sizing:border-box}.algolia-autocomplete .algolia-docsearch-suggestion{display:block;position:relative;padding:0 8px;background:#fff;color:#02060c;overflow:hidden}.algolia-autocomplete .algolia-docsearch-suggestion--highlight{color:#174d8c;background:rgba(143,187,237,.1);padding:.1em .05em}.algolia-autocomplete .algolia-docsearch-suggestion--category-header .algolia-docsearch-suggestion--category-header-lvl0 .algolia-docsearch-suggestion--highlight,.algolia-autocomplete .algolia-docsearch-suggestion--category-header .algolia-docsearch-suggestion--category-header-lvl1 .algolia-docsearch-suggestion--highlight,.algolia-autocomplete .algolia-docsearch-suggestion--text .algolia-docsearch-suggestion--highlight{padding:0 0 1px;background:inherit;box-shadow:inset 0 -2px 0 0 rgba(69,142,225,.8);color:inherit}.algolia-autocomplete .algolia-docsearch-suggestion--content{display:block;float:right;width:70%;position:relative;padding:5.33333px 0 5.33333px 10.66667px;cursor:pointer}.algolia-autocomplete .algolia-docsearch-suggestion--content:before{content:"";position:absolute;display:block;top:0;height:100%;width:1px;background:#ddd;left:-1px}.algolia-autocomplete .algolia-docsearch-suggestion--category-header{position:relative;border-bottom:1px solid #ddd;display:none;margin-top:8px;padding:4px 0;font-size:1em;color:#33363d}.algolia-autocomplete .algolia-docsearch-suggestion--wrapper{width:100%;float:left;padding:8px 0 0}.algolia-autocomplete .algolia-docsearch-suggestion--subcategory-column{float:left;width:30%;text-align:right;position:relative;padding:5.33333px 10.66667px;color:#a4a7ae;font-size:.9em;word-wrap:break-word}.algolia-autocomplete .algolia-docsearch-suggestion--subcategory-column:before{content:"";position:absolute;display:block;top:0;height:100%;width:1px;background:#ddd;right:0}.algolia-autocomplete .algolia-docsearch-suggestion--subcategory-inline{display:none}.algolia-autocomplete .algolia-docsearch-suggestion--title{margin-bottom:4px;color:#02060c;font-size:.9em;font-weight:700}.algolia-autocomplete .algolia-docsearch-suggestion--text{display:block;line-height:1.2em;font-size:.85em;color:#63676d}.algolia-autocomplete .algolia-docsearch-suggestion--no-results{width:100%;padding:8px 0;text-align:center;font-size:1.2em}.algolia-autocomplete .algolia-docsearch-suggestion--no-results:before{display:none}.algolia-autocomplete .algolia-docsearch-suggestion code{padding:1px 5px;font-size:90%;border:none;color:#222;background-color:#ebebeb;border-radius:3px;font-family:Menlo,Monaco,Consolas,Courier New,monospace}.algolia-autocomplete .algolia-docsearch-suggestion code .algolia-docsearch-suggestion--highlight{background:none}.algolia-autocomplete .algolia-docsearch-suggestion.algolia-docsearch-suggestion__main .algolia-docsearch-suggestion--category-header,.algolia-autocomplete .algolia-docsearch-suggestion.algolia-docsearch-suggestion__secondary{display:block}@media (min-width:768px){.algolia-autocomplete .algolia-docsearch-suggestion .algolia-docsearch-suggestion--subcategory-column{display:block}}@media (max-width:768px){.algolia-autocomplete .algolia-docsearch-suggestion .algolia-docsearch-suggestion--subcategory-column{display:inline-block;width:auto;float:left;padding:0;color:#02060c;font-size:.9em;font-weight:700;text-align:left;opacity:.5}.algolia-autocomplete .algolia-docsearch-suggestion .algolia-docsearch-suggestion--subcategory-column:before{display:none}.algolia-autocomplete .algolia-docsearch-suggestion .algolia-docsearch-suggestion--subcategory-column:after{content:"|"}.algolia-autocomplete .algolia-docsearch-suggestion .algolia-docsearch-suggestion--content{display:inline-block;width:auto;text-align:left;float:left;padding:0}.algolia-autocomplete .algolia-docsearch-suggestion .algolia-docsearch-suggestion--content:before{display:none}}.algolia-autocomplete .suggestion-layout-simple.algolia-docsearch-suggestion{border-bottom:1px solid #eee;padding:8px;margin:0}.algolia-autocomplete .suggestion-layout-simple .algolia-docsearch-suggestion--content{width:100%;padding:0}.algolia-autocomplete .suggestion-layout-simple .algolia-docsearch-suggestion--content:before{display:none}.algolia-autocomplete .suggestion-layout-simple .algolia-docsearch-suggestion--category-header{margin:0;padding:0;display:block;width:100%;border:none}.algolia-autocomplete .suggestion-layout-simple .algolia-docsearch-suggestion--category-header-lvl0,.algolia-autocomplete .suggestion-layout-simple .algolia-docsearch-suggestion--category-header-lvl1{opacity:.6;font-size:.85em}.algolia-autocomplete .suggestion-layout-simple .algolia-docsearch-suggestion--category-header-lvl1:before{background-image:url('data:image/svg+xml;utf8,');content:"";width:10px;height:10px;display:inline-block}.algolia-autocomplete .suggestion-layout-simple .algolia-docsearch-suggestion--wrapper{width:100%;float:left;margin:0;padding:0}.algolia-autocomplete .suggestion-layout-simple .algolia-docsearch-suggestion--duplicate-content,.algolia-autocomplete .suggestion-layout-simple .algolia-docsearch-suggestion--subcategory-inline{display:none!important}.algolia-autocomplete .suggestion-layout-simple .algolia-docsearch-suggestion--title{margin:0;color:#458ee1;font-size:.9em;font-weight:400}.algolia-autocomplete .suggestion-layout-simple .algolia-docsearch-suggestion--title:before{content:"#";font-weight:700;color:#458ee1;display:inline-block}.algolia-autocomplete .suggestion-layout-simple .algolia-docsearch-suggestion--text{margin:4px 0 0;display:block;line-height:1.4em;padding:5.33333px 8px;background:#f8f8f8;font-size:.85em;opacity:.8}.algolia-autocomplete .suggestion-layout-simple .algolia-docsearch-suggestion--text .algolia-docsearch-suggestion--highlight{color:#3f4145;font-weight:700;box-shadow:none}.algolia-autocomplete .algolia-docsearch-footer{width:134px;height:20px;z-index:2000;margin-top:10.66667px;float:right;font-size:0;line-height:0}.algolia-autocomplete .algolia-docsearch-footer--logo{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg width='168' height='24' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cpath d='M78.988.938h16.594a2.968 2.968 0 012.966 2.966V20.5a2.967 2.967 0 01-2.966 2.964H78.988a2.967 2.967 0 01-2.966-2.964V3.897A2.961 2.961 0 0178.988.938zm41.937 17.866c-4.386.02-4.386-3.54-4.386-4.106l-.007-13.336 2.675-.424v13.254c0 .322 0 2.358 1.718 2.364v2.248zm-10.846-2.18c.821 0 1.43-.047 1.855-.129v-2.719a6.334 6.334 0 00-1.574-.199 5.7 5.7 0 00-.897.069 2.699 2.699 0 00-.814.24c-.24.116-.439.28-.582.491-.15.212-.219.335-.219.656 0 .628.219.991.616 1.23s.938.362 1.615.362zm-.233-9.7c.883 0 1.629.109 2.231.328.602.218 1.088.525 1.444.915.363.396.609.922.76 1.483.157.56.232 1.175.232 1.85v6.874a32.5 32.5 0 01-1.868.314c-.834.123-1.772.185-2.813.185-.69 0-1.327-.069-1.895-.198a4.001 4.001 0 01-1.471-.636 3.085 3.085 0 01-.951-1.134c-.226-.465-.343-1.12-.343-1.803 0-.656.13-1.073.384-1.525a3.24 3.24 0 011.047-1.106c.445-.287.95-.492 1.532-.615a8.8 8.8 0 011.82-.185 8.404 8.404 0 011.972.24v-.438c0-.307-.035-.6-.11-.874a1.88 1.88 0 00-.384-.73 1.784 1.784 0 00-.724-.493 3.164 3.164 0 00-1.143-.205c-.616 0-1.177.075-1.69.164a7.735 7.735 0 00-1.26.307l-.321-2.192c.335-.117.834-.233 1.478-.349a10.98 10.98 0 012.073-.178zm52.842 9.626c.822 0 1.43-.048 1.854-.13V13.7a6.347 6.347 0 00-1.574-.199c-.294 0-.595.021-.896.069a2.7 2.7 0 00-.814.24 1.46 1.46 0 00-.582.491c-.15.212-.218.335-.218.656 0 .628.218.991.615 1.23.404.245.938.362 1.615.362zm-.226-9.694c.883 0 1.629.108 2.231.327.602.219 1.088.526 1.444.915.355.39.609.923.759 1.483a6.8 6.8 0 01.233 1.852v6.873c-.41.088-1.034.19-1.868.314-.834.123-1.772.184-2.813.184-.69 0-1.327-.068-1.895-.198a4.001 4.001 0 01-1.471-.635 3.085 3.085 0 01-.951-1.134c-.226-.465-.343-1.12-.343-1.804 0-.656.13-1.073.384-1.524.26-.45.608-.82 1.047-1.107.445-.286.95-.491 1.532-.614a8.803 8.803 0 012.751-.13c.329.034.671.096 1.04.185v-.437a3.3 3.3 0 00-.109-.875 1.873 1.873 0 00-.384-.731 1.784 1.784 0 00-.724-.492 3.165 3.165 0 00-1.143-.205c-.616 0-1.177.075-1.69.164a7.75 7.75 0 00-1.26.307l-.321-2.193c.335-.116.834-.232 1.478-.348a11.633 11.633 0 012.073-.177zm-8.034-1.271a1.626 1.626 0 01-1.628-1.62c0-.895.725-1.62 1.628-1.62.904 0 1.63.725 1.63 1.62 0 .895-.733 1.62-1.63 1.62zm1.348 13.22h-2.689V7.27l2.69-.423v11.956zm-4.714 0c-4.386.02-4.386-3.54-4.386-4.107l-.008-13.336 2.676-.424v13.254c0 .322 0 2.358 1.718 2.364v2.248zm-8.698-5.903c0-1.156-.253-2.119-.746-2.788-.493-.677-1.183-1.01-2.067-1.01-.882 0-1.574.333-2.065 1.01-.493.676-.733 1.632-.733 2.788 0 1.168.246 1.953.74 2.63.492.683 1.183 1.018 2.066 1.018.882 0 1.574-.342 2.067-1.019.492-.683.738-1.46.738-2.63zm2.737-.007c0 .902-.13 1.584-.397 2.33a5.52 5.52 0 01-1.128 1.906 4.986 4.986 0 01-1.752 1.223c-.685.286-1.739.45-2.265.45-.528-.006-1.574-.157-2.252-.45a5.096 5.096 0 01-1.744-1.223c-.487-.527-.863-1.162-1.137-1.906a6.345 6.345 0 01-.41-2.33c0-.902.123-1.77.397-2.508a5.554 5.554 0 011.15-1.892 5.133 5.133 0 011.75-1.216c.679-.287 1.425-.423 2.232-.423.808 0 1.553.142 2.237.423a4.88 4.88 0 011.753 1.216 5.644 5.644 0 011.135 1.892c.287.738.431 1.606.431 2.508zm-20.138 0c0 1.12.246 2.363.738 2.882.493.52 1.13.78 1.91.78.424 0 .828-.062 1.204-.178.377-.116.677-.253.917-.417V9.33a10.476 10.476 0 00-1.766-.226c-.971-.028-1.71.37-2.23 1.004-.513.636-.773 1.75-.773 2.788zm7.438 5.274c0 1.824-.466 3.156-1.404 4.004-.936.846-2.367 1.27-4.296 1.27-.705 0-2.17-.137-3.34-.396l.431-2.118c.98.205 2.272.26 2.95.26 1.074 0 1.84-.219 2.299-.656.459-.437.684-1.086.684-1.948v-.437a8.07 8.07 0 01-1.047.397c-.43.13-.93.198-1.492.198-.739 0-1.41-.116-2.018-.349a4.206 4.206 0 01-1.567-1.025c-.431-.45-.774-1.017-1.013-1.694-.24-.677-.363-1.885-.363-2.773 0-.834.13-1.88.384-2.577.26-.696.629-1.298 1.129-1.796.493-.498 1.095-.881 1.8-1.162a6.605 6.605 0 012.428-.457c.87 0 1.67.109 2.45.24.78.129 1.444.265 1.985.415V18.17z' fill='%235468FF'/%3E%3Cpath d='M6.972 6.677v1.627c-.712-.446-1.52-.67-2.425-.67-.585 0-1.045.13-1.38.391a1.24 1.24 0 00-.502 1.03c0 .425.164.765.494 1.02.33.256.835.532 1.516.83.447.192.795.356 1.045.495.25.138.537.332.862.582.324.25.563.548.718.894.154.345.23.741.23 1.188 0 .947-.334 1.691-1.004 2.234-.67.542-1.537.814-2.601.814-1.18 0-2.16-.229-2.936-.686v-1.708c.84.628 1.814.942 2.92.942.585 0 1.048-.136 1.388-.407.34-.271.51-.646.51-1.125 0-.287-.1-.55-.302-.79-.203-.24-.42-.42-.655-.542-.234-.123-.585-.29-1.053-.503a61.27 61.27 0 01-.582-.271 13.67 13.67 0 01-.55-.287 4.275 4.275 0 01-.567-.351 6.92 6.92 0 01-.455-.4c-.18-.17-.31-.34-.39-.51-.08-.17-.155-.37-.224-.598a2.553 2.553 0 01-.104-.742c0-.915.333-1.638.998-2.17.664-.532 1.523-.798 2.576-.798.968 0 1.793.17 2.473.51zm7.468 5.696v-.287c-.022-.607-.187-1.088-.495-1.444-.309-.357-.75-.535-1.324-.535-.532 0-.99.194-1.373.583-.382.388-.622.949-.717 1.683h3.909zm1.005 2.792v1.404c-.596.34-1.383.51-2.362.51-1.255 0-2.255-.377-3-1.132-.744-.755-1.116-1.744-1.116-2.968 0-1.297.34-2.316 1.021-3.055.68-.74 1.548-1.11 2.6-1.11 1.033 0 1.852.323 2.458.966.606.644.91 1.572.91 2.784 0 .33-.033.676-.096 1.038h-5.314c.107.702.405 1.239.894 1.611.49.372 1.106.558 1.85.558.862 0 1.58-.202 2.155-.606zm6.605-1.77h-1.212c-.596 0-1.045.116-1.349.35-.303.234-.454.532-.454.894 0 .372.117.664.35.877.235.213.575.32 1.022.32.51 0 .912-.142 1.204-.424.293-.281.44-.651.44-1.108v-.91zm-4.068-2.554V9.325c.627-.361 1.457-.542 2.489-.542 2.116 0 3.175 1.026 3.175 3.08V17h-1.548v-.957c-.415.68-1.143 1.02-2.186 1.02-.766 0-1.38-.22-1.843-.661-.462-.442-.694-1.003-.694-1.684 0-.776.293-1.38.878-1.81.585-.431 1.404-.647 2.457-.647h1.34V11.8c0-.554-.133-.971-.399-1.253-.266-.282-.707-.423-1.324-.423a4.07 4.07 0 00-2.345.718zm9.333-1.93v1.42c.394-1 1.101-1.5 2.123-1.5.148 0 .313.016.494.048v1.531a1.885 1.885 0 00-.75-.143c-.542 0-.989.24-1.34.718-.351.479-.527 1.048-.527 1.707V17h-1.563V8.91h1.563zm5.01 4.084c.022.82.272 1.492.75 2.019.479.526 1.15.79 2.01.79.639 0 1.235-.176 1.788-.527v1.404c-.521.319-1.186.479-1.995.479-1.265 0-2.276-.4-3.031-1.197-.755-.798-1.133-1.792-1.133-2.984 0-1.16.38-2.151 1.14-2.975.761-.825 1.79-1.237 3.088-1.237.702 0 1.346.149 1.93.447v1.436a3.242 3.242 0 00-1.77-.495c-.84 0-1.513.266-2.019.798-.505.532-.758 1.213-.758 2.042zM40.24 5.72v4.579c.458-1 1.293-1.5 2.505-1.5.787 0 1.42.245 1.899.734.479.49.718 1.17.718 2.042V17h-1.564v-5.106c0-.553-.14-.98-.422-1.284-.282-.303-.652-.455-1.11-.455-.531 0-1.002.202-1.411.606-.41.405-.615 1.022-.615 1.851V17h-1.563V5.72h1.563zm14.966 10.02c.596 0 1.096-.253 1.5-.758.404-.506.606-1.157.606-1.955 0-.915-.202-1.62-.606-2.114-.404-.495-.92-.742-1.548-.742-.553 0-1.05.224-1.491.67-.442.447-.662 1.133-.662 2.058 0 .958.212 1.67.638 2.138.425.469.946.703 1.563.703zM53.004 5.72v4.42c.574-.894 1.388-1.341 2.44-1.341 1.022 0 1.857.383 2.506 1.149.649.766.973 1.781.973 3.047 0 1.138-.309 2.109-.925 2.912-.617.803-1.463 1.205-2.537 1.205-1.075 0-1.894-.447-2.457-1.34V17h-1.58V5.72h1.58zm9.908 11.104l-3.223-7.913h1.739l1.005 2.632 1.26 3.415c.096-.32.48-1.458 1.15-3.415l.909-2.632h1.66l-2.92 7.866c-.777 2.074-1.963 3.11-3.559 3.11a2.92 2.92 0 01-.734-.079v-1.34c.17.042.351.064.543.064 1.032 0 1.755-.57 2.17-1.708z' fill='%235D6494'/%3E%3Cpath d='M89.632 5.967v-.772a.978.978 0 00-.978-.977h-2.28a.978.978 0 00-.978.977v.793c0 .088.082.15.171.13a7.127 7.127 0 011.984-.28c.65 0 1.295.088 1.917.259.082.02.164-.04.164-.13m-6.248 1.01l-.39-.389a.977.977 0 00-1.382 0l-.465.465a.973.973 0 000 1.38l.383.383c.062.061.15.047.205-.014.226-.307.472-.601.746-.874.281-.28.568-.526.883-.751.068-.042.075-.137.02-.2m4.16 2.453v3.341c0 .096.104.165.192.117l2.97-1.537c.068-.034.089-.117.055-.184a3.695 3.695 0 00-3.08-1.866c-.068 0-.136.054-.136.13m0 8.048a4.489 4.489 0 01-4.49-4.482 4.488 4.488 0 014.49-4.482 4.488 4.488 0 014.489 4.482 4.484 4.484 0 01-4.49 4.482m0-10.85a6.363 6.363 0 100 12.729 6.37 6.37 0 006.372-6.368 6.358 6.358 0 00-6.371-6.36' fill='%23FFF'/%3E%3C/g%3E%3C/svg%3E");background-repeat:no-repeat;background-position:50%;background-size:100%;overflow:hidden;text-indent:-9000px;padding:0!important;width:100%;height:100%;display:block}.sidebar .sidebar-sub-headers{padding-left:1rem;font-size:.95em}a.sidebar-link{font-size:1em;font-weight:400;display:inline-block;color:#292828;border-left:.25rem solid transparent;padding:.35rem 1rem .35rem 1.25rem;line-height:1.4;width:100%;box-sizing:border-box}a.sidebar-link:hover{color:#07aab4}a.sidebar-link.active{font-weight:600;color:#07aab4;border-left-color:#07aab4}.sidebar-group a.sidebar-link{padding-left:2rem}.sidebar-sub-headers a.sidebar-link{padding-top:.25rem;padding-bottom:.25rem;border-left:none}.sidebar-sub-headers a.sidebar-link.active{font-weight:500}.navbar{padding:.7rem 1.5rem;line-height:2.2rem}.navbar a,.navbar img,.navbar span{display:inline-block}.navbar .logo{height:2.2rem;min-width:2.2rem;margin-right:.8rem;vertical-align:top}.navbar .site-name{font-size:1.3rem;font-weight:600;color:#292828;position:relative}.navbar .links{padding-left:1.5rem;box-sizing:border-box;background-color:#fff;white-space:nowrap;font-size:.9rem;position:absolute;right:1.5rem;top:.7rem;display:flex}.navbar .links .search-box{flex:0 0 auto;vertical-align:top}@media (max-width:719px){.navbar{padding-left:4rem}.navbar .can-hide{display:none}.navbar .links{padding-left:1.5rem}.navbar .site-name{width:calc(100vw - 9.4rem);overflow:hidden;white-space:nowrap;text-overflow:ellipsis}}.nav-links{display:inline-block}.nav-links a{line-height:1.4rem;color:inherit}.nav-links a.router-link-active,.nav-links a:hover{color:#07aab4}.nav-links .nav-item{position:relative;display:inline-block;margin-left:1.5rem;line-height:2rem}.nav-links .nav-item:first-child{margin-left:0}.nav-links .repo-link{margin-left:1.5rem}@media (max-width:719px){.nav-links .nav-item,.nav-links .repo-link{margin-left:0}}@media (min-width:719px){.nav-links a.router-link-active,.nav-links a:hover{color:#292828}.nav-item>a:not(.external).router-link-active,.nav-item>a:not(.external):hover{margin-bottom:-2px;border-bottom:2px solid #08c1cd}}.search-box{display:inline-block;position:relative;margin-right:1rem}.search-box input{cursor:text;width:10rem;height:2rem;color:#5f5d5d;display:inline-block;border:1px solid #cfd4db;border-radius:2rem;font-size:.9rem;line-height:2rem;padding:0 .5rem 0 2rem;outline:none;transition:all .2s ease;background:#fff url(/assets/img/search.83621669.svg) .6rem .5rem no-repeat;background-size:1rem}.search-box input:focus{cursor:auto;border-color:#07aab4}.search-box .suggestions{background:#fff;width:20rem;position:absolute;top:2rem;border:1px solid #cfd4db;border-radius:6px;padding:.4rem;list-style-type:none}.search-box .suggestions.align-right{right:0}.search-box .suggestion{line-height:1.4;padding:.4rem .6rem;border-radius:4px;cursor:pointer}.search-box .suggestion a{white-space:normal;color:#757272}.search-box .suggestion a .page-title{font-weight:600}.search-box .suggestion a .header{font-size:.9em;margin-left:.25em}.search-box .suggestion.focused{background-color:#f3f4f5}.search-box .suggestion.focused a{color:#07aab4}@media (max-width:959px){.search-box input{cursor:pointer;width:0;border-color:transparent;position:relative}.search-box input:focus{cursor:text;left:0;width:10rem}}@media (-ms-high-contrast:none){.search-box input{height:2rem}}@media (max-width:959px) and (min-width:719px){.search-box .suggestions{left:0}}@media (max-width:719px){.search-box{margin-right:0}.search-box input{left:1rem}.search-box .suggestions{right:0}}@media (max-width:480px){.search-box .suggestions{width:calc(100vw - 4rem)}.search-box input:focus{width:8rem}}.dropdown-wrapper{cursor:pointer}.dropdown-wrapper .dropdown-title,.dropdown-wrapper .mobile-dropdown-title{display:block;font-size:.9rem;font-family:inherit;cursor:inherit;padding:inherit;line-height:1.4rem;background:transparent;border:none;font-weight:500;color:#292828}.dropdown-wrapper .dropdown-title:hover,.dropdown-wrapper .mobile-dropdown-title:hover{border-color:transparent}.dropdown-wrapper .dropdown-title .arrow,.dropdown-wrapper .mobile-dropdown-title .arrow{vertical-align:middle;margin-top:-1px;margin-left:.4rem}.dropdown-wrapper .mobile-dropdown-title{display:none;font-weight:600}.dropdown-wrapper .mobile-dropdown-title font-size inherit:hover{color:#07aab4}.dropdown-wrapper .nav-dropdown .dropdown-item{color:inherit;line-height:1.7rem}.dropdown-wrapper .nav-dropdown .dropdown-item h4{margin:.45rem 0 0;border-top:1px solid #eee;padding:1rem 1.5rem .45rem 1.25rem}.dropdown-wrapper .nav-dropdown .dropdown-item .dropdown-subitem-wrapper{padding:0;list-style:none}.dropdown-wrapper .nav-dropdown .dropdown-item .dropdown-subitem-wrapper .dropdown-subitem{font-size:.9em}.dropdown-wrapper .nav-dropdown .dropdown-item a{display:block;line-height:1.7rem;position:relative;border-bottom:none;font-weight:400;margin-bottom:0;padding:0 1.5rem 0 1.25rem}.dropdown-wrapper .nav-dropdown .dropdown-item a.router-link-active,.dropdown-wrapper .nav-dropdown .dropdown-item a:hover{color:#07aab4}.dropdown-wrapper .nav-dropdown .dropdown-item a.router-link-active:after{content:"";width:0;height:0;border-left:5px solid #07aab4;border-top:3px solid transparent;border-bottom:3px solid transparent;position:absolute;top:calc(50% - 2px);left:9px}.dropdown-wrapper .nav-dropdown .dropdown-item:first-child h4{margin-top:0;padding-top:0;border-top:0}@media (max-width:719px){.dropdown-wrapper.open .dropdown-title{margin-bottom:.5rem}.dropdown-wrapper .dropdown-title{display:none}.dropdown-wrapper .mobile-dropdown-title{display:block}.dropdown-wrapper .nav-dropdown{transition:height .1s ease-out;overflow:hidden}.dropdown-wrapper .nav-dropdown .dropdown-item h4{border-top:0;margin-top:0;padding-top:0}.dropdown-wrapper .nav-dropdown .dropdown-item>a,.dropdown-wrapper .nav-dropdown .dropdown-item h4{font-size:15px;line-height:2rem}.dropdown-wrapper .nav-dropdown .dropdown-item .dropdown-subitem{font-size:14px;padding-left:1rem}}@media (min-width:719px){.dropdown-wrapper{height:1.8rem}.dropdown-wrapper.open .nav-dropdown,.dropdown-wrapper:hover .nav-dropdown{display:block!important}.dropdown-wrapper.open:blur{display:none}.dropdown-wrapper .nav-dropdown{display:none;height:auto!important;box-sizing:border-box;max-height:calc(100vh - 2.7rem);overflow-y:auto;position:absolute;top:100%;right:0;background-color:#fff;padding:.6rem 0;border:1px solid;border-color:#ddd #ddd #ccc;text-align:left;border-radius:.25rem;white-space:nowrap;margin:0}}.dropdown-enter,.dropdown-leave-to{height:0!important}.sidebar-button{cursor:pointer;display:none;width:1.25rem;height:1.25rem;position:absolute;padding:.6rem;top:.6rem;left:1rem}.sidebar-button .icon{display:block;width:1.25rem;height:1.25rem}@media (max-width:719px){.sidebar-button{display:block}} \ No newline at end of file diff --git a/assets/img/contributors.dfa0ba17.jpg b/assets/img/contributors.dfa0ba17.jpg new file mode 100644 index 000000000..6c9404257 Binary files /dev/null and b/assets/img/contributors.dfa0ba17.jpg differ diff --git a/assets/js/1.456afe5a.js b/assets/js/1.456afe5a.js new file mode 100644 index 000000000..4e322df7c --- /dev/null +++ b/assets/js/1.456afe5a.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[1,13,16,40,41,42],{238:function(t,e,n){"use strict";n.d(e,"d",(function(){return s})),n.d(e,"a",(function(){return r})),n.d(e,"i",(function(){return o})),n.d(e,"f",(function(){return l})),n.d(e,"g",(function(){return u})),n.d(e,"h",(function(){return c})),n.d(e,"b",(function(){return h})),n.d(e,"e",(function(){return f})),n.d(e,"k",(function(){return p})),n.d(e,"l",(function(){return d})),n.d(e,"c",(function(){return m})),n.d(e,"j",(function(){return k}));n(88);const s=/#.*$/,i=/\.(md|html)$/,r=/\/$/,o=/^[a-z]+:/i;function a(t){return decodeURI(t).replace(s,"").replace(i,"")}function l(t){return o.test(t)}function u(t){return/^mailto:/.test(t)}function c(t){return/^tel:/.test(t)}function h(t){if(l(t))return t;const e=t.match(s),n=e?e[0]:"",i=a(t);return r.test(i)?t:i+".html"+n}function f(t,e){const n=decodeURIComponent(t.hash),i=function(t){const e=t.match(s);if(e)return e[0]}(e);if(i&&n!==i)return!1;return a(t.path)===a(e)}function p(t,e,n){if(l(e))return{type:"external",path:e};n&&(e=function(t,e,n){const s=t.charAt(0);if("/"===s)return t;if("?"===s||"#"===s)return e+t;const i=e.split("/");n&&i[i.length-1]||i.pop();const r=t.replace(/^\//,"").split("/");for(let t=0;tfunction t(e,n,s,i=1){if("string"==typeof e)return p(n,e,s);if(Array.isArray(e))return Object.assign(p(n,e[0],s),{title:e[1]});{const r=e.children||[];return 0===r.length&&e.path?Object.assign(p(n,e.path,s),{title:e.title}):{type:"group",path:e.path,title:e.title,sidebarDepth:e.sidebarDepth,initialOpenGroupIndex:e.initialOpenGroupIndex,children:r.map(e=>t(e,n,s,i+1)),collapsable:!1!==e.collapsable}}}(t,i,n)):[]}return[]}function g(t){const e=m(t.headers||[]);return[{type:"group",collapsable:!1,title:t.title,path:null,children:e.map(e=>({type:"auto",title:e.title,basePath:t.path,path:t.path+"#"+e.slug,children:e.children||[]}))}]}function m(t){let e;return(t=t.map(t=>Object.assign({},t))).forEach(t=>{2===t.level?e=t:e&&(e.children||(e.children=[])).push(t)}),t.filter(t=>2===t.level)}function k(t){return Object.assign(t,{type:t.items&&t.items.length?"links":"link"})}},239:function(t,e,n){},240:function(t,e,n){"use strict";n.r(e);var s=n(238),i={name:"NavLink",props:{item:{required:!0}},computed:{link(){return Object(s.b)(this.item.link)},exact(){return this.$site.locales?Object.keys(this.$site.locales).some(t=>t===this.link):"/"===this.link},isNonHttpURI(){return Object(s.g)(this.link)||Object(s.h)(this.link)},isBlankTarget(){return"_blank"===this.target},isInternal(){return!Object(s.f)(this.link)&&!this.isBlankTarget},target(){return this.isNonHttpURI?null:this.item.target?this.item.target:Object(s.f)(this.link)?"_blank":""},rel(){return this.isNonHttpURI||!1===this.item.rel?null:this.item.rel?this.item.rel:this.isBlankTarget?"noopener noreferrer":null}},methods:{focusoutAction(){this.$emit("focusout")}}},r=n(14),o=Object(r.a)(i,(function(){var t=this,e=t._self._c;return t.isInternal?e("RouterLink",{staticClass:"nav-link",attrs:{to:t.link,exact:t.exact},nativeOn:{focusout:function(e){return t.focusoutAction.apply(null,arguments)}}},[t._v("\n "+t._s(t.item.text)+"\n")]):e("a",{staticClass:"nav-link external",attrs:{href:t.link,target:t.target,rel:t.rel},on:{focusout:t.focusoutAction}},[t._v("\n "+t._s(t.item.text)+"\n "),t.isBlankTarget?e("OutboundLink"):t._e()],1)}),[],!1,null,null,null);e.default=o.exports},241:function(t,e,n){"use strict";n.r(e);var s={name:"DropdownTransition",methods:{setHeight(t){t.style.height=t.scrollHeight+"px"},unsetHeight(t){t.style.height=""}}},i=(n(243),n(14)),r=Object(i.a)(s,(function(){return(0,this._self._c)("transition",{attrs:{name:"dropdown"},on:{enter:this.setHeight,"after-enter":this.unsetHeight,"before-leave":this.setHeight}},[this._t("default")],2)}),[],!1,null,null,null);e.default=r.exports},242:function(t,e,n){},243:function(t,e,n){"use strict";n(239)},247:function(t,e,n){},250:function(t,e,n){"use strict";n(242)},254:function(t,e,n){"use strict";n.r(e);var s=n(240),i=n(241),r=n(89),o=n.n(r),a={name:"DropdownLink",components:{NavLink:s.default,DropdownTransition:i.default},props:{item:{required:!0}},data:()=>({open:!1}),computed:{dropdownAriaLabel(){return this.item.ariaLabel||this.item.text}},watch:{$route(){this.open=!1}},methods:{setOpen(t){this.open=t},isLastItemOfArray:(t,e)=>o()(e)===t,handleDropdown(){0===event.detail&&this.setOpen(!this.open)}}},l=(n(250),n(14)),u=Object(l.a)(a,(function(){var t=this,e=t._self._c;return e("div",{staticClass:"dropdown-wrapper",class:{open:t.open}},[e("button",{staticClass:"dropdown-title",attrs:{type:"button","aria-label":t.dropdownAriaLabel},on:{click:t.handleDropdown}},[e("span",{staticClass:"title"},[t._v(t._s(t.item.text))]),t._v(" "),e("span",{staticClass:"arrow down"})]),t._v(" "),e("button",{staticClass:"mobile-dropdown-title",attrs:{type:"button","aria-label":t.dropdownAriaLabel},on:{click:function(e){return t.setOpen(!t.open)}}},[e("span",{staticClass:"title"},[t._v(t._s(t.item.text))]),t._v(" "),e("span",{staticClass:"arrow",class:t.open?"down":"right"})]),t._v(" "),e("DropdownTransition",[e("ul",{directives:[{name:"show",rawName:"v-show",value:t.open,expression:"open"}],staticClass:"nav-dropdown"},t._l(t.item.items,(function(n,s){return e("li",{key:n.link||s,staticClass:"dropdown-item"},["links"===n.type?e("h4",[t._v("\n "+t._s(n.text)+"\n ")]):t._e(),t._v(" "),"links"===n.type?e("ul",{staticClass:"dropdown-subitem-wrapper"},t._l(n.items,(function(s){return e("li",{key:s.link,staticClass:"dropdown-subitem"},[e("NavLink",{attrs:{item:s},on:{focusout:function(e){t.isLastItemOfArray(s,n.items)&&t.isLastItemOfArray(n,t.item.items)&&t.setOpen(!1)}}})],1)})),0):e("NavLink",{attrs:{item:n},on:{focusout:function(e){t.isLastItemOfArray(n,t.item.items)&&t.setOpen(!1)}}})],1)})),0)])],1)}),[],!1,null,null,null);e.default=u.exports},260:function(t,e,n){"use strict";n(247)},261:function(t,e,n){},267:function(t,e,n){"use strict";n.r(e);var s=n(254),i=n(238),r={name:"NavLinks",components:{NavLink:n(240).default,DropdownLink:s.default},computed:{userNav(){return this.$themeLocaleConfig.nav||this.$site.themeConfig.nav||[]},nav(){const{locales:t}=this.$site;if(t&&Object.keys(t).length>1){const e=this.$page.path,n=this.$router.options.routes,s=this.$site.themeConfig.locales||{},i={text:this.$themeLocaleConfig.selectText||"Languages",ariaLabel:this.$themeLocaleConfig.ariaLabel||"Select language",items:Object.keys(t).map(i=>{const r=t[i],o=s[i]&&s[i].label||r.lang;let a;return r.lang===this.$lang?a=e:(a=e.replace(this.$localeConfig.path,i),n.some(t=>t.path===a)||(a=i)),{text:o,link:a}})};return[...this.userNav,i]}return this.userNav},userLinks(){return(this.nav||[]).map(t=>Object.assign(Object(i.j)(t),{items:(t.items||[]).map(i.j)}))},repoLink(){const{repo:t}=this.$site.themeConfig;return t?/^https?:/.test(t)?t:"https://github.com/"+t:null},repoLabel(){if(!this.repoLink)return;if(this.$site.themeConfig.repoLabel)return this.$site.themeConfig.repoLabel;const t=this.repoLink.match(/^https?:\/\/[^/]+/)[0],e=["GitHub","GitLab","Bitbucket"];for(let n=0;n{let s=i()(e,"title","");return i()(e,"frontmatter.tags")&&(s+=" "+e.frontmatter.tags.join(" ")),n&&(s+=" "+n),o(t,s)};const o=(t,e)=>{const n=t=>t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&"),s=new RegExp("[^\0-]"),i=t.split(/\s+/g).map(t=>t.trim()).filter(t=>!!t);if(s.test(t))return i.some(t=>e.toLowerCase().indexOf(t)>-1);{const s=t.endsWith(" ");return new RegExp(i.map((t,e)=>i.length!==e+1||s?`(?=.*\\b${n(t)}\\b)`:`(?=.*\\b${n(t)})`).join("")+".+","gi").test(e)}};var a={name:"SearchBox",data:()=>({query:"",focused:!1,focusIndex:0,placeholder:void 0}),computed:{showSuggestions(){return this.focused&&this.suggestions&&this.suggestions.length},suggestions(){const t=this.query.trim().toLowerCase();if(!t)return;const{pages:e}=this.$site,n=this.$site.themeConfig.searchMaxSuggestions||5,s=this.$localePath,i=[];for(let o=0;o=n);o++){const a=e[o];if(this.getPageLocalePath(a)===s&&this.isSearchable(a))if(r(t,a))i.push(a);else if(a.headers)for(let e=0;e=n);e++){const n=a.headers[e];n.title&&r(t,a,n.title)&&i.push(Object.assign({},a,{path:a.path+"#"+n.slug,header:n}))}}return i},alignRight(){return(this.$site.themeConfig.nav||[]).length+(this.$site.repo?1:0)<=2}},mounted(){this.placeholder=this.$site.themeConfig.searchPlaceholder||"",document.addEventListener("keydown",this.onHotkey)},beforeDestroy(){document.removeEventListener("keydown",this.onHotkey)},methods:{getPageLocalePath(t){for(const e in this.$site.locales||{})if("/"!==e&&0===t.path.indexOf(e))return e;return"/"},isSearchable(t){let e=null;return null===e||(e=Array.isArray(e)?e:new Array(e),e.filter(e=>t.path.match(e)).length>0)},onHotkey(t){t.srcElement===document.body&&["s","/"].includes(t.key)&&(this.$refs.input.focus(),t.preventDefault())},onUp(){this.showSuggestions&&(this.focusIndex>0?this.focusIndex--:this.focusIndex=this.suggestions.length-1)},onDown(){this.showSuggestions&&(this.focusIndex "+t._s(n.header.title))]):t._e()])])})),0):t._e()])}),[],!1,null,null,null).exports,c=n(310),h=n(267);function f(t,e){return t.ownerDocument.defaultView.getComputedStyle(t,null)[e]}var p={name:"Navbar",components:{SidebarButton:c.default,NavLinks:h.default,SearchBox:u,AlgoliaSearchBox:{}},data:()=>({linksWrapMaxWidth:null}),computed:{algolia(){return this.$themeLocaleConfig.algolia||this.$site.themeConfig.algolia||{}},isAlgoliaSearch(){return this.algolia&&this.algolia.apiKey&&this.algolia.indexName}},mounted(){const t=parseInt(f(this.$el,"paddingLeft"))+parseInt(f(this.$el,"paddingRight")),e=()=>{document.documentElement.clientWidth<719?this.linksWrapMaxWidth=null:this.linksWrapMaxWidth=this.$el.offsetWidth-t-(this.$refs.siteName&&this.$refs.siteName.offsetWidth||0)};e(),window.addEventListener("resize",e,!1)}},d=(n(320),Object(l.a)(p,(function(){var t=this,e=t._self._c;return e("header",{staticClass:"navbar"},[e("SidebarButton",{on:{"toggle-sidebar":function(e){return t.$emit("toggle-sidebar")}}}),t._v(" "),e("RouterLink",{staticClass:"home-link",attrs:{to:t.$localePath}},[t.$site.themeConfig.logo?e("img",{staticClass:"logo",attrs:{src:t.$withBase(t.$site.themeConfig.logo),alt:t.$siteTitle}}):t._e(),t._v(" "),t.$siteTitle?e("span",{ref:"siteName",staticClass:"site-name",class:{"can-hide":t.$site.themeConfig.logo}},[t._v(t._s(t.$siteTitle))]):t._e()]),t._v(" "),e("div",{staticClass:"links",style:t.linksWrapMaxWidth?{"max-width":t.linksWrapMaxWidth+"px"}:{}},[t.isAlgoliaSearch?e("AlgoliaSearchBox",{attrs:{options:t.algolia}}):!1!==t.$site.themeConfig.search&&!1!==t.$page.frontmatter.search?e("SearchBox"):t._e(),t._v(" "),e("NavLinks",{staticClass:"can-hide"})],1)],1)}),[],!1,null,null,null));e.default=d.exports}}]); \ No newline at end of file diff --git a/assets/js/10.29ee2b39.js b/assets/js/10.29ee2b39.js new file mode 100644 index 000000000..80debcbad --- /dev/null +++ b/assets/js/10.29ee2b39.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[10],{325:function(t,r,e){t.exports=e.p+"assets/img/eslint.01955545.png"},326:function(t,r,e){t.exports=e.p+"assets/img/stoplight.d7a77d4d.png"},327:function(t,r,e){t.exports=e.p+"assets/img/webpack.84759e93.svg"},328:function(t,r,e){t.exports=e.p+"assets/img/fastify.a4139f0f.png"},329:function(t,r,e){t.exports=e.p+"assets/img/taskcluster.0221addc.png"},330:function(t,r,e){t.exports=e.p+"assets/img/rxdb.a3ab2aad.svg"},331:function(t,r,e){t.exports=e.p+"assets/img/rjsf.84438f22.png"},332:function(t,r,e){t.exports=e.p+"assets/img/autorest.e9363112.png"},333:function(t,r,e){t.exports=e.p+"assets/img/nodered.65e93379.png"},334:function(t,r,e){t.exports=e.p+"assets/img/mdn.a61a6b37.svg"},335:function(t,r,e){t.exports=e.p+"assets/img/quicktype.d558c16d.svg"},336:function(t,r){t.exports="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAAV00lEQVR4nOydbawc1XnH/zOzc+5dv+CLfZ2XJoS8lEASaAgJJEBJqqof+iGq+qHqh/ZD1VaVmqpqDJgERJpCQhMSEDWIBMWNiAhV3KAUYUWWXIEiK/hSWbFqCRRnFmTFDS/G8Yyx7717z+6dubvVs3sMey939u7LzDzP7p6fZGl9d+ac/zzn/HfnnD3PnNLnv3AzLBbL+rjcAiwWyViDWCxdsAaxWLpgDWKxdMEaxGLpgjWIxdIFaxCLpQvWIBZLF6xBLJYuWINYLF2wBrFYumANYrF0obR8eXkXgG3cQtKI//cNNOMGt4xVTO8oP1xacSJuHf2QeM0dtUj/I7eOThzfhX/NDL3ilpLG+dLKbMlpzPp3cStJI16soT4XcstYxYpy3rdtU/lvuXX0Q3Wh9u3aOf033Do6mbpxFrhiE7eMVNwwvsVVgX4YQMAtJo3S1TNwZxS3jFXUQv3XutT4BLeOXiGtpJlbRyfONr/VtoIJyBuuFyWxG8Zik0KckgN10yy3jNU0ms7iG0sPcsvolZbWRlPUfczUZ3e22lYq5ImWN+g/5bmFgwAOcItKo/TBzfDeJ+uruBHVb1rwkj/n1rERpJG0cuvoxLtkU6tNBXPAeOKtWSw/0LcAWGaV1QX6xIEr6xNHv179t7gEWfd/HZA20sitYxUuMPW5ndwqurFsvNDiTYOoin4RwENssjbA3aHgXyVrsq1ZTX5nSdfv5NaRBmkjjdw6OvGvmmm1pWAeMl5osep3kOnD818HcJpFVg+oz+yAM+1xy1hF/bdLt8du8xJuHWshTaSNW0cn1HbUhoI5bTzwJqsM4kXJvBvGYj8RnWkX6npZAW7GDXV+qfYAt461kCbSxq2jE2o7akOpUN8nD6z629qDVKB/AOBoocr6wL/yIrizU9wyVrFyeunPtNv4LLeOC5AW0sStoxNqM2o7wRw1fX8VbzOIFyUNP9C76MOxMGn94DryBnlNYDGqihm/tbQIaz2JkywdNKnPU99f+8a633eqoucA7CtE2gB47y2j9KEt3DJW0Ti//PF5J/47bh2kgbRw6+iE2sq7pMwtoxv7TJ9/G6k3hH6gvwygmqusIZj67CzgyfpEqr2+9K3Ea27lqp/qJg1c9a+L57TbSi5V09fXJdUgqqJfccNYVrA7cC7yoa7Zzi1jFU2dXFyt1v+Vq36qmzRw1b8e1EbUVlJxw/he6uup73c7WQX6PgAnc1GWAf61M3C2lLhlrKJ2ZukfarPeFYXXO+tdQXUXXW83qG2ojQRzUgX6/m4HdDWIFyU1N4xvy1xWRji+214RKomVprfwf/OF/3rdqnOlKepHImobaiOpuGG8m/p412M2KkQF+icADmWqLENKl2+B+25ZA8DGmdofa6x8vqj6qC6qs6j6eoHahNpGMIdUoP9ro4M2NIgXJTRg/yJ9NmYmLUscB9Of2yku52Yxqu5JSvlnbFIdVFfe9fSFA9MmwhrlLVaoT1Pf3oieGlBV9PMA9mahLA/cd07B/4isdVqNhfhDS/XlW/Ouh+qguvKupx+oLahNBLPX9OkN6fkTbvrw/FcBvDGUrBxRN+6Ao2Td79ZOV/8l9pq5/apJZVMdeZU/CNQG6gZZy4HWcNb05Z7ouUd5URK6YSw2NdfZ5EFdJ6thmsuNzfO6dl9e5VPZVEde5Q8CtYGzWdRcwSrcML6b+nLPx/dTuAr0dwEcH0hZAfhXbxOXnpu8rv9KlxqfyrpcKpPKzrrcYaDYUxsI5rjpwz3Tl0G8KEncMN7Vt6yikPirbaOJxbPZp+e2ymzIWnAlcXVDJ+6r9V3Uh/s6p99KynMLTwPY3+95ReF9YDO8S0XddaBxtn7D4nb8RVblUVlUZlblZQHFnGIvmP3lo9Wn+z1poFGtH+hbAdQHObcIWp9kwlaOLgXnH0hKmB62HCqDyspGVUa4Ar+5V1M3fbZvBjKIqugTAGTNvXfgbldQH5e1xKG5lLyzulQfesaJyqCyslGVDRRrirlg9pg+2zcDz4tOH56/B8CpQc/PG//T2+GUZc2m1M4s3RK7zfcPej6dS2Vkq2o4KMb+dbIWja7hlOmrAzGwQbwoWXTD+I5Bz88bZ8qFukHY137cUOereuB1Wq1zhaXRTl0/Kz2N9g7qqwOfP0zlKtA/BHBkmDLyxP/oVrg7h77tz5SV3+o/1W7jD/s9j86hc/NRNRgU29LH2NJfeuGI6aMDM5RBvChpmnVasuYbLyA2PXfxwaSPVfp0LJ0jLcqt2AqbDOmgadZbDRW1ob8bVUXTN8h/DFtOXnjvmUbpw7I+5Rrn4yuXkvgLvR5Px9I5+arqj9JlW1uxFczjpm8ORSY3j36gbwcw8H1e3kz9/iwg7Dmwtder9yZec8OfnekYOrYYVT1ScjAl7XnJq1n0A53J+DgTg6iKfs0N429kUVYeOFtLUJ+SNdPSrK1cVK3WN4xZK422tiLqeTnqk9tbMZUK9UXqk5mUlUUhaA/YHwAw0FxzEfjXzMDZIis3unZm6e+13/xY2vv0Xu3MUs+3YkVAMfQ/Kes3pjWcMH0xEzIziBcldTeMd2dVXta00nOl3RasNN3qG0upP7i23ltpippDpRiOQBptZqs8Mr1SFeinADyTZZlZUvrwFnjvkZWeuxLW/kg3kz9Z+3f6G73Ho2p9KHaly0Svt3qmPLfwVJYFZmoQk567i8aWWZabJa0n/Mkar2MxWnooKeHNn/3pNf2NV9UanAuxExa8t0hM38uUzL8rVUX/EsAjWZebFe47puBfKeseurEYX1qtL3/pwv/pNf2NV9Vq/Cu3tWInmEdM38uUXG4mpw/P3wVA7C6w6vrtcKZkrdOqn67+c+I230X/6DW3nk5aabTCnqq/hsj0uczJxSBelJx1w7jnvN+iccoe1KeFTfsuN8rnarX76R+95tbTSWtfFmELPzuhvkZ9Lpey8ygU7QH79wC8kFf5w+L/3jZxS7RXXtd/Sf+4dXRCMaJYCeYF09dyITeDeFGyIj499yZh67QaTYhLo6UYSU6jDeNd1NdyKz+vgtFOz/0ZgCfzrGMYvPdvQukDop/+xwrFhmIkmCdNH8uN3H/x8QO9u/V0TKG09mAX/AnJhudA3SR6YK5N38qV3A2iKvrXbhjLyqHuwL3Yh7pa1I4BIqCYuBfLGqN1Qn2K+lbu9eRdAdoD9m8CSN2DgRv/uovhlOUuvisaioV/regPjVdMn8qdQgziRUnVDWNRWxJ34igXUzeKvp0oFIqFMyV6vdXt1KcKqauIStD+FvkRgP8pqr5+KX10K9x3iE4AKgSKAcVCMM+ZvlQIhRnEpOf+E4C37SQqAsfB1B8Im/ZloBUDueutGlmk0fZDod+jqqKPAnisyDr7wXv3NEqXi/70zBW6doqBYB4zfagwCr/RNKmQ80XX2yutLd0E5zvkhsTt7FYzn1UabT8U3hNURZ92w3jgB3nljcT03CKgaxaeRnsP9Z3C6y26QrQH7A8CeImj7l7wr5mBK3jr4qxxW1tqi15v9ZLpM4XDYhAvSpbdMM59e7JBcUoOlLR1WjmiWk99kXtbSX2F+gxL3RyVor1O66cA/pur/o0o/e5meO8VvQ4pE+gaS5eJXo920PQVFlg/NvxA3wwg5tTQjfaTA7lV5IgLeU+eXE3sB5r1Yd2sza8q+lcAvsOpoRvurBKXnpsldG10jVJp1hvfMX2EDfbPx+nD83cDOMOtIw31GXnpuVlA10TXJpgz5V8s3s0tgt0gXpScc8NYVA52J630XNn52APRMr7sNNqvUN9g18EtAO1p338HcIxbRxr+VRfB3SH6iR59QdciPI32mAr097lFQIpBvChpiE7Plb8HX1+0njApd9uCC2m0ItbsiTAI2tO+PwfwBLeONLz3bULpg6KnQ3uCrsG7VPT09ROmL4hAjEHQnva9DcASt440Rj491xO/bcGS6QNiEGUQVdG/ccP4Pm4dabgzPtQnRGfadYW0OzNyl9BQ21Mf4NbRiSiDoD1g/zaAl7l1pOFfezGczXIX9aVBmoWn0b5s2l4U4gziRcmSG8Zf4taRRjs9V/RtyrqQZtIuFTeMb6O259axFpERU4H+TwDPcutIo3TFFnjvEp1YtArSSpoF86wK9I+5RayHSIOYbRS+CCC3J+YNheNAyV7DtAole9uCFZNGy61jXUQaBO0B+zEAj3LrSIM+lf2PiNo6cF1Io/A02kdNW4tErEHQnva9EwD7coM01I2ytyMjbUr2eOnc9OH5O7lFdENu67a/Rc64Yfw1bh1pOJs9qOvkLvgjbaRRKtS2XpSIXagK6QZBe8D+MICAW0capatn4M7IWzJOmkibYALTtqIRbxAvSmI3jG/m1pFGOz1X3m0MaSJtUqE2pbbl1rER4g2C9jqtgwAOcOtIo/TBza21WlLwLtnU0iSYA6ZNxTMSBkF7wH4LAJbE/V5o7QArIZry02iXudNo+0FCk/aEqugXAcjaGrkDd4eCfxX/PT9pIC2Ceci05UgwMgZBOz336wAKf3hYr7Q2u5zmmzWiukmDYE6bNhwZRsogXpTMu2Esdt7cmebdLpnqJg1SobajNuTW0Q9yo5mCCvQPABT6AON+8K+8CO5s8em5VCfVLZijpu1GipEziBclDT/QuwDI2g72Aq7DMkhuTxKIndZtUptJSaPth5EzCNoD9jkA+7h1pOG9t4zSh4pbPUt1eZeUC6tvAPaZNhs5RtIgaE/7fhlAIdtwDULrIQ9FpOd64h8oUTVtNZKMrEFURb/ihvG3uHWk4bSemJ7/Oi2qwxH8JHo3jO+ltuLWMSgjaxC0B+z3ATjJrSMN/9oZOFvyS8+lsqkOwZxUgb6fW8QwjLRBvCipuWEs6ikYnTg579o0JXy5vUmjrXHrGAa50e0RFeifADjErSON0uVb4L47+wE0lUllC+aQaZuRZuQNMgrpudOf2wlkOV53YMoUO60rOo22H0beIGgP2J8HsJdbRxruO6fgfyS7Z+FSWVSmYPaaNhl5xsIgaK/T+iqAN7h1pKFu2JHJY3eoDCpLMGdNW4wFY2MQL0pCN4zv4taRRjs9d/iOTWUIT6O9m9qCW0dWjI1B0B6wfxfAcW4dafhXbxsqPZfOpTIEc9y0wdgwVgbxoiQRvY3CkL96F/br/IC4r9Z3URtw68iSsTII2um5TwPYz60jDe8Dm+Fd2n86LJ1D5wpmf/lo9WluEVkzdgZBe53WrQDq3DrSaH0T9LPyVv4GPnUT87FjLA2iKvoEgD3cOtJwtyuoj/e+RISOpXMEs8fEfOwYS4OgPe17D4BT3DrS8D/d2yaadAwdK5hTJtZjydgaxIuSRTeM7+DWkYYz5WLq+o1vm+gYOlYqFGOKNbeOvJAb+QxQgf4hgCPcOtIofWwr3J3pD5am9+gYwRwxMR5bxtogXpQ0zTqtkUzPbb0nO432ixRjbiF5MtYGQXvATt8gj3PrSMN7zzRKl739W4L+Ru8J5nET27Fm7A2C9rQvjUXE3ie3dp7tfI5uSfxutIsmpmPPRBhEVfRrbhh/g1tHGs7WEtSn3pqpotf0N6lQLCmm3DqKYCIMgvaA/QEAYufq/Wtm4GzxW//otWBOmFhOBBNjEC9K6m4Y7+bWkUYrPfem2dY/4Wm0uymW3DqKQm5L5EB5buEpAM9w60ij9OEtrX+CecbEcGKYKIOgPWDfBWCsVpwWRGJiN1FMnEFURf8SwCPcOkaQR0zsJoqJMwja67TuAhBx6xghIhOziWMiDeJFyVk3jMcmbzpvKFYUM24dHEykQdCe9v0egBe4dYwAL5hYTSQTaxAvSlZEp+cKgWJEseLWwcXEGgTtad+fAXiSW4dgnjQxmlgm2iBoT/vuBqC5dQhEm9hMNBNvEFXRv3bDeGKWTvQKxYRiw62Dm4k3CNoD9m8CGNk9LHLgFROTiccapD1gr7phfDu3DilQLCgm3DokYA1iUIH+EYDnuHUI4DkTC4s1yFt0pOeO3E6sGdKYhDTafrAG6UBV9FEAj3HrYOQxEwOLwRpkDSaVdJ5bBwPzk5JG2w/WIGtQFX3aDeOxfRBaGnTNdO3cOqRhDbIOKtAPAniJW0eBvGSu2bIGa5B18KJk2Q3jsXwY83rQtdI1c+uQiDVICuW5hZ8COMitowAOmmu1rIM1SBf8QN8CIObWkSOxuUZLCtYgXVAV/atmvfEdbh15QddG18itQzLWIBtQ/sXi3QDOcOvIgTPm2ixdsAbZAC9Kzrlh/BVuHVlD10TXxq1DOtYgPaAC/X0Ax7h1ZMgxc02WDbAG6QEvShrjlJ5r0mgnec1Zz1iD9Eh5buHnAJ7g1pEBT5hrsfSANUgf+IG+DcASt44hWDLXYOkRa5A+UBX9GzeM7+PWMSikna6BW8coYQ3SJyrQ3wbwMreOAXjZaLf0gTVIn3hRsuSG8cjdppBm0s6tY9SwBhkAFegfA3iWW0cfPGs0W/rEGmQAvCiBSc8dhScOrpg0Wm4dI4k1yICoij4G4FFuHT3wqNFqGQBrkCGYPjx/JwDJyzXOGY2WAbEGGQIvSs64Yfw1bh1pkDbSyK1jlLEGGRIV6IcBBNw61iEw2ixDYA0yJF6UxG4Y38ytYy2kibRx6xh1rEEyoDy3cBDAAW4dHRwwmixDYg2SESZ1VcKDD5ZtGm12WINkhKroFwE8xK2DNBgtlgywBsmQ6cPzXwfA+fC100aDJSOsQTLEi5J5N4zZfnegukkDV/3jiDVIxqhA/wAAxwOgj5q6LRliDZIxXpQ0/EDvAlDkFgJNqtOm0WaPNUgOqIqeA7CvwCr3mTotGWMNkhN+oL8MoIhtzKqmLksOWIPkhKroV9wwvjfveqgOqivveiYVa5AcUYG+H8DJHKs4aeqw5IQ1SI54UVLLMz3XpNHW8irfYg2SOyrQPwFwKIeiD5myLTliDZIzOaXn2jTagrAGKQBV0c8D2JthkXtNmZacsQYpiOnD818FcDaDos6asiwFYA1SEF6UhG4YD70fB5VBZWWjyrIR1iAFogL9XQDHhyjiuCnDUhDWIAXiRUnivlofeBsFOpfKyFaVpRvWIAVTPlp9GsD+AU7db861FIg1CAN+oG8FUO/jlLo5x1Iw1iAMqIo+AWBPH6fsMedYCsYahInpw/P3ADjVw6GnzLEWBqxBmPCiZNEN4zs2Oo6OoWOLUWVZizUIIyrQPwRwpMshR8wxFiasQRjxoqRp1mmtl57bNOutikzdtazBGoQZVdH0DfL4Om89bt6zMGINIgA/0DQW6RxnLJq/WZixBhGAqujX3DD+xoX/02v6G68qC6xB5KAC/QCAE/TPvLYIoMQtwNLGi5K6G8a7L7zm1mNpYw0iiPLcwlPcGiyrsbdYFksXrEEsli5Yg1gsXbAGsVi6YA1isXTBGsRi6YI1iMXSBWsQi6UL1iAWSxesQSyWLliDWCxdsAaxWLpgDWKxdOH/AwAA///U5IIvGD6AmgAAAABJRU5ErkJggg=="},337:function(t,r,e){t.exports=e.p+"assets/img/teambit.16da1a29.png"},338:function(t,r,e){t.exports=e.p+"assets/img/backstage.f7efd23e.svg"},339:function(t,r,e){t.exports=e.p+"assets/img/rushstack.b8930568.svg"},340:function(t,r,e){t.exports=e.p+"assets/img/0x.18e8d4da.png"},341:function(t,r,e){t.exports=e.p+"assets/img/fast.77bdca24.svg"},342:function(t,r,e){t.exports=e.p+"assets/img/netlify-cms.f520efb0.png"},343:function(t,r,e){t.exports=e.p+"assets/img/ng-alain.d7712974.svg"},344:function(t,r,e){t.exports=e.p+"assets/img/vercel.d6747134.svg"},345:function(t,r,e){t.exports=e.p+"assets/img/aws-amplify.14a22de9.png"},346:function(t,r,e){t.exports=e.p+"assets/img/flipper.a1c1603d.png"},347:function(t,r,e){t.exports=e.p+"assets/img/nx.9e3ebc8d.svg"},348:function(t,r,e){t.exports=e.p+"assets/img/express-gateway.ac8face3.svg"},349:function(t,r){t.exports="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAMAAACahl6sAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAABAlBMVEUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABjSA+JZRl4WBb3ujb/wDjOmyvAkCiJZhmxhCS7jCb0uDWfdh/wtTTgqTDYoi6leyHtsjP4uzYyIwR4WRVHMwj7vTeYcR3przLPmytjSRCrgCLFlCmBYBdXPwy3iCXlrDHUny2RbBvKmCrcpS9uURL/wkv/3rT/0pD/0In/yW//4br+58z/zHn/26r////+5cf+8OH+/Pv/2KP+793/zoH++/f/xVn+8uX/3K/++fT+9/D/47//1p7/x2X+9On+69X+6dCedh7orzKleiBHMwqYcB68jCZg6ReDAAAADnRSTlMAZ55fln9H9ne+tgfODzHZkZIAAAABYktHRD3QbVFZAAAACXBIWXMAAA7DAAAOwwHHb6hkAAAAB3RJTUUH5AoEFwslNUrEuwAABu9JREFUeNrt3Wdj2kYYAGDXrdOmQx0XiRMSAoRAYthgsKmb2CZO2rgh3eP//5VqAZroJN3Qufd+SSyDwxPd0L03fHIiQoQIESJEiBARxkcStjhl6fhYkp6ExHV8/Q2mYClxHd9+BzDFC3YSrA6GEswOZhLsDkYSAg4mEiIOBhJCDuoSYg7KEoIOqhKiDooSwg5qEnSHrLjRgur+a+hdaDdEUvJ+aLrcCv/aMfRuc+5J+XLV64e3xNQbVLqq1A8luCWdgVWynnzSsHouB7fEHJau8WfNaq9GkndLOpINmiKp2u463i0xJQ00RFK5/xhLhj6RzEr9yVmT+sGxn1qY9pohqezQpmGSZKY3QVLZ0TP36Z7BiL2kerlqRxJXjsVaUt2hxVJwNmArqfG8ex6DTAFTSZ3n9mEMMgAsJbXGH2Y8vdtjKKk3jlJijr4FmElqjgfr1xFMkrrj2k4M0gKsJLXH5+MYRLEYSWo7Rom5nAlgInlWO18yTEBmFgvJs0/rOS7kaWp6bdC2NdqSOg5Lh0ruXOGsPRlRlFR2qPOWWTjx2V9ASk/11RzdS8NBn8adni8t0pIKju5kOCs/J222OhZBSVmHahuz6hPsC3lESFLOMUKoE0UxMzoEJGUcmrzCtPBhNh5hlqA7LFvBuYZDWskqRgmyQ4UDCXf0WyouCbJDxs/w+34ZjwTVoU2R2qPE1wZSi6xhkKA6RkitrW0tIg3aagGtCVK179aWoDpUJAcMUnS6H+E7IVKlt2pKkOuHge5IBpJkUq+eoLe7DqLj6nq9/j58z836h5ev3D9thPcOa7XCJfpBhJJ16b3u9i4e995Fu1/4ZgOxZ/wsE3KK3p8X9oP9uf+6TQLy+sq7uuwj/S8gSJ7nQF5US45kdAZB3X51l4yHoM0r6IIQR8QYIOB4L+KET023KcibsBc6/oA2B9Qg6rHqHpmcent7v9n4BezHzebl9fpqN22yOPJ+1PQXDghQ8z/JGKlgtHKLJfLkAxaI2/hkF3Tn8DmWbVmPp621TuS72cXTQE90Y4IAdZK6K05LTyZ+HUVpQz8UxaWvoqzLYaL9msrdEh8AF8Qr6nM4VLzqMlAUAy4TnyKz9CXKnaZDw1s0pIwh1NVy/zpGSIVuc4Tv59OC9DLrQIc/CLCWybTEyrhUOYSED/ETeB7U946K92dThZAMWpCf3t0/3CSuvX1cc3hHfnafTN5v7rdbd1Syfthut5vXd3fXHELe3GXEBw4h91mQGw4hjxmO9zy2Wr98uP814Xh3zSPEb7rWj9vtb+6Y5Hevzot+hDXkovdEIBPJWbjPJn6qEbrP6xNui9awbN6tqZBe9PHX7HFc2a3D6sx2D3DdasHaC2qa0vzq3th9cQG4hzyF5ldABERABERABARrJx9dO8ALJFhU4KipS2hzts2BZExsKseWRDQdYgtIUyD9XMiYL4iThhjoK00ERED+NxD5qUAg95BVLmTBF0TJhSjcQ6CACIiApCAG95BFLmTF41A3C+JwD5GfCsQWEAERkEOM051GCOnzBYG5EElAmgKZcwmx05U92HUy4GyoG8whEFgnQB1CPAREQKhD/uDK8Wce5EyS/uLJ8XfuUbqnPEk8x+dfnHAvOergSFLg4EZS6OBEguDgQoLk4ECC6Gi8BNlRQjJfeLtsYbj9Vm35J/Uvw2922kqwZmA6tIM12Lb/8ki0rMxruBzoklVsJcMiOrGmx3buD/wFQel943rmNWwOZIkT3Ui8OwfCH9t2k+dTyGC/OiX2oaVykJIOVIkT3U5hRiGpMx28I9frQ0o7ECVOZEv0/lQgD6Jm7pquDangQJPsISawZlHIMv355Izb5JbJVYkN75UcSJJDhYaH01eVQwbFO5Zpd8oFDI9DCg/ONb2/d7Ov4XWgSDLPFIlAziNpIRjPEikZmSMFAADwOxAkRRCIEVLDUSyhCKnlKJQEkEHYZ8wIQmo6iiROeBhKuImKHKS2o0ASQtR+cAYeMQgGx3FJCAnOAeoQg2BxHJXsINZYUSaAFAST45jEiU0JamT6EWyOI5JcSDijM9MOJ2lVhWB05EtyIaP8Y+VKQjzHc1yOXEkupJc+Lm9ZCeI5vvwK46+EyZbkQnarTiKnmoIqEOyOHEk+xEqcrTnVqkAIOLIl09jvsAjL03CXmDgUr2lkD084VIn9NsGsa6QcmRLVn+/cbz7q+l8edq2fZ54qd5F4Vd41Uo4K+S671r4XYo7ykjCVYjfNQTUHSdRBUULYQU1C3EFJQsFBRULFQUFCyUFcQs1BWELRQVRC1UFQQtlBTELdQUjCwEFEwsRBQMLIgV3CzIFZwtDhS/75F1OwdPgSfMHQgVXC1CFChAgRIkSIaFb8Bx0j9q/4+aUGAAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDIwLTEwLTA0VDIzOjExOjI2KzAwOjAw7tc/6QAAACV0RVh0ZGF0ZTptb2RpZnkAMjAyMC0xMC0wNFQyMzoxMToyNiswMDowMJ+Kh1UAAAAASUVORK5CYII="},350:function(t,r){t.exports="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKAAAAA0CAAAAAAoU2ykAAAABGdBTUEAALGPC/xhBQAAANJpQ0NQSUNDIFByb2ZpbGUAABiVY2BgrEgsKMhhEmBgyM0rKXIPcoyMiIxSYL/KwM7AyAAGicnFBY4BAT4MOMG3axC1l3VBZuFWhxWwpKQWJwPpLUBcmlxQVMLAwKgDZKuXlxSA2CFAtkh2SJAzkJ0BZPNB1YOAtHNiTmZSUWJJaoqCe1FipYJzfk5+UXFBYnIqia4gApSkVpSAaOf8gsqizPSMEgVHoG9TgXbmFpSWpBbpKHjmJesxMIDCD6LjcyA4XBjFziSXFpVBjWFkMmZgAAARXTTFHXnTkQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAACXBIWXMAAAsTAAALEwEAmpwYAAAKqWlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNS40LjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczpleGlmPSJodHRwOi8vbnMuYWRvYmUuY29tL2V4aWYvMS4wLyIKICAgICAgICAgICAgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIgogICAgICAgICAgICB4bWxuczp0aWZmPSJodHRwOi8vbnMuYWRvYmUuY29tL3RpZmYvMS4wLyIKICAgICAgICAgICAgeG1sbnM6ZXhpZkVYPSJodHRwOi8vY2lwYS5qcC9leGlmLzEuMC8iCiAgICAgICAgICAgIHhtbG5zOnBob3Rvc2hvcD0iaHR0cDovL25zLmFkb2JlLmNvbS9waG90b3Nob3AvMS4wLyI+CiAgICAgICAgIDxleGlmOlNodXR0ZXJTcGVlZFZhbHVlPjU2NC8xMDA8L2V4aWY6U2h1dHRlclNwZWVkVmFsdWU+CiAgICAgICAgIDxleGlmOlNjZW5lQ2FwdHVyZVR5cGU+MDwvZXhpZjpTY2VuZUNhcHR1cmVUeXBlPgogICAgICAgICA8ZXhpZjpFeHBvc3VyZU1vZGU+MDwvZXhpZjpFeHBvc3VyZU1vZGU+CiAgICAgICAgIDxleGlmOkZOdW1iZXI+MjQvMTA8L2V4aWY6Rk51bWJlcj4KICAgICAgICAgPGV4aWY6UGl4ZWxYRGltZW5zaW9uPjE5MjA8L2V4aWY6UGl4ZWxYRGltZW5zaW9uPgogICAgICAgICA8ZXhpZjpFeGlmVmVyc2lvbj4wMjIwPC9leGlmOkV4aWZWZXJzaW9uPgogICAgICAgICA8ZXhpZjpFeHBvc3VyZVRpbWU+MTAvNTAwPC9leGlmOkV4cG9zdXJlVGltZT4KICAgICAgICAgPGV4aWY6UGl4ZWxZRGltZW5zaW9uPjEwODA8L2V4aWY6UGl4ZWxZRGltZW5zaW9uPgogICAgICAgICA8ZXhpZjpDdXN0b21SZW5kZXJlZD4wPC9leGlmOkN1c3RvbVJlbmRlcmVkPgogICAgICAgICA8ZXhpZjpTdWJqZWN0RGlzdFJhbmdlPjA8L2V4aWY6U3ViamVjdERpc3RSYW5nZT4KICAgICAgICAgPGV4aWY6RXhwb3N1cmVCaWFzVmFsdWU+MC8zPC9leGlmOkV4cG9zdXJlQmlhc1ZhbHVlPgogICAgICAgICA8ZXhpZjpEaWdpdGFsWm9vbVJhdGlvPjEwMC8xMDA8L2V4aWY6RGlnaXRhbFpvb21SYXRpbz4KICAgICAgICAgPGV4aWY6SVNPU3BlZWRSYXRpbmdzPgogICAgICAgICAgICA8cmRmOlNlcT4KICAgICAgICAgICAgICAgPHJkZjpsaT41MDwvcmRmOmxpPgogICAgICAgICAgICA8L3JkZjpTZXE+CiAgICAgICAgIDwvZXhpZjpJU09TcGVlZFJhdGluZ3M+CiAgICAgICAgIDxleGlmOkZsYXNoIHJkZjpwYXJzZVR5cGU9IlJlc291cmNlIj4KICAgICAgICAgICAgPGV4aWY6RnVuY3Rpb24+RmFsc2U8L2V4aWY6RnVuY3Rpb24+CiAgICAgICAgICAgIDxleGlmOkZpcmVkPkZhbHNlPC9leGlmOkZpcmVkPgogICAgICAgICAgICA8ZXhpZjpSZXR1cm4+MDwvZXhpZjpSZXR1cm4+CiAgICAgICAgICAgIDxleGlmOk1vZGU+MzwvZXhpZjpNb2RlPgogICAgICAgICAgICA8ZXhpZjpSZWRFeWVNb2RlPkZhbHNlPC9leGlmOlJlZEV5ZU1vZGU+CiAgICAgICAgIDwvZXhpZjpGbGFzaD4KICAgICAgICAgPGV4aWY6Q29sb3JTcGFjZT4xPC9leGlmOkNvbG9yU3BhY2U+CiAgICAgICAgIDxleGlmOk1ldGVyaW5nTW9kZT4yPC9leGlmOk1ldGVyaW5nTW9kZT4KICAgICAgICAgPGV4aWY6Q29tcG9uZW50c0NvbmZpZ3VyYXRpb24+CiAgICAgICAgICAgIDxyZGY6U2VxPgogICAgICAgICAgICAgICA8cmRmOmxpPjE8L3JkZjpsaT4KICAgICAgICAgICAgICAgPHJkZjpsaT4yPC9yZGY6bGk+CiAgICAgICAgICAgICAgIDxyZGY6bGk+MzwvcmRmOmxpPgogICAgICAgICAgICAgICA8cmRmOmxpPjA8L3JkZjpsaT4KICAgICAgICAgICAgPC9yZGY6U2VxPgogICAgICAgICA8L2V4aWY6Q29tcG9uZW50c0NvbmZpZ3VyYXRpb24+CiAgICAgICAgIDxleGlmOldoaXRlQmFsYW5jZT4wPC9leGlmOldoaXRlQmFsYW5jZT4KICAgICAgICAgPGV4aWY6TGlnaHRTb3VyY2U+MDwvZXhpZjpMaWdodFNvdXJjZT4KICAgICAgICAgPGV4aWY6Rmxhc2hQaXhWZXJzaW9uPjAxMDA8L2V4aWY6Rmxhc2hQaXhWZXJzaW9uPgogICAgICAgICA8ZXhpZjpGb2NhbExlbmd0aD40MTAvMTAwPC9leGlmOkZvY2FsTGVuZ3RoPgogICAgICAgICA8eG1wOk1vZGlmeURhdGU+MjAxNi0xMS0yMFQyMDoyNjo1NDwveG1wOk1vZGlmeURhdGU+CiAgICAgICAgIDx4bXA6Q3JlYXRlRGF0ZT4yMDE2LTExLTIwVDIwOjI2OjU0PC94bXA6Q3JlYXRlRGF0ZT4KICAgICAgICAgPHhtcDpDcmVhdG9yVG9vbD4xMC43LkEuMC4yMjhfM19mNjAwPC94bXA6Q3JlYXRvclRvb2w+CiAgICAgICAgIDx0aWZmOk1ha2U+U29ueTwvdGlmZjpNYWtlPgogICAgICAgICA8dGlmZjpNb2RlbD5DNjYwMzwvdGlmZjpNb2RlbD4KICAgICAgICAgPHRpZmY6UmVzb2x1dGlvblVuaXQ+MjwvdGlmZjpSZXNvbHV0aW9uVW5pdD4KICAgICAgICAgPHRpZmY6T3JpZW50YXRpb24+MTwvdGlmZjpPcmllbnRhdGlvbj4KICAgICAgICAgPGV4aWZFWDpQaG90b2dyYXBoaWNTZW5zaXRpdml0eT41MDwvZXhpZkVYOlBob3RvZ3JhcGhpY1NlbnNpdGl2aXR5PgogICAgICAgICA8cGhvdG9zaG9wOkRhdGVDcmVhdGVkPjIwMTYtMTEtMjBUMjA6MjY6NTQ8L3Bob3Rvc2hvcDpEYXRlQ3JlYXRlZD4KICAgICAgPC9yZGY6RGVzY3JpcHRpb24+CiAgIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+CpOF2G4AAAnnSURBVGjezZlrcJTVGcf/M53WmY4f2s7YGa1otVovINQZREtRnFERCtpCRRQV8FKgoKIioAaQSyBAIAiSQAKBJBggCeF+CSQhBMgdEAIJCYSYK5vLJtnsbvaW9zz/ftjN7ia7ucF+4P2QSTLve97f+z/P+T/PeQ4Y2EuUkKRQAjQgnMMFik6RrEmMNlK0QAIG8LLkrfkdUEnFuxBQi9ibPhN4ctDQ9cvnFdyNCibA6zrLjmiUuwRQKPMxckdC+sUr19cDHzs6/n/3ACYB+c7fq4AQucumWFhzP3ZRKaUUW0ZjS2DMIXCAikcwyUQhKdQNQ3JgVnIgFdyNH518irFAaYAVVHcOuB2bqUQUmfsIIhiwGBQRqvYAKBiHj9tIUh17CO8aGcBFoigqADF4HljcaG78+TvgfV2gcgmoahqp1B37lShp/wIYNXUMgGWtgeATJSRY9IeXztNhu8OaQUiy/C0AGLn8tI2adLluA4+kECwBnjllJ9WdKCi0F1620V6asv9ia0C0E9KY10qB8PxbwMIi3lEcCncB85MPHdufuP2nndGxW7dEREZv+CEmNmJj0q7wjSfrWvpdUjbmf44vTARJU/LDwIpCUtNum+8G/vQMerj6attOOmtZyvoxwLMoJkhFVm4CsCHPQE1uE3AthuClj79eFLwsKGRtSFTUpnUhS+ZO/2j8Yy7A4TrfEFciSinltE4PXeuVXTMA4O9jsUUjXMu3bAWAKTduj1DY9Nq9WFtvtrYrzaGcKEqzmk2GylO5BeGhU+9HalcJpUsl5FxIhoLN7wMYujTpUp2+vMbmyiQi1I7gT3ij2hWf/bXAdGCz+LzNfVUOwve+fJXJ2zMzzmVmpMXkOOlrc8MnApiwMUvnDLZmszvVKTJzADAi5zb8UGiahvftPj7gsRg1FyOaOmkmrFryqHd1a69KDR0OYGJUXov7Ye9cLML64mDgh8p+52XFWOBCD0+JBOMfXQGDPHj34rnY7x4F8PYPBQYnnFtmdBJdSxuOx45rVNIvvkvA1p5tPhivtHjfIbwJvJB86mxm1umcrH8CAN6LKGj2pvMtt0SRdeuB4Fr2A1HY9HJvtYEKwhud7lCMx4CLHX8lYRDWFRo8HthtPSiKkj0Rzx2yOINAuX90n62Ea4HCnsNCfYOXm70AhbZZ2EYlIko5eBzYRlJ/1dB7wapIw3Zg9pEqf6Hkd4LPAvG9hK36FkPqOgFW3IPzVC7LmA+Ums9sH49P6qT3ilqRBW8CT6flH45JPpmffaaotrm2yWw0WvyVE8K64fja3kuhIcswtMHrHsUzeKrW+VU2fcEDDzw+818ABuECpfeSXzSewrO/8iyyoeOfnzL9o2kzk/wEmkgInq/tRUBhGF70WsUiKgSLhWzIP7p13kjnW55f8xaWtvcJkJUT8QTw6iefTx0/ZeyDHtKVylfuTOBQr76kzcPQBi9fpOl1JKriyBEAgLFTZsefLarXv4Jq9mGKhdqXGIxFl+tN1lZ9k+6Xwrzso9u3hk7AIJzvgiI0jMMsW28TTOM4DKrzPGs33xyHGXMBTAw7cK5cb7SS5AmE+BnIH+BRPItoW9f/G/cB67qsE8U4oKhnAUUUW0fjA410GBuuX0zdHTb/3V8DwJPL8g2eIsY2Czl+RoLvpN3A01hHdriLs94QoX4IVrd3ufc6sKNTM1A8T4lSHd5UBnxUkhm38INhzlh5avR7ocezKxXpsjEqXsH0tr4oqLgbmGb2+RbFEiCmS7pyzMFUM4Wa0zD9ubtmbynO+gp/vQ8AMOzD2SGJaVd1jSaXb4mXm2b4mwo/NrMASKfmC54CHHDrKiKiMR3I6nSrsrXWVlSUFJ5PO3E07WRq4qa1wQsmOFX774YD567XmWzuNCuK7SYXobAaYw3+Yhk+Edg47EHs9500xR996uK6EVhMKrvN1masv3bu5N4tq+ZPGuBTTU9Y/lPc5GN2L6PVqNhsY/nyYteLFBOwx+9aQ+ciThQvYzB20DVnXjwyG8igZreYDC31VddLSi5dWwqs2rdj9bfz5s+a9EgHzsAX35w6Y8W2LcGrVodtTj6ccrGsmaTDuVpIXQ2ry3j6+/3RpXxnplvOljGo6RnQrXUZBiLeK4SMtTcL885mnNr78CP3LYoIDZo9+fVRf/PddAx/e2F4bNyhU1eqdPo2q3TKjEJaSQotDeb16UzJqTl2wxBdWotrrhlRTEOI/2SPjiFyv0291Wix2h1tC4BI3Y2y0qsXslJ/Cgl65zddWYa+MHDU62++PXnajIUbwrZE7jqcfu7KtVsGv4n6WAFvZlKXtHGX1RG5dfPKdeMSmXrzkJXcVBQ5x62ZWoI8/27lKvnZ8Fvg96/O/Cwo6Kuxf3zsCW+ee16Z/MX3ISFLwyJ3JSZk5F4t19VVN9Q3GU0WW6dvbmmjslgdGluzY5N+tpt37oszMbSAB49yerZKi7+593IFL4ZGG1dtbaTG9M9GVbqn7ReMM7AHBRWvYbA31Atjxo37z+ygiD37TpeW15sd0m2xShGHTTRe37xsSRtTo1YW8Wxm44VPy0uSrhTarYNzGWZoX9FOLeTrDfGJjrSknMUPHaHDojjncIdmikmI7SYddQAWA3GF5/bF7Inbve9Qbnmtvqmp1a58txgu2+6IUOoN1PY2U3HjMcZkc++tGybG1NC8xrw8PyeXJS9dKE2mbhtZuP6IvSHPEpnA/SVR4RE/OloWe1KkbSZKuslHHYAH8J3fNCVKKZ/8RlVWlJ95tT6Dxem3Iu1LrKS2opGHC/JHbzNR92lN+byKyqATWRbuPb1pkYEnt8mFhKwFUXuy7XEFJO362hYmpHgELMb/bD03MGUZjrDdmdPElduk+z6RdU/syTEnsrdWLLZVYcNcO2ldbWsPrwrVW0jda1FJldyZ0laSZU4wFt4gz3y5O0dsxXqS1o5jibY57k2KYhwOdpfQXUdhdUNQ3I/uliJ3pjB12nMJzPlmw1IRtq7n4TOXkuwtN9vrlmsk84LDD5y2aEIqtujcvYSOb7S0XFPuDzZPQHl3b3c1MLMx1dqvXtvOg+SOWdcHVKeGpMRT4/HpJ/fxzJdrVsa0V2dTU179DVdf3XsfJmy2eKXheHxi77HDKozGpj4LKGRVFI4cNIadZ8aeyuqiQirqjx61UrN4zjqFdOchf9EiHgH1AzGyqUcFaZ+NtL5v19v3jFhxPOuiudbq3uOLN4f06zBWWAZMMvcEKKx9HFf7DuioavXO4C5BXDPolb6lj4CJ8FuqegAVz+IvFf3qAIuriPWzfsST1/s2Ytu/MUDX7dudi2QpujVK/1W8k0EpPweK3vHVB0bF2j/jXXNPgMIKPOXbv+tL19zfiSeV23PFrrTexzF/iJLup+//6sDcAeFKPOMAAAAASUVORK5CYII="},351:function(t,r,e){t.exports=e.p+"assets/img/theia.adcefcea.svg"},352:function(t,r,e){t.exports=e.p+"assets/img/tsdoc.afd1c711.svg"},353:function(t,r){t.exports="data:image/jpeg;base64,/9j/2wCEAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDIBCQkJDAsMGA0NGDIhHCEyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMv/AABEIAMgAyAMBIgACEQEDEQH/xAGiAAABBQEBAQEBAQAAAAAAAAAAAQIDBAUGBwgJCgsQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29/j5+gEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoLEQACAQIEBAMEBwUEBAABAncAAQIDEQQFITEGEkFRB2FxEyIygQgUQpGhscEJIzNS8BVictEKFiQ04SXxFxgZGiYnKCkqNTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqCg4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2dri4+Tl5ufo6ery8/T19vf4+fr/2gAMAwEAAhEDEQA/APf6KKKACiiigAoooPTigApCcVl6z4h0zQIPN1G6SLIJVOrv9AOTXl+vfFe/vCYtHh+xxf8APV8NIf6D9frXZhsBXxHwLTuTKaieuXuoWem2/wBovbmK2hzjfK4UZ9Oe9clqfxR8PWJ227z3r/8ATBMKPqWx+ma8Rury6vpjLd3M08nd5XLH8zWlp3hXXtVRZLPS7iSNvuuVCKR7FsA17MMmoUlzV53/AARi6snsjt734xXDAiw0mOM9mnlLj/vkAfzrIk+K/iRzlRZxj0WEn+ZNW7T4Q6xKoa5vbS3yPujc7D68AfrWrB8G4VINzrTsPSO3C/qWNVzZVT00f3sdqjOa/wCFo+J8/wDHxb/9+BUifFXxIhBY2j+zQ/4EV13/AAp/R8f8hC9/Nf8ACqtx8G7Zjm21iWMeksAf+RFH1nK5aWX/AICw5ahn2XxivU4v9Kgl94JDH+h3V0umfFXw/eNsuhcWTf3pU3L+a5P5iuVufg/qqAm21G0lI7OrJn+dctqHgvxFpis9xpc/lqMl4x5igeuVJo+q5ZiHaDSfq/yYuapHc+gNP1bT9ViMlheQ3Kjr5bg4+o7VczXy1DPNbSCSCWSKQdGjYqR+Irt9B+KWr6c6x6kBf2wGMnCyD33d/wAR+NcuIyOpFXpO/wCBSqrqe30Vh6D4s0nxHEDY3I87bua3k+WRPqO/1GRW5Xizpypy5ZqzNk77BRRRUAFFFFABRRRQAUUUUAFFFRTzxW0LzTSLHGilmZjgADvQld2QEjMEUsxwAMkmvMvFXxThtzJaaCBLMDta7dcov+6P4vqePrXPeN/iBPrryWGmu8OmDhj0af69wvt+foOb0Dw3qPiS9+z2MQIXmSV+EjHqT/TrX0WDyyFOPtsVp5dvUwnUu7RKFxcXmp3hlnklubmU9WJZmJ7V2ugfCzVdS8ufUpFsbdgG2H5pSPp0X8efavR/DHgnTPDcYeOMXF53uZF+Yeyj+EfTn3NdNioxOcte5hlZd/8AIcaXWRzujeCdB0MbraySSb/ntP8AO/4Z4H4AV0IGBilorxKlWdR3m7s1SSCiiisxhRRRQAUEZFFFAGHrHhLRdcQi9sYjJnImjGxx+I6/Q15xr3wmvbXfNo04uohyIZDtkA9j0b9K9joIB612YbH18P8AA9Oz2IlCMj5cK3WnXmCJra5iPujof5ivSfC3xUaFVtPEAZ1GAt0i5IH+2O/1HPsa73xH4U0vxLb7LyHEyriO4Th0/HuPY14l4n8I6j4YugJ0Mtq5PlXKKdrfX+6fY/hmvep4jC5jHkqK0v62MnGUNUfQ0U8U8SyxOskbjKshyCPY1JXgPg7xvd+GZ1gmLz6ax+eHPMfqye/t0Pt1r3Wwv7bUrOK7tJllglXcrqf8814eNwNTCy97VPZmsZqRZooorhLCiiigAooozQAjMEUsxAA6k14j8QfGza7dPpthJjTYm+Zgf9ew7/QHp69fTHRfFPxUba2Gg2kpE0oDXRX+FOy59+p9vrXnHhvQbnxHq8VhbDAI3SSHpGncn8x9TX0WV4OFOH1qt8r/AJ/5GFSbvyos+FfCt74o1HyYQY7aPmecjhB6D1b0Fe+6VpNnothHZWMKxQp2HUnuSe5o0jSrTRdOisbKLy4YxgZ6se5J7k1erzsfmEsVKy0itl/maQgohRRRXnFhRRRQAUUUUAFFFFABRRRQAUUUUAFV72xt9Rs5LW7hSaCQYZHGQasUU02ndAeA+M/Bdx4Xu/Mi3TadIcRynqp/ut7+nrSeCvGM3hm/EUzNJp0zfvY+uw/31Hr6+oFe8Xlnb39pLa3USywSqUdG6EV8/wDjDwrceGNWMQDPZzEtby46jP3T7jj9D3r6fA4uGNpvD19/z/4Jzzi4ao+goJ4ri3jmhdXikUMjKeCDyDUtePfC3xV9muhoN3IogmJa3Zj0c4+X6H+f1r2GvBxeFlhqrpv5eZtGXMrhRRRXKUFZXiHWYdA0W41GYA+UvyKTjex6D8TWoeBXjfxY177ZqsWjxH91aDfKc/edhwPwB/U12YHDfWayh06kzlyq5wdxcXOp6hJPKWlubiQse5LE9BXvXgnwunhrQ0jdf9MmAe4bP8XZR7D+efWvOPhboP8AaWvPqM0Ya3sgCu4ZBlP3fy6+3Fe2jpXp5zitVhobLf8ARGdKP2mLRRRXgGwUUUUAFFFFABRRRQAUU15EjUs7qqjqScCqj6zpcZxJqVmp9GnUf1pqLlshXLtFZw8QaKxwur2BPoLlP8auQ3MFwu6GaOVfVGDD9KbhJbodyWijNQ3V3BZ27z3E0cUSDLO7AAfiaSV3ZATVn6rrWn6NaG51C6jgi6AseWOM4A6muA8Q/FmCKN4NCiMsucfaZlwg9wvU/jj8a5Dw9pmo+PPFAfULiaaKM+bcSt0C5HyjsM9AB05PavUoZXLkdWu+WK+8ydTWyPbdF1CTV9MjvntXtkmy0SSH5inYnHTPXHuKr+JvD9v4j0WaxmChz80UhGfLfsf6H2Na6KqIFVQqjgADAFO615yqOM+eGhpa6sz5euILjTb+SCUNFcW8hU84Ksp7V7/4L8QjxH4fhuXK/ao/3dwAMYcd8eh6/wD6q4f4teHzHcQ67CBsfbBOAOd2Dtb8hj8BWD8NvEB0bxIttNIVtb7ETjsH/gP58fjX0uKjHHYNVo7rX/NGEfclZnvFFA6UV8sdBW1C8i07T7i9nJEUEbSPjrgDPFfMt7cyXt9cXcpzJPI0jfVjn+te3fFDUzY+D5IF+/eSrD16D7xP6Y/GvIvC2nLq3inTrKRd8ckwMi+qD5mH5Cvpcmpxp0Z15f0kYVXdpHuHgjRv7D8K2du3+ukXz5TjHzNg4/AYH4V0VAGOlFfPVajqTc5bs2SsrBRRRWYwooooAKKKr3t5DYWM93cOFhhjLufYCmk27IClrniLTvDtn9p1CbaDwkajLufQCvJdb+Kes37lNOC2EGeCvzSMPcngfgPxrltd1y78QarLf3bcscIg6Rr2UVm19Zg8ppUoqVRc0vyOaVRvYtXupX2pSeZfXk9y46NLIWI+maq9aKK9dJJWRncP0qa1u7mynWe1nkhlU5DxuVI/EVDRSaTVmB638OvGOtazqX9l3oS5jSNpWuGO10AwAOOG5IHY+5rnPihq93deKZ9NeRhaWoTbHngsVBLEevOPpVb4b61Do3ilRcsEhu4zAXY4CEkFSfxGPxrufHHw/fxFdrqemzIl2wCyJKcK4HQg44Pb0IrwpKjhcfzTVotaepsryhoeMAM7BVUljwAO9fQngjw6vh3w/FC6Yu5v3lwc5+Y9vwHH5+tcp4S+GM+nanHqGsyQP5LbooIyWBbszHjp6c16hiuXNsfGtalSd118x04NasKKKK8M2M3X9Jj1vQ7vT5QCJoyFz/C/VT+Bwa+a2WW2nKsGimjbBB4KsOo+tfU1eAfEXTW03xneHGI7rFwnvu6/+PBq9/I675pUns9TGqup7V4c1U6z4dsdQON80QL46bhw36g1q5rzj4Q3zTaLfWTMT9nmDqCegcf4qfzr0avJxlH2NeUPM1hrG55N8Yr0NcaXYg/MqPMw9iQF/k1UfhFarL4ju7lgD5FsQuR0ZiOfyBFVvixKX8Yqv/PO1Rf1Y/1re+DUJEerzkcExIPw3E/zFe6/3eU+q/NmH/Lw9Tooor5k6AooooAKKKKACvPPi5qf2bQLbT1Pz3c24/7iYJ/UrXodePfGKQnWNNizwtuzY+rf/Wr0MrpqeLhfp/kRUdonm1FFFfaHKFFFFABRRRQAVuab4x8QaRb/AGey1SZIegRwsgX6bgcfhWHRUzpwmrTVwTsepfDXxfeXesz6bqdxJcPdZkikkbO1gOV+hAz+HvXrFfL1hePp+oW95ESJIJVkXHqDmvpy3mS5t454m3RyIHU+oIyK+WznDxpVVUirKX6HRSldWZLRRRXjGoV5R8Y7Mh9KvQMjEkTH8iP/AGavV64P4tQh/B8T4H7u7Rv/AB1h/Wu7LZ8uKh56feRU+FnG/CW6aHxbJDk7ZrZgR7ggg/ofzr27NfP/AMN5PK8eacM8N5in/v22P1r3/iuvOotYm66pfqTSfunhfxU/5HaT/rhH/Kuv+DwH9gX5xz9q5PtsFcn8V4ynjPcej20bD8yP6V0Pwbnzb6vAeivE4/EMD/IV3YjXKo27L8yV/EPUD0ryvxL8S9Z0bxFe6db21g8MD7VaSNyxGAecOPWvVTXiXxU0R7LxGNSRWMF6oJbHCyKMEfiAD+deXlVOjVr8lVXutPU0qNpXResPjDfLLjUdMt5I/W3ZkI/76LZ/SvRNF8V6TrunveW1yqJEMzLMQjRe7c8D36V84VJHPNEkiRyuiyrtkCsQHGc4PryAfwr26+TYeovcXKzFVZLc9d1j4uWVu7RaVZSXTDgSynYn1A6n9K57/hb2v5/489Mx/wBc5P8A4uvP6lt4Jbu5it4VLyyuERfUngVrDKsJCNnG/mxOcmz6S8PahNqvh+xv7hUWW4hV2VAQoJ9Mkn9a8t+MP/IxWH/Xp/7O1esaTYppek2lgrbhbxLHu9cDGfxrx34sXsdz4tjgjO429sqP7MSW/kRXiZUk8beK01NanwHCUUUV9Yc4UUUUAFFFFABRRRQAV9HeD3L+D9ILdfssY/IYr5xr6U8MQNbeGNKhcYdbSIMPQ7RXg5817OC8zWjuzWooor5k6Arivip/yJMn/XeP+ddrXC/FmXy/Byr/AM9LpF/Rj/SuvAf7zD1Jn8LPMPAxYeNtJKnnzucfQ/0zX0RXz/8ADmPzPHmmjBwpkY/hG3/1q+gM/WvSzpr6wvT9WZU1oeSfGKyC32mX4zmSN4W/4CQR/wChGq3wfuRHr99bFgPNttwHqVYf/FV1nxT0w3vhL7Sv3rOZZT7qflP8wfwrynwfqC6Z4u026kcLGJgjsegVsqT+tdWFXt8tdNbq6+7VCl7s7n0fVHVtJtNa0+WyvYvMhkHTOCD2IPYir2c0V81GTi7rc6NzxXWPhRq9rOx0t47yD+EMwjcexB4/WuT1nw5qvh8wjVLQ2/nZ8v51fdjGfuk+or6Wrj/iJ4ck8QaBm2Utd2jGWNQMlxj5lH+e1e7g84qupGFW1npfqYSpK10eR6N4O1rXrcT6fbxSRZKljOg2n3Gcj8q9Q8FfD1PDsw1G/kjnvwCEVOUizxkE9TjjPua8Vjllt5d0cjxSDupIIq//AMJJroj8sazqGz0Fy+P516mMw+JrpwhNKL8tfzZEZRXQ938T+KrDwxYNLO6vcsCIbdT8zntx2X1NfPt/ez6lfz3t0++edy7t7n09qhkkeV2eR2d25LMckmm1WBwEMKnrdvdinNyCiiiu8kKKKKACiiigAooooAu6PYvqesWdjGpZp5lQgehPJ/AZNfTgAUAAYA7V5T8KPDbh5NeuUZRgx22R97+8w/l+der18nnOIVSsoR+z+bOilGyuFFFFeOahXlfxjvGCaXYhvlJeZl+mAp/Vq9UrwT4lamdQ8ZXEYI8u0VYEx7cn9SR+Fepk9L2mJT7K5nVdolv4T25m8YNLjiG2difqVH9a9wrzP4P2Pl6XqF8V/wBdKsSk+ijJx/31+lel/hSzaoqmKfloFOPulTVbCPVNLubCUkJcRtGSOoyOv4V8y3ED2tzLbyDEkTmNx6EHBH55r6lIyK8T+KegNp+vLqcSAW1797HaQDnP14P5105JiOSo6T+1t6oVVaXPUPCGsDXPDNneZPmbPLlB/vrwT+PX6EVu1418KNdNpq02kTSYiuhviBPAkHX8x/IV7IOlcGYYf6vXlBbbr0KhK6FoooriLPPPGXw3h1d5NQ0nZBetlniPCSn29GP615Ff6de6Xcm2vrWW3mHO2QYyPUeo96+oKqahpdjqtuYL60iuIj2kUHHuPQ+4r2MHm9SiuSouaP4mU6aeqPmCivZtU+Eek3ILaddT2b9lb94n5HB/WuauvhFrceTb3dlMPdmUn8MY/Wvcp5rhZ/at6mTpyR59RXVz/DfxTACf7NEgHeOZD+mc1mS+E/EMJw+iX591t2YfmBXVHE0ZbTX3k8r7GPRWn/wjuuf9AbUf/AV/8KB4b11jgaLqJP8A16v/AIVftaf8y+8LMzKK6O18BeJ7vGzSJkHrKVj/APQiK27P4Sa7MQbm4s7ZT1yxdh+AGP1rGeNw8PimgUWzga7LwX4FufENyl1eJJDpa8l/umY/3V/qa9B0L4Y6LpLRzXQa/uV5zLxHn2Tv+Oa7ZVVFCqoVQMAAcCvHxmdLl5KH3/5GsaXWRHb28NrbxwQRrHDGoVEUYCgelS0UV8423qzcKKKOlAFLV9Rj0nSbq/lICQRl+e5xwPxOB+NfM9xcS3l3JPKxeaZy7MeSSTkn9a9T+LXiBBDDoUWS7FZ5j2xztX88H8BXI/D/AEA634oh8xCbW0xPKexx91fxP6A19PllNYbDSxE+uvyMKj5pWR7N4U0ptG8MafZSLtlSLdKPR2+Zv1NbWKBRXzdSbqTc3uzZaIKxfFOhR+ItAuLBtolI3Qu38Eg6H29D7E1tUUoTlTkpR3Q9z5cP2jTb/HzRXNvJ+KOp/mCK+hfCXiOLxLokV2hUTr8k6D+F/wDA9RXDfFTwvsYeILVThiI7pQOB2D/yB/CuL8JeJp/DGsLcqC9vJhZ4gfvL6/Uc4/8Ar19PiKccywqq0/iX9WOeL9nKx9F0VWsL621KyhvLSUSwTKHRx3H9PpVmvl2mnZnQFFFFIAooooAMc0mKWigAxSYpaKAExS4oooAKKKKACiiigArO13WLbQtHn1C6I2Rjhc4Lseij3NXpZY4ImllkWONBlmc4AHqTXgnjvxc3iXUxHbll063JESkffPdz9e3t9a7svwTxVS32VuROaijntRv7nV9TnvbljJPO+49/oB9OB+Fe6+AvDn/CPeHkSZSt5cYlnB6qey/gP1Jrz74Z+FTqepjVruINZWrHywf45Rgj8BnP1xXtdehnGLWmHp7Lf/IilH7TCiiivBNgooooAZLGk0TxSqHjcFWVhkEHqDXg/jnwZL4avjcWyM+mTN+7bk+Wf7jH+XqPeve6rX1jb6jZy2l3EssEq7XRh1Fd2BxssLUutU91/XUicOZHg3gzxlc+Fr3YwabT5T+9hzyD03Lnv/P8jXvVle22o2cV3aTJNBIMpIhyDXhXjPwRdeGrlriANNpjt8kvePPRW/oehqn4W8X6h4YuswMZbRyPNt2Pyn3HofevaxmCp42Ht8O9fz/yZlGTi7SPomisXw94n0zxHaiaymHmAAyQPw8f1Hp7jitqvmpwlTlyzVmbp32CiiioGFFFFABRRRQAUUUUAFFFBOKACmTSpBC8srqkaAszMcAAdSaoaxrunaFZm51C4WJedq9Wc+ijua8T8XeOr7xM5t4822nq2VhB5fHdz3+nT613YLAVMVLTSPciU1EteOvHT+IpTY2JePTo25OcGYjufb0H41l+EfCtx4o1QRLuS0iINxMP4R6D/aPb86Twr4Rv/FF5tiBitEOJbhhwvsPVvb86950fR7PQtOjsbGIRxIPqWPck9zXt4vF0sDS9hQ+L8vUyjFzd2T2Flb6fZRWlrGI4YVCIoHYVZoor5dtt3Z0BRRRSAKKKKACiiigCOaCKeF4po1kjcFWVhkEe4ryTxV8LprZnu9BDSwgZa2Y5cf7vHP0PP1r1+g9K6sLjKuGleD+RMoqW58uxTXem3m+F5ra5iOMqSjqf516N4e+LM8REOuw+bHjAngQBs/7QyAfw/Ku88Q+DdI8RoWu4NlzgAXMfD8evqPY15T4g+Gus6O0k1ov9oWo6NEv7wD3T/DP4V70MXg8dHlrK0vP9H/mYuMobHsWkeIdL1yASWF7FMT1QNh1+qnkVqV8s/vbeb+KKVDkH7rKR/I10um/EPxLprr/p5uox/wAs7kbwfx+9+RrmrZFLejLTz/zRSrdz6Borya1+McgIF5o6MO7RTEfoQf51uQ/Fvw9IBvgv4z33RKR+jV588sxUX8F/Qv2kTvaK4r/hanhn/nrdf9+DUMvxZ8OoPlivpD/sxL/VhWawGJe0GPnj3O7oryq8+MWGIstIJHZ5psH/AL5A/rXMan8SfEmosQl2tnGRjZbJt/Hccn9a6qWT4me6S9WS6sUe26nrOn6RCZb+8ht1Az87cn6DqfwrzzxB8WoxEYtCgLPnBnuE4x/srnP515ZNPPd3DSzyyTTOcs7sWZj9TXS6D8Ptd1wrIYDZ2xPM1wCpx/sr1P8AL3r0qeWYXDLnryv67GbqSl8JgX+o32r3rXN7cSXE7nqxz17AdvoK7Twt8Mr3UzHd6uHtbJhkR5xK/wCBHyj6816D4c8BaR4e2ypH9pvAc/aJhyp/2R0H8/euqrmxecu3Jh1Zd/8AIqNLrIrWVha6faR21pAkMEYwqIMAVZoorwm23dmwUUUUgCiiigAooooAKKKKACiiigAowDRRQBmap4e0jWedQ0+CdgMB2XDAf7w5rjL/AOEOlTuzWV9c2ueisokUfyP616KaO1dNDGV6T9yTRPKpbnid18Jdehc/Z5rK4TPB3lG/EEY/Ws6X4beK4icaYHHqtxH/AC3V763elNdsc8xK0aT+X/BIdKJ89j4f+KR/zCJc/wC+n/xVSR/DfxVJg/2XtB7tPGMf+PZr6ApD/StXnmI7L8f8yfZo8QtvhN4hmYCV7OAdy8hP8ga6Wy+D9hGym91K4nwc7YkEYP55r0sdKK56mbYqovit6GipRRjaX4V0PRmV7HTYY5V6SsCzj/gRya2cCiivPlUnUd5ttlbBRRRUDCiiigAooooAKKKKAP/Z"},354:function(t,r,e){t.exports=e.p+"assets/img/middy.4aef0f28.png"},355:function(t,r){t.exports="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQYAAABgCAYAAAD/79zPAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAhGVYSWZNTQAqAAAACAAFARIAAwAAAAEAAQAAARoABQAAAAEAAABKARsABQAAAAEAAABSASgAAwAAAAEAAgAAh2kABAAAAAEAAABaAAAAAAAAAJAAAAABAAAAkAAAAAEAA6ABAAMAAAABAAEAAKACAAQAAAABAAABBqADAAQAAAABAAAAYAAAAACAiOg8AAAACXBIWXMAABYlAAAWJQFJUiTwAAABWWlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNi4wLjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczp0aWZmPSJodHRwOi8vbnMuYWRvYmUuY29tL3RpZmYvMS4wLyI+CiAgICAgICAgIDx0aWZmOk9yaWVudGF0aW9uPjE8L3RpZmY6T3JpZW50YXRpb24+CiAgICAgIDwvcmRmOkRlc2NyaXB0aW9uPgogICA8L3JkZjpSREY+CjwveDp4bXBtZXRhPgoZXuEHAAAV8klEQVR4Ae1dCXAU55V+6L4lJBAgdINQsCyL+wpxHCC2wEA4vDaHNw7rWgo7cdWGXYddr+3U1lYlxilnba8hu2sg3pAQJ14cl2NOYWMwBpSIy5YQGINAgNB935f3fR2PM0jT13TPSGjeq5qamb//q7/u/vr973//+4d9wUIigoAgIAg4IeDn9Ft+CgKCgCCgICDEIDeCICAI9ENAiKEfJJIgCAgCQgxyDwgCgkA/BIQY+kEiCYKAICDEIPeAICAI9ENAiKEfJJIgCAgCQgxyDwgCgkA/BIQY+kEiCYKAICDEIPeAICAI9ENAiKEfJJIgCAgCQgxyDwgCgkA/BAL6pegkYMlVQ1sP9d7ha6+CA/woPFh4Uedyax5ubm6mnp4ezTwDdTA8PJwCAkzf3kp3u7q6qLW11XLX/fz8yPHx9/cnfPB/2LBhluv2dAWmkWvt6qUndpRQXfPgvCGMAvatrEj60eIEvkhGS0g+ZwSwKPfFF1+kzz//3Dl5UPxG3zZt2kSTJk1yqz9nzpyhV199lXp7e90q7yjkIAMQVGBgIMXFxVF8fDyNHDmSUlNTKSkpiaKjoyk0NNRtEnO0Zfe3aWL4grGqqO+i6sZuu/vitfqwzrymqZvwLbzgHux4+Kqrq+nWrVvuVeDBUnig29ra3G6hvb2dysvLPaINATdoDCANEEJsbCylp6fTjBkzKDs7WyGN4OBgt/tuV0HTxGBXwwNfj1DCwF8D3+uBYxiBIRiGYviUlpbS0aNHKTIykjIyMmjp0qWUk5Oj/Hfk9zZSPkwM3oZa2hME1BGAltPQ0EAFBQV09uxZGjt2LM2ePZsWL15MCQkY8nr3RSbEoH6t5IggMCAIdHd307Vr1+j69euUn59PCxcupNzcXEWD8FaHxCzvLaSlHUHAJALQIkpKSmjbtm20efNmZcgBG4U3xC2NAX2zs3tGlCQ721P67yWAvXERB3Mb3rqRvY2BUdXecf6Ob6PlnM+ns7OTjh8/rhh7161bR9OnT1emPZ3z2P3bNDEEBQ6j9Qviqa3T2lSO84kcvdBEpy+3OCf1+71iViylxAX1S3c3IT0+RKYq3QXPYDlY19euXUtBQfZdN4NNU0pKitGspvPhIV+yZIliA1ArjLc9Hmj4RDQ2NlJtba3yYMPQWFZWphgdHWShVodzOvJevHiRXn75ZVq/fj3de++9ysyGcx47f5snBv9htHp2nJ19oNqWHk1igN3lwUkxNCM93NZ2pTLPIoC5++XLl1NERIRnGxqA2tPS0jSJoW+XHETR0tKiEAQecvhLFBYWKv/75lf7j2nUrVu3EuwQ8+bN8xg5mCYGtQ5bSTcylLBSv5QVBAYaAXg8hoSEKB84Ok2YMIEWLFhAN27coBMnTtDhw4cN2xDgPwK7A6Y3Z86c6ZEZCzE+DvQdI+37JAKwNYSFhSkE8dhjj9Frr71Gjz/+OMXExBjCo7KyUhlWFBcXG8pvNpMQg1nEJL8g4AEEMNxas2aN4maenJxsqIWKigpFc6ipqTGU30wmIQYzaEleQcCDCECLgOfjSy+9RFOmTDHUEuwU+/btM5TXTCYhBjNoSV5BwAsIjBgxgp577jmaPHmyodZ2795NVVVVhvIazSTEYBQpyScIeBEB2BqeeeYZwuyHntTX19OuXbv0spk6LsRgCi7JLAh4DwFoDhs3bqSoqCjdRvPy8pQVoboZDWYYFNOVBvs6aLN193xB12s7qehGG12r6qCyhi5q4mA2Hd1fEMeDodAgf4oN96ckdtBKHxVCmWNC+H8A+ck87aC9poOlY1lZWYRZiy1btmjGh8AqzZ07d9LTTz9tS9eFGNyEsZd9tM/fbKM/FNRR/qVmulnTSd1IhO82P/B9n3mHBzZPZ3PkKH9KjQ+ib2VF0ZIpw2l0dKCbvZBiQx0BGCQfeOABev/99+n8+fOqp4t88IcAQdjhUCZDCVWoXR/AA57P7tuP/88V+u6Wy/T74zVUylpCD5MCyICvTz9SQE1KOh9D+eb2HiosbaP/3FdBK35+if75zetUxCTjIA/XLUuqryKAMHWrVq3SjfJUV1dHx44dswUmIQYTMDby8ODZt67TE9tK6BSTA4YQfTUDE9UpWZu5zr2n6+l7W6/Qv/zuOl2t7jBbheT3AQQwfWnEv+HQoUO2oCHEYBDGUh4q/HBnKf2xoF4hBIPFDGfr4FiaIIi/ZS1kx5Eqtk/Yt0jNcCck46BFAFrDtGnTdN2fEYMT6zGsihCDAQRhWHyG1f0/f95sILe1LA28oOyVveX03Fs3qJyNmCKCgAMBrIvA+ggtwUpOLVuEVlnnY0IMzmi4+N3c0UM/e+8WfXrNeDhx2ApcfVxU7zIJZY+cb6JL5e0uj0uibyKQmZmpO5zAKk5EfbIqMiuhgSAMim8cqaaPi5t0A9OEh/jTXYkhlJ0cRhmjQyguMoDCg5h32QjR3N5Llfz2v1zRocxkXLrVTvUtHKWaCcCV+PM85gaOeTFr/NBbruzqfCXNGAJYdAVyKCoq4nvH9c2D2YnPPvvMWIUauYQYNMC5XNlB+87WUxcbGbUkfVQwff+BUTQnI1JzExvU0trRS4U3Wmn/2Qb6iAPUgDD6yvTx4bR8eiwFcuwLEUHAgQAeehADAt90dKgbqRHSH8ethKEXYnCg3ucbhHzwkwYqq+3/4DpnzRwbQj9dlUTj2XFJT/CYY/ermeMiaEpqOJ0rbaXfHKuh4xebvoqIlchOUBsfHEMxYf561clxH0QAkangp6BFDIg2jZgNiDTtroiNQQW5JvY1+DNPSWI4oSbR/PA+v3KsIVLoWwe0gWlp4fSTRxJp4+IxlDIymCJC/BTNI5OHIiKCgCsE4CaN3au0BOHkEK/BiojGoILeNfYnuF6jrq6h2KIpMZSdGKZSg7HkULZDPDwzlu5JDuUhRht9OztacYYyVnrw58JYWG08bGfvoWb7gkBbQASoK1euqJ4u8BZiUIXH2oFr1Z3U3KbuSxDAb/zvTBturZEvS+OenpgQqnxsqXCQVII317vvvmtprGvkVOD4gy3efEEQRxMaAx5+LTIUYvDQ3VDFe1t2ahgdI3kYkTZi4PcY9NDp21ItxsGvv/66LXVpVYLYib5CDCADrLbUIgVgZTWqkwwlVO64Dg6Pr6UCB/CUoo9oryoIGUvWu4GN1aKdyxttaPfAu0ehMSC4LHwWXAnwaG017nfjqg4xPrpChdMCArQf/MbWHmrgj4gg4G0EMA2pR4bY08KKCDGooIfpQmgFaoK1DX84Vad2WNIFAY8hADuDnggx6CHk5vEUth+Ess+Blrz5cQ0Vl4nbshZGcsx+BAICAkRjsB9WYzWOZ2/GxFjtrdVq2UD5o9+UKtOMxmqVXIKAdQR6eno07V9oAeRhRayVttLyIC8bExZAczMj6cLNdk0nJ4Ry+/6Oq/RPS8bQfI7IFIb1ESIKAhgHY95dbzxsFa7Q0FCrVdxR5TENrCdW9wsVYlBBGDMOD7HjUcGVFjrFHy2pa+6mH//+Br05NpRyJ0XT/LujaQyHa/P1WQss+sEmrPj2pPgaMcB+oDVjBqytrJNAeSEGoKAio/jhXj8/np6vvUEV9dosjWhOn/Lah2IO0bY7v5ZmZUTQfXdFUQ6vtoR3oy8KNIX4+HhbYhD6In5q54y4jlrEgGPYJ9OKCDHooDdjXDj9/bx4eu1AhbJUWie7Et3pCi+vLuGVmXvO1LOrc5gyJPk6D0tgs9CY6NCrWo4LAgoCCMaiRQzIZHQPTDVIhRjUkPkyHbERlrHrM4YFWw5WEAyORoRJmxCN6SOO5YAo0r87UUPTeVXlPLZDgCywylJEEDCLQHd3NzmIQct2A03NiggxGEAviJ2dQA4xvDfEf+wp58VVnaaCwHby/hIOLeLAuQaayEu1v8nDjG98LZKSdGY+DHRPsvgQAm1tbYq7sxYpOIZwVmARYjCIHpZJz8+K5k1jgmn74Uo6XNRInV3qS7JdVQstApGbTnzWrBg0YYtYODmGFrHBckxMkCmycVW/pA19BBAiHlvSaYm/v79i29HKo3dMiEEPIafjsA98jXeR+vGKsZSbE6MYGfM5QCw0AnUfSacKnH6iDEK8lVRW0AGOEvXw7DhazMu4QwNliOEEk/zsg0BZWRk1NTX1Sb39LwLGylDidky88i+C4zvCZwH2ggu32uhN3nQm75NGZVs6swSB2YyL7D3577tv0n4eZjy7PIHSOGiLiCDgCoHi4mLdBVKjRo0ihJu3IvJ6soAeSGDimFD6t5WJ9M4/ZihOThMTQ5UFWO5Ui/D0T2y/qsSEdKe8lBnaCMDwiH0j9GYkUlNTLQMhxGAZwr9UEB8VSI99YwT99qnx9OsfjKOHZsUqkaLNVl/Ge1j88FelEjreLHA+kP/mzZtUUlKie6ZTp07VzaOXQYhBDyGTx2GHuIujMT3Pdoh3n55Am5YlELQITHsaFThTvbK/nOrYUCkiCDgQOH36NFVVVTn+uvyGF2hOTo7LY2YShRjMoGUybyTbItbOiaNfPTmOXlmXQjMnRBBCwhkR+D9gJ21lB20jBSTPkEYAC6cKCgoIwwktSUxMpJEjR2plMXRMiMEQTNYyBbMfxL3s+bh1XSr9ZHUSpcTrGxcxtbmLQ8tjkxoRQQDDiMLCQk0gYHuYNWuWLYvWhBg0obb3IHwhcu+Jpl/8XSrNnRipu8iqgjejwaY0GhHs7e2g1DYoEUAItz179igej1odxPqI+++/XyuL4WNCDIahsi8j1ky8wJvUPDg1RrNSDDpOsDt1Y5uEkNMEaogfvHjxokIMeqcJ2wKGEnaIEIMdKLpRR1SoP/3g26Np9HDtYDCI91DLy7pFfBOB9vZ22rFjh+7W9nCDXrFihW0gCTHYBqX5isbEBNKy6dpaQzPviFXfKsRgHt07vwSGELt37ybMRujJxIkTadq0aXrZDB8XYjAMlf0ZsWITO1pjkZaadHOE8LZOc2sy1OqS9DsLgVOnTtGuXbtUw8Q7zgah5B999FHCGgm7RIjBLiTdrCc2PEDbx4Etzb2YohDxKQQwA/HCCy/ouj8DFDg0zZw501Z8ZBGVrXCarwyb5/ZqTDvAMcpKBCjsBoUYgYgBaDUOoPmzkxJmEcCUI4YOmzdvptraWt3i2JVq9erVygY0uplNZBBi0ACrnD0Q8woblAhMqRxOHqq/3VLEG9lqbYUXwUZKaBVmBKvvjh49SkeOHKHS0lKCAQtxF8eNG0fz5s1T3i6ejsNopr+S9y8IYDn1oUOH6I033tA1NqIEiH7t2rWUnZ1tO4Tm7jjbmx+8FbbxFnW/PFJFb52sJQRX2bAgXonABGclu6SV2zhUiDBd6jUmxwUpAWLUc9x+BDfXli1b6IMPPrhtbNrQ0EC3bt1S3kZLlixRbigszxUZeAQQfOXChQv09ttvU35+vqLh6fUKdgX4LCxcuNByqHhXbQkxuEAFmv1ejpHwx9P1SgzHT6610rMcBXoVuzc/zIujzL7BXTShOC396XILnbuqvcdgNoeBi2LXaiMCt9lt27Ypbx21/NjT8J133lECtK5Zs8Z2FVStXUm/HQHMOCBE26VLl+jDDz+k48eP6wZgcdSAqUls4guDo6fIXYjBgbbT9ycc7fmXR6qp2cmxCLEe/yuvkk6XtNB3eRXllLRwt/eQAPEUcTTpX+RVELa6U5MwjguJaNNG11fgrZOXl6dW3VfpsDvs37+f5syZQ+np6V+le+IH7BtG9kHwRNtGdmzyRLt964TdAGscgAM0t/LycioqKlK0NzgvmdmAFqQAY+OGDRsIcRc8JUIMfZCtaOyirfzAlrJjUV+BkfAkh2U7xxrEvLujaMmU4XQX7yURzftcGh1gtHT0Uv7lZvrvQ5VUzPYFLZnFi66yeGWmUcHwAQ89bh49qaioUG5MTxID+rJ9+3YysteiXn/dOb5o0SLKyMhwp6huGcebXi0jtDfs/4APbD7V1dXKykjYfPAbdh+zgulIaApPPvmkbR6Oan0QYnBCBtOCOz+qpgJW8bWkjR/uPafq6f1PG1lzCKPZEyKVBxgOS+HB/gQ7hLIhLj+fXRyhCVpBLUeMvlzRTh+eb+LI0Y26O2XHsMHxoRmxFM3GR6OCIB5GSAH14Q2Gm9STgjfke++958kmVOvGWzorK8sjxACMoXEdOHBAtX0cQB8cH/w3em2Qt6/A0Jibm6vYhqyGbetbt6v/QgxOqPCwT5GQQD9qZsbXk3Y2Hh6/2Ewf8wfh4EdGBVB8dBDFRfhz7EZ+oJkYWng6sobjKtzkyNLVPBxBKDc98eMpyr9hW8b0dHPhuWDEMiq4Yc2osEbr7ZvPysPQt67B9N/5gdfrlxUMUHbEiBG0dOlSWrlyJXlr1y0hBqerirH8P+SOppyUMNp6oJKuVLZrzhg4ikJxb2Ut4lpVp/JxpLvzjVEAhinf++YICmaCMiNm/BRww1ndxsxM3ySveQRAAphehp9CQkKCJY3DbOtCDH0QAzks4L0nYTuAAXIf7ybV5GSE7JPd1r9wZpp/TxT963cSCEFezEpaWpqyZt/IGwrjVbtW4pntp+TXRgAbAWPdw7Jly5ThkNWdq7Vbc31UiMEFLtAAxvKqx028g3VuTjT979Fq+hMvf4Zvg6ckkm0Jq78ep2gKEWyncEfwdsHYVy/KD+qGemrnoht3+itl/ooADLSIvIQZBwwbUlJSBsxoi14JMfz12vT7hcAq03ha8m6eGTjLMxH/xxvEHOPAKRg22CWwZ0z9cn/MnGRzsSH79gHr8e+77z5NPwaUwU0I5xh4Qop4DwHYJaDN4QMtAJoBphwzMzOVyEv4houznYuh3D27QUEMw9lYl8QefmoCIK2sF1Cr12g6Hl6sgpySGk6X2e6Qx7MRR8430g2O6AwDJPwSoGUYFQwZonm7u8mpYcpGM5PZpoE2rAq84Z566inFqHjy5MnbPB8ddcOuAG+5Rx55xJJzE64Jbmo46QxGwUPorqEO5TCmhxOSFcH1gN0HmOM7OjpawQx1JyUlKW0gDZGXgOdgkmEMoL6Z3MM97uBdmTqxvlhDwngreTORljWqsnwIgCFOQlldF51jZ6gzV1uohGMz1nHchNb2XuphpgBZQJgDKDDAjyJCMGsRSBN4Jys4R2UnhSr/g1grsVswO3Hw4EHau3ev4gaNoQVuzuTkZEVNnTt3ri2GR7Rj9eGx+9wd9eG2xgPnzvgcPgju+Bk42nb+Bjngocc3NIHBoA0490/t96AgBrXO3SnpIAL4K2CIAZLr4d/4DzUCwxEYNKERQOvBf5CFNwTTkXCugZMNiAFqKh4WEUFADwEhBj2E5Lgg4IMIWB/Y+iBocsqCwFBHQIhhqF9hOT9BwA0EhBjcAE2KCAJDHQEhhqF+heX8BAE3EBBicAM0KSIIDHUEhBiG+hWW8xME3EBAiMEN0KSIIDDUERBiGOpXWM5PEHADASEGN0CTIoLAUEdAiGGoX2E5P0HADQSEGNwATYoIAkMdgf8H39NDVYVi/ggAAAAASUVORK5CYII="},473:function(t,r,e){"use strict";e.r(r);var a=e(14),s=Object(a.a)({},(function(){var t=this,r=t._self._c;return r("ContentSlotsDistributor",{attrs:{"slot-key":t.$parent.slotKey}},[r("HeroSection",[r("h1",{attrs:{id:"ajv-json-schema-validator"}},[r("a",{staticClass:"header-anchor",attrs:{href:"#ajv-json-schema-validator"}},[t._v("#")]),t._v(" Ajv JSON schema validator")]),t._v(" "),r("h2",{attrs:{id:"security-and-reliability-for-javascript-applications"}},[r("a",{staticClass:"header-anchor",attrs:{href:"#security-and-reliability-for-javascript-applications"}},[t._v("#")]),t._v(" Security and reliability for JavaScript applications")]),t._v(" "),r("Features",[r("Feature",{attrs:{type:"less-code",link:"/guide/why-ajv.html#write-less-code"}},[r("h3",{attrs:{id:"write-less-code"}},[r("a",{staticClass:"header-anchor",attrs:{href:"#write-less-code"}},[t._v("#")]),t._v(" Write less code")]),t._v(" "),r("p",[t._v("Ensure your data is valid once it is received")])]),t._v(" "),r("Feature",{attrs:{type:"fast-secure",link:"/guide/why-ajv.html#super-fast-secure"}},[r("h3",{attrs:{id:"super-fast-secure"}},[r("a",{staticClass:"header-anchor",attrs:{href:"#super-fast-secure"}},[t._v("#")]),t._v(" Super fast & secure")]),t._v(" "),r("p",[t._v("Compiles your schemas to optimized JavaScript code")])]),t._v(" "),r("Feature",{attrs:{type:"multi-spec",link:"/guide/why-ajv.html#multi-standard"}},[r("h3",{attrs:{id:"multi-standard"}},[r("a",{staticClass:"header-anchor",attrs:{href:"#multi-standard"}},[t._v("#")]),t._v(" Multi-standard")]),t._v(" "),r("p",[t._v("Use JSON Type Definition or JSON Schema")])])],1),t._v(" "),r("Sponsors",{attrs:{level:"platinum"}},[r("h2",{attrs:{id:"ajv-sponsors"}},[r("a",{staticClass:"header-anchor",attrs:{href:"#ajv-sponsors"}},[t._v("#")]),t._v(" Ajv sponsors")]),t._v(" "),r("p",[r("a",{attrs:{href:"https://www.mozilla.org",target:"_blank",rel:"noopener noreferrer"}},[r("img",{attrs:{src:"/img/mozilla.svg",alt:"mozilla"}}),r("OutboundLink")],1),t._v(" "),r("a",{attrs:{href:"https://opencollective.com/ajv",target:"_blank",rel:"noopener noreferrer"}},[r("img",{attrs:{src:"/img/reserved.svg",alt:"reserved"}}),r("OutboundLink")],1)])]),t._v(" "),r("Sponsors",{attrs:{level:"gold"}},[r("p",[r("a",{attrs:{href:"https://opensource.microsoft.com",target:"_blank",rel:"noopener noreferrer"}},[r("img",{attrs:{src:"/img/microsoft.png",alt:"microsoft"}}),r("OutboundLink")],1),t._v(" "),r("a",{attrs:{href:"https://opencollective.com/ajv",target:"_blank",rel:"noopener noreferrer"}},[r("img",{attrs:{src:"/img/reserved.svg",alt:"reserved"}}),r("OutboundLink")],1),t._v(" "),r("a",{attrs:{href:"https://opencollective.com/ajv",target:"_blank",rel:"noopener noreferrer"}},[r("img",{attrs:{src:"/img/reserved.svg",alt:"reserved"}}),r("OutboundLink")],1)])]),t._v(" "),r("Sponsors",{attrs:{level:"bronze"}},[r("p",[r("a",{attrs:{href:"https://retool.com/?utm_source=sponsor&utm_campaign=ajv",target:"_blank",rel:"noopener noreferrer"}},[r("img",{attrs:{src:"/img/retool.svg",alt:"Retool"}}),r("OutboundLink")],1),t._v(" "),r("a",{attrs:{href:"https://tidelift.com/subscription/pkg/npm-ajv?utm_source=npm-ajv&utm_medium=referral&utm_campaign=enterprise",target:"_blank",rel:"noopener noreferrer"}},[r("img",{attrs:{src:"/img/tidelift.svg",alt:"Tidelift"}}),r("OutboundLink")],1),t._v(" "),r("a",{attrs:{href:"https://github.com/simplex-chat/simplex-chat",target:"_blank",rel:"noopener noreferrer"}},[r("img",{attrs:{src:"/img/simplex.svg",alt:"SimpleX"}}),r("OutboundLink")],1),t._v(" "),r("a",{attrs:{href:"https://opencollective.com/ajv",target:"_blank",rel:"noopener noreferrer"}},[r("img",{attrs:{src:"/img/reserved.svg",alt:"reserved"}}),r("OutboundLink")],1)])])],1),t._v(" "),r("HomeSection",[r("Columns",[r("Column",{attrs:{side:"left"}},[r("p",[t._v("Ajv is used by a large number of JavaScript applications and libraries in all JavaScript environments - Node.js, browser, Electron apps, WeChat mini-apps etc.")]),t._v(" "),r("p",[t._v("It allows implementing complex data validation logic via declarative schemas for your JSON data, without writing code.")]),t._v(" "),r("p",[t._v("Out of the box, Ajv supports "),r("RouterLink",{attrs:{to:"/json-schema.html"}},[t._v("JSON Schema")]),t._v(" (drafts 04, 06, 07, 2019-09 and 2020-12) and "),r("RouterLink",{attrs:{to:"/json-type-definition.html"}},[t._v("JSON Type Definition")]),t._v(" ("),r("a",{attrs:{href:"https://datatracker.ietf.org/doc/rfc8927/",target:"_blank",rel:"noopener noreferrer"}},[t._v("RFC8927"),r("OutboundLink")],1),t._v(").")],1),t._v(" "),r("br"),t._v(" "),r("Button",{attrs:{link:"/guide/getting-started.html"}},[t._v("Learn Ajv")]),t._v(" "),r("br")],1),t._v(" "),r("Column",{attrs:{side:"right"}},[r("code-group",[r("code-block",{attrs:{title:"JSON Schema"}},[r("div",{staticClass:"language-javascript extra-class"},[r("pre",{pre:!0,attrs:{class:"language-javascript"}},[r("code",[r("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" Ajv "),r("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),r("span",{pre:!0,attrs:{class:"token function"}},[t._v("require")]),r("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),r("span",{pre:!0,attrs:{class:"token string"}},[t._v('"ajv"')]),r("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n"),r("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" ajv "),r("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),r("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("new")]),t._v(" "),r("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("Ajv")]),r("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),r("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n\n"),r("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" schema "),r("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),r("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),r("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),r("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),r("span",{pre:!0,attrs:{class:"token string"}},[t._v('"object"')]),r("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),r("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("properties")]),r("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),r("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),r("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("foo")]),r("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),r("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),r("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),r("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),r("span",{pre:!0,attrs:{class:"token string"}},[t._v('"integer"')]),r("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),r("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),r("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("bar")]),r("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),r("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),r("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),r("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),r("span",{pre:!0,attrs:{class:"token string"}},[t._v('"string"')]),r("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n "),r("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),r("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),r("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("required")]),r("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),r("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),r("span",{pre:!0,attrs:{class:"token string"}},[t._v('"foo"')]),r("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),r("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),r("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("additionalProperties")]),r("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),r("span",{pre:!0,attrs:{class:"token boolean"}},[t._v("false")]),t._v("\n"),r("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n\n"),r("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" data "),r("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),r("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),r("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("foo")]),r("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),r("span",{pre:!0,attrs:{class:"token number"}},[t._v("1")]),r("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),r("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("bar")]),r("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),r("span",{pre:!0,attrs:{class:"token string"}},[t._v('"abc"')]),r("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n"),r("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" valid "),r("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" ajv"),r("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),r("span",{pre:!0,attrs:{class:"token function"}},[t._v("validate")]),r("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("schema"),r("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" data"),r("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n"),r("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("if")]),t._v(" "),r("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),r("span",{pre:!0,attrs:{class:"token operator"}},[t._v("!")]),t._v("valid"),r("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" console"),r("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),r("span",{pre:!0,attrs:{class:"token function"}},[t._v("log")]),r("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("ajv"),r("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("errors"),r("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n")])])])]),t._v(" "),r("code-block",{attrs:{title:"JSON Type Definition"}},[r("div",{staticClass:"language-javascript extra-class"},[r("pre",{pre:!0,attrs:{class:"language-javascript"}},[r("code",[r("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" Ajv "),r("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),r("span",{pre:!0,attrs:{class:"token function"}},[t._v("require")]),r("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),r("span",{pre:!0,attrs:{class:"token string"}},[t._v('"ajv/dist/jtd"')]),r("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n"),r("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" ajv "),r("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),r("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("new")]),t._v(" "),r("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("Ajv")]),r("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),r("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n\n"),r("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" schema "),r("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),r("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),r("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("properties")]),r("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),r("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),r("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("foo")]),r("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),r("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),r("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),r("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),r("span",{pre:!0,attrs:{class:"token string"}},[t._v('"int32"')]),r("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n "),r("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),r("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),r("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("optionalProperties")]),r("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),r("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),r("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("bar")]),r("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),r("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),r("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("type")]),r("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),r("span",{pre:!0,attrs:{class:"token string"}},[t._v('"string"')]),r("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n "),r("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n"),r("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n\n\n"),r("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" data "),r("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),r("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),r("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("foo")]),r("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),r("span",{pre:!0,attrs:{class:"token number"}},[t._v("1")]),r("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),r("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("bar")]),r("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),r("span",{pre:!0,attrs:{class:"token string"}},[t._v('"abc"')]),r("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n"),r("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" valid "),r("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" ajv"),r("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),r("span",{pre:!0,attrs:{class:"token function"}},[t._v("validate")]),r("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("schema"),r("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" data"),r("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n"),r("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("if")]),t._v(" "),r("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),r("span",{pre:!0,attrs:{class:"token operator"}},[t._v("!")]),t._v("valid"),r("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" console"),r("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),r("span",{pre:!0,attrs:{class:"token function"}},[t._v("log")]),r("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("ajv"),r("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("errors"),r("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n")])])])])],1)],1)],1)],1),t._v(" "),r("HomeSection",{attrs:{section:"testimonials"}},[r("h2",{attrs:{id:"what-users-say"}},[r("a",{staticClass:"header-anchor",attrs:{href:"#what-users-say"}},[t._v("#")]),t._v(" What users say")]),t._v(" "),r("Testimonials",[r("Testimonial",{attrs:{color:"green"}},[r("p",[t._v("Ajv stands out as the implementation of choice - it provides a rich API which many thousands of people use in production... Ajv is partly responsible for the success of JSON Schema.")]),t._v(" "),r("p",[r("a",{attrs:{href:"https://github.com/relequestual",target:"_blank",rel:"noopener noreferrer"}},[t._v("Ben Hutton"),r("OutboundLink")],1),t._v(", JSON Schema Specification Lead")])]),t._v(" "),r("Testimonial",{attrs:{color:"blue"}},[r("p",[r("a",{attrs:{href:"https://eslint.org/",target:"_blank",rel:"noopener noreferrer"}},[t._v("ESLint"),r("OutboundLink")],1),t._v(" has used Ajv for validating our complex configurations. Ajv has proven to be reliable over the years we’ve been using it and ESLint is proud to sponsor Ajv’s continued development.")]),t._v(" "),r("p",[r("a",{attrs:{href:"https://github.com/nzakas",target:"_blank",rel:"noopener noreferrer"}},[t._v("Nicholas C. Zakas"),r("OutboundLink")],1),t._v(", ESLint creator and TSC member")])])],1),t._v(" "),r("p",[r("span",{staticStyle:{float:"right"}},[r("RouterLink",{attrs:{to:"/testimonials.html"}},[t._v("All quotes")])],1)])],1),t._v(" "),r("HomeSection",[r("h2",{attrs:{id:"news"}},[r("a",{staticClass:"header-anchor",attrs:{href:"#news"}},[t._v("#")]),t._v(" News")]),t._v(" "),r("NewsHome")],1),t._v(" "),r("HomeSection",[r("h2",{attrs:{id:"who-uses-ajv"}},[r("a",{staticClass:"header-anchor",attrs:{href:"#who-uses-ajv"}},[t._v("#")]),t._v(" Who uses Ajv")]),t._v(" "),r("Projects",[r("p",[r("a",{attrs:{href:"https://eslint.org",target:"_blank",rel:"noopener noreferrer"}},[r("img",{attrs:{src:e(325),alt:"eslint"}}),r("OutboundLink")],1),t._v(" "),r("a",{attrs:{href:"https://stoplight.io",target:"_blank",rel:"noopener noreferrer"}},[r("img",{attrs:{src:e(326),alt:"stoplight"}}),r("OutboundLink")],1),t._v(" "),r("a",{attrs:{href:"https://webpack.js.org",target:"_blank",rel:"noopener noreferrer"}},[r("img",{attrs:{src:e(327),alt:"webpack"}}),r("OutboundLink")],1),t._v(" "),r("a",{attrs:{href:"https://github.com/gajus/table",target:"_blank",rel:"noopener noreferrer"}},[t._v("table"),r("OutboundLink")],1),t._v(" "),r("a",{attrs:{href:"https://www.fastify.io",target:"_blank",rel:"noopener noreferrer"}},[r("img",{attrs:{src:e(328),alt:"fastify"}}),r("OutboundLink")],1),t._v(" "),r("a",{attrs:{href:"https://github.com/wikimedia/restbase",target:"_blank",rel:"noopener noreferrer"}},[t._v("restbase"),r("OutboundLink")],1),t._v(" "),r("a",{attrs:{href:"https://github.com/vincit/objection.js",target:"_blank",rel:"noopener noreferrer"}},[t._v("objection.js"),r("OutboundLink")],1),t._v(" "),r("a",{attrs:{href:"https://taskcluster.net",target:"_blank",rel:"noopener noreferrer"}},[r("img",{attrs:{src:e(329),alt:"Taskcluster"}}),r("OutboundLink")],1),t._v(" "),r("a",{attrs:{href:"https://rxdb.info",target:"_blank",rel:"noopener noreferrer"}},[r("img",{attrs:{src:e(330),alt:"RxDB"}}),r("OutboundLink")],1),t._v(" "),r("a",{attrs:{href:"https://github.com/rjsf-team/react-jsonschema-form",target:"_blank",rel:"noopener noreferrer"}},[r("img",{attrs:{src:e(331),alt:"react-jsonschema-form"}}),r("OutboundLink")],1),t._v(" "),r("a",{attrs:{href:"https://github.com/Azure/autorest",target:"_blank",rel:"noopener noreferrer"}},[r("img",{attrs:{src:e(332),alt:"autorest"}}),r("OutboundLink")],1),t._v(" "),r("a",{attrs:{href:"https://github.com/node-red/node-red",target:"_blank",rel:"noopener noreferrer"}},[r("img",{attrs:{src:e(333),alt:"node-red"}}),r("OutboundLink")],1),t._v(" "),r("a",{attrs:{href:"https://developer.mozilla.org",target:"_blank",rel:"noopener noreferrer"}},[r("img",{attrs:{src:e(334),alt:"MDN"}}),r("OutboundLink")],1),t._v(" "),r("a",{attrs:{href:"https://github.com/quicktype/quicktype",target:"_blank",rel:"noopener noreferrer"}},[r("img",{attrs:{src:e(335),alt:"quicktype"}}),r("OutboundLink")],1),t._v(" "),r("a",{attrs:{href:"https://github.com/vue-generators/vue-form-generator",target:"_blank",rel:"noopener noreferrer"}},[r("img",{attrs:{src:e(336),alt:"vue-form-generator"}}),r("OutboundLink")],1),t._v(" "),r("a",{attrs:{href:"https://github.com/teambit/bit",target:"_blank",rel:"noopener noreferrer"}},[r("img",{attrs:{src:e(337),alt:"teambit"}}),r("OutboundLink")],1),t._v(" "),r("a",{attrs:{href:"https://react-page.github.io",target:"_blank",rel:"noopener noreferrer"}},[t._v("React Page"),r("OutboundLink")],1),t._v(" "),r("a",{attrs:{href:"https://backstage.io",target:"_blank",rel:"noopener noreferrer"}},[r("img",{attrs:{src:e(338),alt:"Backstage"}}),r("OutboundLink")],1),t._v(" "),r("a",{attrs:{href:"https://github.com/microsoft/rushstack",target:"_blank",rel:"noopener noreferrer"}},[r("img",{attrs:{src:e(339),alt:"rushstack"}}),r("OutboundLink")],1),t._v(" "),r("a",{attrs:{href:"https://github.com/jupyterlab/jupyterlab",target:"_blank",rel:"noopener noreferrer"}},[t._v("JupyterLab"),r("OutboundLink")],1),t._v(" "),r("a",{attrs:{href:"https://github.com/davidmarkclements/0x",target:"_blank",rel:"noopener noreferrer"}},[r("img",{attrs:{src:e(340),alt:"0x"}}),r("OutboundLink")],1),t._v(" "),r("a",{attrs:{href:"https://piqnt.com/planck.js/",target:"_blank",rel:"noopener noreferrer"}},[t._v("Plank.js"),r("OutboundLink")],1),t._v(" "),r("a",{attrs:{href:"https://www.fast.design",target:"_blank",rel:"noopener noreferrer"}},[r("img",{attrs:{src:e(341),alt:"fast"}}),r("OutboundLink")],1),t._v(" "),r("a",{attrs:{href:"https://www.netlifycms.org",target:"_blank",rel:"noopener noreferrer"}},[r("img",{attrs:{src:e(342),alt:"netlify cms"}}),r("OutboundLink")],1),t._v(" "),r("a",{attrs:{href:"https://ng-alain.com/en",target:"_blank",rel:"noopener noreferrer"}},[r("img",{attrs:{src:e(343),alt:"ng-alain"}}),r("OutboundLink")],1),t._v(" "),r("a",{attrs:{href:"https://vercel.com",target:"_blank",rel:"noopener noreferrer"}},[r("img",{attrs:{src:e(344),alt:"Vercel"}}),r("OutboundLink")],1),t._v(" "),r("a",{attrs:{href:"https://github.com/aws-amplify/amplify-cli",target:"_blank",rel:"noopener noreferrer"}},[r("img",{attrs:{src:e(345),alt:"AWS Amplify"}}),r("OutboundLink")],1),t._v(" "),r("a",{attrs:{href:"https://github.com/facebook/flipper",target:"_blank",rel:"noopener noreferrer"}},[r("img",{attrs:{src:e(346),alt:"FB flipper"}}),r("OutboundLink")],1),t._v(" "),r("a",{attrs:{href:"https://nx.dev",target:"_blank",rel:"noopener noreferrer"}},[r("img",{attrs:{src:e(347),alt:"nx.dev"}}),r("OutboundLink")],1),t._v(" "),r("a",{attrs:{href:"https://www.express-gateway.io",target:"_blank",rel:"noopener noreferrer"}},[r("img",{attrs:{src:e(348),alt:"express gateway"}}),r("OutboundLink")],1),t._v(" "),r("a",{attrs:{href:"https://www.zigbee2mqtt.io",target:"_blank",rel:"noopener noreferrer"}},[r("img",{attrs:{src:e(349),alt:"zigbee2mqtt"}}),r("OutboundLink")],1),t._v(" "),r("a",{attrs:{href:"https://github.com/sverweij/dependency-cruiser",target:"_blank",rel:"noopener noreferrer"}},[r("img",{attrs:{src:e(350),alt:"dependency-cruiser"}}),r("OutboundLink")],1),t._v(" "),r("a",{attrs:{href:"https://theia-ide.org",target:"_blank",rel:"noopener noreferrer"}},[r("img",{attrs:{src:e(351),alt:"theia"}}),r("OutboundLink")],1),t._v(" "),r("a",{attrs:{href:"https://tsdoc.org",target:"_blank",rel:"noopener noreferrer"}},[r("img",{attrs:{src:e(352),alt:"TSDoc"}}),r("OutboundLink")],1),t._v(" "),r("a",{attrs:{href:"https://webhint.io",target:"_blank",rel:"noopener noreferrer"}},[r("img",{attrs:{src:e(353),alt:"webhint"}}),r("OutboundLink")],1),t._v(" "),r("a",{attrs:{href:"https://vega.github.io/vega-lite/",target:"_blank",rel:"noopener noreferrer"}},[t._v("Vega-Lite"),r("OutboundLink")],1),t._v(" "),r("a",{attrs:{href:"https://middy.js.org",target:"_blank",rel:"noopener noreferrer"}},[r("img",{attrs:{src:e(354),alt:"middy"}}),r("OutboundLink")],1),t._v(" "),r("a",{attrs:{href:"https://github.com/jsdoc/jsdoc",target:"_blank",rel:"noopener noreferrer"}},[t._v("JSDoc"),r("OutboundLink")],1),t._v(" "),r("a",{attrs:{href:"https://tsed.io",target:"_blank",rel:"noopener noreferrer"}},[r("img",{attrs:{src:e(355),alt:"Ts.ED"}}),r("OutboundLink")],1)])])],1),t._v(" "),r("HomeSection",{attrs:{section:"contributors"}},[r("h2",{attrs:{id:"contributors"}},[r("a",{staticClass:"header-anchor",attrs:{href:"#contributors"}},[t._v("#")]),t._v(" Contributors")]),t._v(" "),r("p",[t._v("Ajv is free to use and open-source that many developers contributed to. Join us!")]),t._v(" "),r("Contributors")],1),t._v(" "),r("HomeSection",{attrs:{section:"footer"}},[r("FooterColumns",[r("FooterColumn",{attrs:{type:"ajv"}},[r("p",[r("img",{attrs:{src:"/img/ajv.svg",alt:"ajv"}})])]),t._v(" "),r("FooterColumn",{attrs:{type:"links"}},[r("p",[r("RouterLink",{attrs:{to:"/guide/getting-started.html"}},[t._v("Learn Ajv")])],1),t._v(" "),r("p",[r("RouterLink",{attrs:{to:"/api.html"}},[t._v("Reference")])],1),t._v(" "),r("p",[r("RouterLink",{attrs:{to:"/security.html"}},[t._v("Security")])],1)]),t._v(" "),r("FooterColumn",{attrs:{type:"links"}},[r("p",[r("RouterLink",{attrs:{to:"/json-schema.html"}},[t._v("JSON Schema")])],1),t._v(" "),r("p",[r("RouterLink",{attrs:{to:"/json-type-definition.html"}},[t._v("JSON Type Definition")])],1),t._v(" "),r("p",[r("RouterLink",{attrs:{to:"/contributing.html"}},[t._v("Contributing")])],1)]),t._v(" "),r("FooterColumn",{attrs:{type:"sponsors"}},[r("p",[r("a",{attrs:{href:"https://www.mozilla.org",target:"_blank",rel:"noopener noreferrer"}},[r("img",{attrs:{src:"/img/mozilla.svg",alt:"mozilla"}}),r("OutboundLink")],1),t._v(" "),r("a",{attrs:{href:"https://opencollective.com/ajv",target:"_blank",rel:"noopener noreferrer"}},[r("img",{attrs:{src:"/img/reserved.svg",alt:"reserved"}}),r("OutboundLink")],1)])])],1),t._v(" "),r("p",[r("RouterLink",{attrs:{to:"/license.html"}},[t._v("© 2015-2021")]),t._v(" | Ajv JSON schema validator | "),r("a",{attrs:{href:"mailto:ajv.validator@gmail.com"}},[t._v("ajv.validator@gmail.com")])],1)],1)],1)}),[],!1,null,null,null);r.default=s.exports}}]); \ No newline at end of file diff --git a/assets/js/11.2e6d8e3a.js b/assets/js/11.2e6d8e3a.js new file mode 100644 index 000000000..5565f5306 --- /dev/null +++ b/assets/js/11.2e6d8e3a.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[11,3,13,16,24,40,42],{238:function(t,e,n){"use strict";n.d(e,"d",(function(){return i})),n.d(e,"a",(function(){return r})),n.d(e,"i",(function(){return a})),n.d(e,"f",(function(){return l})),n.d(e,"g",(function(){return u})),n.d(e,"h",(function(){return c})),n.d(e,"b",(function(){return p})),n.d(e,"e",(function(){return h})),n.d(e,"k",(function(){return d})),n.d(e,"l",(function(){return f})),n.d(e,"c",(function(){return b})),n.d(e,"j",(function(){return g}));n(88);const i=/#.*$/,s=/\.(md|html)$/,r=/\/$/,a=/^[a-z]+:/i;function o(t){return decodeURI(t).replace(i,"").replace(s,"")}function l(t){return a.test(t)}function u(t){return/^mailto:/.test(t)}function c(t){return/^tel:/.test(t)}function p(t){if(l(t))return t;const e=t.match(i),n=e?e[0]:"",s=o(t);return r.test(s)?t:s+".html"+n}function h(t,e){const n=decodeURIComponent(t.hash),s=function(t){const e=t.match(i);if(e)return e[0]}(e);if(s&&n!==s)return!1;return o(t.path)===o(e)}function d(t,e,n){if(l(e))return{type:"external",path:e};n&&(e=function(t,e,n){const i=t.charAt(0);if("/"===i)return t;if("?"===i||"#"===i)return e+t;const s=e.split("/");n&&s[s.length-1]||s.pop();const r=t.replace(/^\//,"").split("/");for(let t=0;tfunction t(e,n,i,s=1){if("string"==typeof e)return d(n,e,i);if(Array.isArray(e))return Object.assign(d(n,e[0],i),{title:e[1]});{const r=e.children||[];return 0===r.length&&e.path?Object.assign(d(n,e.path,i),{title:e.title}):{type:"group",path:e.path,title:e.title,sidebarDepth:e.sidebarDepth,initialOpenGroupIndex:e.initialOpenGroupIndex,children:r.map(e=>t(e,n,i,s+1)),collapsable:!1!==e.collapsable}}}(t,s,n)):[]}return[]}function m(t){const e=b(t.headers||[]);return[{type:"group",collapsable:!1,title:t.title,path:null,children:e.map(e=>({type:"auto",title:e.title,basePath:t.path,path:t.path+"#"+e.slug,children:e.children||[]}))}]}function b(t){let e;return(t=t.map(t=>Object.assign({},t))).forEach(t=>{2===t.level?e=t:e&&(e.children||(e.children=[])).push(t)}),t.filter(t=>2===t.level)}function g(t){return Object.assign(t,{type:t.items&&t.items.length?"links":"link"})}},239:function(t,e,n){},240:function(t,e,n){"use strict";n.r(e);var i=n(238),s={name:"NavLink",props:{item:{required:!0}},computed:{link(){return Object(i.b)(this.item.link)},exact(){return this.$site.locales?Object.keys(this.$site.locales).some(t=>t===this.link):"/"===this.link},isNonHttpURI(){return Object(i.g)(this.link)||Object(i.h)(this.link)},isBlankTarget(){return"_blank"===this.target},isInternal(){return!Object(i.f)(this.link)&&!this.isBlankTarget},target(){return this.isNonHttpURI?null:this.item.target?this.item.target:Object(i.f)(this.link)?"_blank":""},rel(){return this.isNonHttpURI||!1===this.item.rel?null:this.item.rel?this.item.rel:this.isBlankTarget?"noopener noreferrer":null}},methods:{focusoutAction(){this.$emit("focusout")}}},r=n(14),a=Object(r.a)(s,(function(){var t=this,e=t._self._c;return t.isInternal?e("RouterLink",{staticClass:"nav-link",attrs:{to:t.link,exact:t.exact},nativeOn:{focusout:function(e){return t.focusoutAction.apply(null,arguments)}}},[t._v("\n "+t._s(t.item.text)+"\n")]):e("a",{staticClass:"nav-link external",attrs:{href:t.link,target:t.target,rel:t.rel},on:{focusout:t.focusoutAction}},[t._v("\n "+t._s(t.item.text)+"\n "),t.isBlankTarget?e("OutboundLink"):t._e()],1)}),[],!1,null,null,null);e.default=a.exports},241:function(t,e,n){"use strict";n.r(e);var i={name:"DropdownTransition",methods:{setHeight(t){t.style.height=t.scrollHeight+"px"},unsetHeight(t){t.style.height=""}}},s=(n(243),n(14)),r=Object(s.a)(i,(function(){return(0,this._self._c)("transition",{attrs:{name:"dropdown"},on:{enter:this.setHeight,"after-enter":this.unsetHeight,"before-leave":this.setHeight}},[this._t("default")],2)}),[],!1,null,null,null);e.default=r.exports},242:function(t,e,n){},243:function(t,e,n){"use strict";n(239)},246:function(t,e,n){},247:function(t,e,n){},249:function(t,e,n){},250:function(t,e,n){"use strict";n(242)},252:function(t,e,n){"use strict";n(246)},253:function(t,e,n){"use strict";n.r(e);var i=n(268),s=n(256),r=n(238);function a(t,e){if("group"===e.type){const n=e.path&&Object(r.e)(t,e.path),i=e.children.some(e=>"group"===e.type?a(t,e):"page"===e.type&&Object(r.e)(t,e.path));return n||i}return!1}var o={name:"SidebarLinks",components:{SidebarGroup:i.default,SidebarLink:s.default},props:["items","depth","sidebarDepth","initialOpenGroupIndex"],data(){return{openGroupIndex:this.initialOpenGroupIndex||0}},watch:{$route(){this.refreshIndex()}},created(){this.refreshIndex()},methods:{refreshIndex(){const t=function(t,e){for(let n=0;n-1&&(this.openGroupIndex=t)},toggleGroup(t){this.openGroupIndex=t===this.openGroupIndex?-1:t},isActive(t){return Object(r.e)(this.$route,t.regularPath)}}},l=n(14),u=Object(l.a)(o,(function(){var t=this,e=t._self._c;return t.items.length?e("ul",{staticClass:"sidebar-links"},t._l(t.items,(function(n,i){return e("li",{key:i},["group"===n.type?e("SidebarGroup",{attrs:{item:n,open:i===t.openGroupIndex,collapsable:n.collapsable||n.collapsible,depth:t.depth},on:{toggle:function(e){return t.toggleGroup(i)}}}):e("SidebarLink",{attrs:{"sidebar-depth":t.sidebarDepth,item:n}})],1)})),0):t._e()}),[],!1,null,null,null);e.default=u.exports},254:function(t,e,n){"use strict";n.r(e);var i=n(240),s=n(241),r=n(89),a=n.n(r),o={name:"DropdownLink",components:{NavLink:i.default,DropdownTransition:s.default},props:{item:{required:!0}},data:()=>({open:!1}),computed:{dropdownAriaLabel(){return this.item.ariaLabel||this.item.text}},watch:{$route(){this.open=!1}},methods:{setOpen(t){this.open=t},isLastItemOfArray:(t,e)=>a()(e)===t,handleDropdown(){0===event.detail&&this.setOpen(!this.open)}}},l=(n(250),n(14)),u=Object(l.a)(o,(function(){var t=this,e=t._self._c;return e("div",{staticClass:"dropdown-wrapper",class:{open:t.open}},[e("button",{staticClass:"dropdown-title",attrs:{type:"button","aria-label":t.dropdownAriaLabel},on:{click:t.handleDropdown}},[e("span",{staticClass:"title"},[t._v(t._s(t.item.text))]),t._v(" "),e("span",{staticClass:"arrow down"})]),t._v(" "),e("button",{staticClass:"mobile-dropdown-title",attrs:{type:"button","aria-label":t.dropdownAriaLabel},on:{click:function(e){return t.setOpen(!t.open)}}},[e("span",{staticClass:"title"},[t._v(t._s(t.item.text))]),t._v(" "),e("span",{staticClass:"arrow",class:t.open?"down":"right"})]),t._v(" "),e("DropdownTransition",[e("ul",{directives:[{name:"show",rawName:"v-show",value:t.open,expression:"open"}],staticClass:"nav-dropdown"},t._l(t.item.items,(function(n,i){return e("li",{key:n.link||i,staticClass:"dropdown-item"},["links"===n.type?e("h4",[t._v("\n "+t._s(n.text)+"\n ")]):t._e(),t._v(" "),"links"===n.type?e("ul",{staticClass:"dropdown-subitem-wrapper"},t._l(n.items,(function(i){return e("li",{key:i.link,staticClass:"dropdown-subitem"},[e("NavLink",{attrs:{item:i},on:{focusout:function(e){t.isLastItemOfArray(i,n.items)&&t.isLastItemOfArray(n,t.item.items)&&t.setOpen(!1)}}})],1)})),0):e("NavLink",{attrs:{item:n},on:{focusout:function(e){t.isLastItemOfArray(n,t.item.items)&&t.setOpen(!1)}}})],1)})),0)])],1)}),[],!1,null,null,null);e.default=u.exports},256:function(t,e,n){"use strict";n.r(e);var i=n(238);function s(t,e,n,i,s){const r={props:{to:e,activeClass:"",exactActiveClass:""},class:{active:i,"sidebar-link":!0}};return s>2&&(r.style={"padding-left":s+"rem"}),t("RouterLink",r,n)}function r(t,e,n,a,o,l=1){return!e||l>o?null:t("ul",{class:"sidebar-sub-headers"},e.map(e=>{const u=Object(i.e)(a,n+"#"+e.slug);return t("li",{class:"sidebar-sub-header"},[s(t,n+"#"+e.slug,e.title,u,e.level-1),r(t,e.children,n,a,o,l+1)])}))}var a={functional:!0,props:["item","sidebarDepth"],render(t,{parent:{$page:e,$site:n,$route:a,$themeConfig:o,$themeLocaleConfig:l},props:{item:u,sidebarDepth:c}}){const p=Object(i.e)(a,u.path),h="auto"===u.type?p||u.children.some(t=>Object(i.e)(a,u.basePath+"#"+t.slug)):p,d="external"===u.type?function(t,e,n){return t("a",{attrs:{href:e,target:"_blank",rel:"noopener noreferrer"},class:{"sidebar-link":!0}},[n,t("OutboundLink")])}(t,u.path,u.title||u.path):s(t,u.path,u.title||u.path,h),f=[e.frontmatter.sidebarDepth,c,l.sidebarDepth,o.sidebarDepth,1].find(t=>void 0!==t),m=l.displayAllHeaders||o.displayAllHeaders;if("auto"===u.type)return[d,r(t,u.children,u.basePath,a,f)];if((h||m)&&u.headers&&!i.d.test(u.path)){return[d,r(t,Object(i.c)(u.headers),u.path,a,f)]}return d}},o=(n(252),n(14)),l=Object(o.a)(a,void 0,void 0,!1,null,null,null);e.default=l.exports},260:function(t,e,n){"use strict";n(247)},265:function(t,e,n){},266:function(t,e,n){"use strict";n(249)},267:function(t,e,n){"use strict";n.r(e);var i=n(254),s=n(238),r={name:"NavLinks",components:{NavLink:n(240).default,DropdownLink:i.default},computed:{userNav(){return this.$themeLocaleConfig.nav||this.$site.themeConfig.nav||[]},nav(){const{locales:t}=this.$site;if(t&&Object.keys(t).length>1){const e=this.$page.path,n=this.$router.options.routes,i=this.$site.themeConfig.locales||{},s={text:this.$themeLocaleConfig.selectText||"Languages",ariaLabel:this.$themeLocaleConfig.ariaLabel||"Select language",items:Object.keys(t).map(s=>{const r=t[s],a=i[s]&&i[s].label||r.lang;let o;return r.lang===this.$lang?o=e:(o=e.replace(this.$localeConfig.path,s),n.some(t=>t.path===o)||(o=s)),{text:a,link:o}})};return[...this.userNav,s]}return this.userNav},userLinks(){return(this.nav||[]).map(t=>Object.assign(Object(s.j)(t),{items:(t.items||[]).map(s.j)}))},repoLink(){const{repo:t}=this.$site.themeConfig;return t?/^https?:/.test(t)?t:"https://github.com/"+t:null},repoLabel(){if(!this.repoLink)return;if(this.$site.themeConfig.repoLabel)return this.$site.themeConfig.repoLabel;const t=this.repoLink.match(/^https?:\/\/[^/]+/)[0],e=["GitHub","GitLab","Bitbucket"];for(let n=0;nfunction t(e,n,r,i=1){if("string"==typeof e)return d(n,e,r);if(Array.isArray(e))return Object.assign(d(n,e[0],r),{title:e[1]});{const a=e.children||[];return 0===a.length&&e.path?Object.assign(d(n,e.path,r),{title:e.title}):{type:"group",path:e.path,title:e.title,sidebarDepth:e.sidebarDepth,initialOpenGroupIndex:e.initialOpenGroupIndex,children:a.map(e=>t(e,n,r,i+1)),collapsable:!1!==e.collapsable}}}(t,i,n)):[]}return[]}function g(t){const e=v(t.headers||[]);return[{type:"group",collapsable:!1,title:t.title,path:null,children:e.map(e=>({type:"auto",title:e.title,basePath:t.path,path:t.path+"#"+e.slug,children:e.children||[]}))}]}function v(t){let e;return(t=t.map(t=>Object.assign({},t))).forEach(t=>{2===t.level?e=t:e&&(e.children||(e.children=[])).push(t)}),t.filter(t=>2===t.level)}function m(t){return Object.assign(t,{type:t.items&&t.items.length?"links":"link"})}},244:function(t,e,n){},245:function(t,e){t.exports=function(t){return null==t}},248:function(t,e,n){},251:function(t,e,n){"use strict";n(244)},255:function(t,e,n){"use strict";n.r(e);var r=n(245),i=n.n(r),a=n(238),s={name:"PageEdit",computed:{lastUpdated(){return this.$page.lastUpdated},lastUpdatedText(){return"string"==typeof this.$themeLocaleConfig.lastUpdated?this.$themeLocaleConfig.lastUpdated:"string"==typeof this.$site.themeConfig.lastUpdated?this.$site.themeConfig.lastUpdated:"Last Updated"},editLink(){const t=i()(this.$page.frontmatter.editLink)?this.$site.themeConfig.editLinks:this.$page.frontmatter.editLink,{repo:e,docsDir:n="",docsBranch:r="master",docsRepo:a=e}=this.$site.themeConfig;return"string"==typeof t?t:t&&a&&this.$page.relativePath?this.createEditLink(e,a,n,r,this.$page.relativePath):null},editLinkText(){return this.$themeLocaleConfig.editLinkText||this.$site.themeConfig.editLinkText||"Edit this page"}},methods:{createEditLink(t,e,n,r,i){if(/bitbucket.org/.test(e)){return e.replace(a.a,"")+"/src"+`/${r}/`+(n?n.replace(a.a,"")+"/":"")+i+`?mode=edit&spa=0&at=${r}&fileviewer=file-view-default`}if(/gitlab.com/.test(e)){return e.replace(a.a,"")+"/-/edit"+`/${r}/`+(n?n.replace(a.a,"")+"/":"")+i}return(a.i.test(e)?e:"https://github.com/"+e).replace(a.a,"")+"/edit"+`/${r}/`+(n?n.replace(a.a,"")+"/":"")+i}}},o=(n(251),n(14)),u=Object(o.a)(s,(function(){var t=this,e=t._self._c;return e("footer",{staticClass:"page-edit"},[t.editLink?e("div",{staticClass:"edit-link"},[e("a",{attrs:{href:t.editLink,target:"_blank",rel:"noopener noreferrer"}},[t._v(t._s(t.editLinkText))]),t._v(" "),e("OutboundLink")],1):t._e(),t._v(" "),t.lastUpdated?e("div",{staticClass:"last-updated"},[e("span",{staticClass:"prefix"},[t._v(t._s(t.lastUpdatedText)+":")]),t._v(" "),e("span",{staticClass:"time"},[t._v(t._s(t.lastUpdated))])]):t._e()])}),[],!1,null,null,null);e.default=u.exports},262:function(t,e,n){},263:function(t,e,n){"use strict";n(248)},264:function(t,e,n){var r=n(11),i=n(4),a=n(10);t.exports=function(t){return"string"==typeof t||!i(t)&&a(t)&&"[object String]"==r(t)}},269:function(t,e,n){"use strict";n.r(e);n(88);var r=n(238),i=n(264),a=n.n(i),s=n(245),o=n.n(s),u={name:"PageNav",props:["sidebarItems"],computed:{prev(){return l(c.PREV,this)},next(){return l(c.NEXT,this)}}};const c={NEXT:{resolveLink:function(t,e){return p(t,e,1)},getThemeLinkConfig:({nextLinks:t})=>t,getPageLinkConfig:({frontmatter:t})=>t.next},PREV:{resolveLink:function(t,e){return p(t,e,-1)},getThemeLinkConfig:({prevLinks:t})=>t,getPageLinkConfig:({frontmatter:t})=>t.prev}};function l(t,{$themeConfig:e,$page:n,$route:i,$site:s,sidebarItems:u}){const{resolveLink:c,getThemeLinkConfig:l,getPageLinkConfig:p}=t,f=l(e),d=p(n),h=o()(d)?f:d;return!1===h?void 0:a()(h)?Object(r.k)(s.pages,h,i.path):c(n,u)}function p(t,e,n){const r=[];!function t(e,n){for(let r=0,i=e.length;rfunction t(e,n,i,s=1){if("string"==typeof e)return f(n,e,i);if(Array.isArray(e))return Object.assign(f(n,e[0],i),{title:e[1]});{const r=e.children||[];return 0===r.length&&e.path?Object.assign(f(n,e.path,i),{title:e.title}):{type:"group",path:e.path,title:e.title,sidebarDepth:e.sidebarDepth,initialOpenGroupIndex:e.initialOpenGroupIndex,children:r.map(e=>t(e,n,i,s+1)),collapsable:!1!==e.collapsable}}}(t,s,n)):[]}return[]}function m(t){const e=g(t.headers||[]);return[{type:"group",collapsable:!1,title:t.title,path:null,children:e.map(e=>({type:"auto",title:e.title,basePath:t.path,path:t.path+"#"+e.slug,children:e.children||[]}))}]}function g(t){let e;return(t=t.map(t=>Object.assign({},t))).forEach(t=>{2===t.level?e=t:e&&(e.children||(e.children=[])).push(t)}),t.filter(t=>2===t.level)}function b(t){return Object.assign(t,{type:t.items&&t.items.length?"links":"link"})}},239:function(t,e,n){},240:function(t,e,n){"use strict";n.r(e);var i=n(238),s={name:"NavLink",props:{item:{required:!0}},computed:{link(){return Object(i.b)(this.item.link)},exact(){return this.$site.locales?Object.keys(this.$site.locales).some(t=>t===this.link):"/"===this.link},isNonHttpURI(){return Object(i.g)(this.link)||Object(i.h)(this.link)},isBlankTarget(){return"_blank"===this.target},isInternal(){return!Object(i.f)(this.link)&&!this.isBlankTarget},target(){return this.isNonHttpURI?null:this.item.target?this.item.target:Object(i.f)(this.link)?"_blank":""},rel(){return this.isNonHttpURI||!1===this.item.rel?null:this.item.rel?this.item.rel:this.isBlankTarget?"noopener noreferrer":null}},methods:{focusoutAction(){this.$emit("focusout")}}},r=n(14),a=Object(r.a)(s,(function(){var t=this,e=t._self._c;return t.isInternal?e("RouterLink",{staticClass:"nav-link",attrs:{to:t.link,exact:t.exact},nativeOn:{focusout:function(e){return t.focusoutAction.apply(null,arguments)}}},[t._v("\n "+t._s(t.item.text)+"\n")]):e("a",{staticClass:"nav-link external",attrs:{href:t.link,target:t.target,rel:t.rel},on:{focusout:t.focusoutAction}},[t._v("\n "+t._s(t.item.text)+"\n "),t.isBlankTarget?e("OutboundLink"):t._e()],1)}),[],!1,null,null,null);e.default=a.exports},241:function(t,e,n){"use strict";n.r(e);var i={name:"DropdownTransition",methods:{setHeight(t){t.style.height=t.scrollHeight+"px"},unsetHeight(t){t.style.height=""}}},s=(n(243),n(14)),r=Object(s.a)(i,(function(){return(0,this._self._c)("transition",{attrs:{name:"dropdown"},on:{enter:this.setHeight,"after-enter":this.unsetHeight,"before-leave":this.setHeight}},[this._t("default")],2)}),[],!1,null,null,null);e.default=r.exports},242:function(t,e,n){},243:function(t,e,n){"use strict";n(239)},247:function(t,e,n){},250:function(t,e,n){"use strict";n(242)},254:function(t,e,n){"use strict";n.r(e);var i=n(240),s=n(241),r=n(89),a=n.n(r),o={name:"DropdownLink",components:{NavLink:i.default,DropdownTransition:s.default},props:{item:{required:!0}},data:()=>({open:!1}),computed:{dropdownAriaLabel(){return this.item.ariaLabel||this.item.text}},watch:{$route(){this.open=!1}},methods:{setOpen(t){this.open=t},isLastItemOfArray:(t,e)=>a()(e)===t,handleDropdown(){0===event.detail&&this.setOpen(!this.open)}}},l=(n(250),n(14)),u=Object(l.a)(o,(function(){var t=this,e=t._self._c;return e("div",{staticClass:"dropdown-wrapper",class:{open:t.open}},[e("button",{staticClass:"dropdown-title",attrs:{type:"button","aria-label":t.dropdownAriaLabel},on:{click:t.handleDropdown}},[e("span",{staticClass:"title"},[t._v(t._s(t.item.text))]),t._v(" "),e("span",{staticClass:"arrow down"})]),t._v(" "),e("button",{staticClass:"mobile-dropdown-title",attrs:{type:"button","aria-label":t.dropdownAriaLabel},on:{click:function(e){return t.setOpen(!t.open)}}},[e("span",{staticClass:"title"},[t._v(t._s(t.item.text))]),t._v(" "),e("span",{staticClass:"arrow",class:t.open?"down":"right"})]),t._v(" "),e("DropdownTransition",[e("ul",{directives:[{name:"show",rawName:"v-show",value:t.open,expression:"open"}],staticClass:"nav-dropdown"},t._l(t.item.items,(function(n,i){return e("li",{key:n.link||i,staticClass:"dropdown-item"},["links"===n.type?e("h4",[t._v("\n "+t._s(n.text)+"\n ")]):t._e(),t._v(" "),"links"===n.type?e("ul",{staticClass:"dropdown-subitem-wrapper"},t._l(n.items,(function(i){return e("li",{key:i.link,staticClass:"dropdown-subitem"},[e("NavLink",{attrs:{item:i},on:{focusout:function(e){t.isLastItemOfArray(i,n.items)&&t.isLastItemOfArray(n,t.item.items)&&t.setOpen(!1)}}})],1)})),0):e("NavLink",{attrs:{item:n},on:{focusout:function(e){t.isLastItemOfArray(n,t.item.items)&&t.setOpen(!1)}}})],1)})),0)])],1)}),[],!1,null,null,null);e.default=u.exports},260:function(t,e,n){"use strict";n(247)},267:function(t,e,n){"use strict";n.r(e);var i=n(254),s=n(238),r={name:"NavLinks",components:{NavLink:n(240).default,DropdownLink:i.default},computed:{userNav(){return this.$themeLocaleConfig.nav||this.$site.themeConfig.nav||[]},nav(){const{locales:t}=this.$site;if(t&&Object.keys(t).length>1){const e=this.$page.path,n=this.$router.options.routes,i=this.$site.themeConfig.locales||{},s={text:this.$themeLocaleConfig.selectText||"Languages",ariaLabel:this.$themeLocaleConfig.ariaLabel||"Select language",items:Object.keys(t).map(s=>{const r=t[s],a=i[s]&&i[s].label||r.lang;let o;return r.lang===this.$lang?o=e:(o=e.replace(this.$localeConfig.path,s),n.some(t=>t.path===o)||(o=s)),{text:a,link:o}})};return[...this.userNav,s]}return this.userNav},userLinks(){return(this.nav||[]).map(t=>Object.assign(Object(s.j)(t),{items:(t.items||[]).map(s.j)}))},repoLink(){const{repo:t}=this.$site.themeConfig;return t?/^https?:/.test(t)?t:"https://github.com/"+t:null},repoLabel(){if(!this.repoLink)return;if(this.$site.themeConfig.repoLabel)return this.$site.themeConfig.repoLabel;const t=this.repoLink.match(/^https?:\/\/[^/]+/)[0],e=["GitHub","GitLab","Bitbucket"];for(let n=0;nfunction t(e,n,i,r=1){if("string"==typeof e)return f(n,e,i);if(Array.isArray(e))return Object.assign(f(n,e[0],i),{title:e[1]});{const a=e.children||[];return 0===a.length&&e.path?Object.assign(f(n,e.path,i),{title:e.title}):{type:"group",path:e.path,title:e.title,sidebarDepth:e.sidebarDepth,initialOpenGroupIndex:e.initialOpenGroupIndex,children:a.map(e=>t(e,n,i,r+1)),collapsable:!1!==e.collapsable}}}(t,r,n)):[]}return[]}function g(t){const e=m(t.headers||[]);return[{type:"group",collapsable:!1,title:t.title,path:null,children:e.map(e=>({type:"auto",title:e.title,basePath:t.path,path:t.path+"#"+e.slug,children:e.children||[]}))}]}function m(t){let e;return(t=t.map(t=>Object.assign({},t))).forEach(t=>{2===t.level?e=t:e&&(e.children||(e.children=[])).push(t)}),t.filter(t=>2===t.level)}function b(t){return Object.assign(t,{type:t.items&&t.items.length?"links":"link"})}},244:function(t,e,n){},245:function(t,e){t.exports=function(t){return null==t}},251:function(t,e,n){"use strict";n(244)},255:function(t,e,n){"use strict";n.r(e);var i=n(245),r=n.n(i),a=n(238),s={name:"PageEdit",computed:{lastUpdated(){return this.$page.lastUpdated},lastUpdatedText(){return"string"==typeof this.$themeLocaleConfig.lastUpdated?this.$themeLocaleConfig.lastUpdated:"string"==typeof this.$site.themeConfig.lastUpdated?this.$site.themeConfig.lastUpdated:"Last Updated"},editLink(){const t=r()(this.$page.frontmatter.editLink)?this.$site.themeConfig.editLinks:this.$page.frontmatter.editLink,{repo:e,docsDir:n="",docsBranch:i="master",docsRepo:a=e}=this.$site.themeConfig;return"string"==typeof t?t:t&&a&&this.$page.relativePath?this.createEditLink(e,a,n,i,this.$page.relativePath):null},editLinkText(){return this.$themeLocaleConfig.editLinkText||this.$site.themeConfig.editLinkText||"Edit this page"}},methods:{createEditLink(t,e,n,i,r){if(/bitbucket.org/.test(e)){return e.replace(a.a,"")+"/src"+`/${i}/`+(n?n.replace(a.a,"")+"/":"")+r+`?mode=edit&spa=0&at=${i}&fileviewer=file-view-default`}if(/gitlab.com/.test(e)){return e.replace(a.a,"")+"/-/edit"+`/${i}/`+(n?n.replace(a.a,"")+"/":"")+r}return(a.i.test(e)?e:"https://github.com/"+e).replace(a.a,"")+"/edit"+`/${i}/`+(n?n.replace(a.a,"")+"/":"")+r}}},o=(n(251),n(14)),c=Object(o.a)(s,(function(){var t=this,e=t._self._c;return e("footer",{staticClass:"page-edit"},[t.editLink?e("div",{staticClass:"edit-link"},[e("a",{attrs:{href:t.editLink,target:"_blank",rel:"noopener noreferrer"}},[t._v(t._s(t.editLinkText))]),t._v(" "),e("OutboundLink")],1):t._e(),t._v(" "),t.lastUpdated?e("div",{staticClass:"last-updated"},[e("span",{staticClass:"prefix"},[t._v(t._s(t.lastUpdatedText)+":")]),t._v(" "),e("span",{staticClass:"time"},[t._v(t._s(t.lastUpdated))])]):t._e()])}),[],!1,null,null,null);e.default=c.exports},300:function(t,e,n){},372:function(t,e,n){"use strict";n(300)},468:function(t,e,n){"use strict";n.r(e);var i={components:{PageEdit:n(255).default}},r=(n(372),n(14)),a=Object(r.a)(i,(function(){var t=this,e=t._self._c;return e("main",{staticClass:"page"},[t._t("top"),t._v(" "),e("div",{staticClass:"theme-default-content",staticStyle:{"padding-bottom":"0px"}},[e("h1",[t._v(t._s(t.$page.frontmatter.title))]),t._v(" "),e("NewsPostMeta",{attrs:{date:t.$page.frontmatter.date}})],1),t._v(" "),e("Content",{staticClass:"theme-default-content",staticStyle:{"padding-top":"0px"}}),t._v(" "),e("PageEdit"),t._v(" "),t._t("bottom")],2)}),[],!1,null,"22624a70",null);e.default=a.exports}}]); \ No newline at end of file diff --git a/assets/js/15.c26b92ae.js b/assets/js/15.c26b92ae.js new file mode 100644 index 000000000..a854110f8 --- /dev/null +++ b/assets/js/15.c26b92ae.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[15],{280:function(e,t,a){},281:function(e,t,a){"use strict";var i=TypeError;e.exports=function(e,t){if(e({placeholder:void 0}),watch:{$lang(e){this.update(this.options,e)},options(e){this.update(e,this.$lang)}},mounted(){this.initialize(this.options,this.$lang),this.placeholder=this.$site.themeConfig.searchPlaceholder||""},methods:{initialize(e,t){Promise.all([Promise.all([a.e(0),a.e(9)]).then(a.t.bind(null,452,7)),Promise.all([a.e(0),a.e(9)]).then(a.t.bind(null,453,7))]).then(([a])=>{a=a.default;const{algoliaOptions:i={}}=e;a(Object.assign({},e,{inputSelector:"#algolia-search-input",algoliaOptions:{...i,facetFilters:["lang:"+t].concat(i.facetFilters||[])},handleSelected:(e,t,a)=>{const{pathname:i,hash:n}=new URL(a.url),r=i.replace(this.$site.base,"/"),s=decodeURIComponent(n);this.$router.push(`${r}${s}`)}}))})},update(e,t){this.$el.innerHTML='',this.initialize(e,t)}}},n=(a(315),a(14)),r=Object(n.a)(i,(function(){var e=this._self._c;return e("form",{staticClass:"algolia-search-wrapper search-box",attrs:{id:"search-form",role:"search"}},[e("input",{staticClass:"search-query",attrs:{id:"algolia-search-input",placeholder:this.placeholder}})])}),[],!1,null,null,null);t.default=r.exports}}]); \ No newline at end of file diff --git a/assets/js/16.eee19255.js b/assets/js/16.eee19255.js new file mode 100644 index 000000000..c2cb340e9 --- /dev/null +++ b/assets/js/16.eee19255.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[16,40,42],{238:function(t,e,n){"use strict";n.d(e,"d",(function(){return i})),n.d(e,"a",(function(){return s})),n.d(e,"i",(function(){return o})),n.d(e,"f",(function(){return l})),n.d(e,"g",(function(){return u})),n.d(e,"h",(function(){return c})),n.d(e,"b",(function(){return p})),n.d(e,"e",(function(){return f})),n.d(e,"k",(function(){return h})),n.d(e,"l",(function(){return d})),n.d(e,"c",(function(){return b})),n.d(e,"j",(function(){return g}));n(88);const i=/#.*$/,r=/\.(md|html)$/,s=/\/$/,o=/^[a-z]+:/i;function a(t){return decodeURI(t).replace(i,"").replace(r,"")}function l(t){return o.test(t)}function u(t){return/^mailto:/.test(t)}function c(t){return/^tel:/.test(t)}function p(t){if(l(t))return t;const e=t.match(i),n=e?e[0]:"",r=a(t);return s.test(r)?t:r+".html"+n}function f(t,e){const n=decodeURIComponent(t.hash),r=function(t){const e=t.match(i);if(e)return e[0]}(e);if(r&&n!==r)return!1;return a(t.path)===a(e)}function h(t,e,n){if(l(e))return{type:"external",path:e};n&&(e=function(t,e,n){const i=t.charAt(0);if("/"===i)return t;if("?"===i||"#"===i)return e+t;const r=e.split("/");n&&r[r.length-1]||r.pop();const s=t.replace(/^\//,"").split("/");for(let t=0;tfunction t(e,n,i,r=1){if("string"==typeof e)return h(n,e,i);if(Array.isArray(e))return Object.assign(h(n,e[0],i),{title:e[1]});{const s=e.children||[];return 0===s.length&&e.path?Object.assign(h(n,e.path,i),{title:e.title}):{type:"group",path:e.path,title:e.title,sidebarDepth:e.sidebarDepth,initialOpenGroupIndex:e.initialOpenGroupIndex,children:s.map(e=>t(e,n,i,r+1)),collapsable:!1!==e.collapsable}}}(t,r,n)):[]}return[]}function m(t){const e=b(t.headers||[]);return[{type:"group",collapsable:!1,title:t.title,path:null,children:e.map(e=>({type:"auto",title:e.title,basePath:t.path,path:t.path+"#"+e.slug,children:e.children||[]}))}]}function b(t){let e;return(t=t.map(t=>Object.assign({},t))).forEach(t=>{2===t.level?e=t:e&&(e.children||(e.children=[])).push(t)}),t.filter(t=>2===t.level)}function g(t){return Object.assign(t,{type:t.items&&t.items.length?"links":"link"})}},239:function(t,e,n){},240:function(t,e,n){"use strict";n.r(e);var i=n(238),r={name:"NavLink",props:{item:{required:!0}},computed:{link(){return Object(i.b)(this.item.link)},exact(){return this.$site.locales?Object.keys(this.$site.locales).some(t=>t===this.link):"/"===this.link},isNonHttpURI(){return Object(i.g)(this.link)||Object(i.h)(this.link)},isBlankTarget(){return"_blank"===this.target},isInternal(){return!Object(i.f)(this.link)&&!this.isBlankTarget},target(){return this.isNonHttpURI?null:this.item.target?this.item.target:Object(i.f)(this.link)?"_blank":""},rel(){return this.isNonHttpURI||!1===this.item.rel?null:this.item.rel?this.item.rel:this.isBlankTarget?"noopener noreferrer":null}},methods:{focusoutAction(){this.$emit("focusout")}}},s=n(14),o=Object(s.a)(r,(function(){var t=this,e=t._self._c;return t.isInternal?e("RouterLink",{staticClass:"nav-link",attrs:{to:t.link,exact:t.exact},nativeOn:{focusout:function(e){return t.focusoutAction.apply(null,arguments)}}},[t._v("\n "+t._s(t.item.text)+"\n")]):e("a",{staticClass:"nav-link external",attrs:{href:t.link,target:t.target,rel:t.rel},on:{focusout:t.focusoutAction}},[t._v("\n "+t._s(t.item.text)+"\n "),t.isBlankTarget?e("OutboundLink"):t._e()],1)}),[],!1,null,null,null);e.default=o.exports},241:function(t,e,n){"use strict";n.r(e);var i={name:"DropdownTransition",methods:{setHeight(t){t.style.height=t.scrollHeight+"px"},unsetHeight(t){t.style.height=""}}},r=(n(243),n(14)),s=Object(r.a)(i,(function(){return(0,this._self._c)("transition",{attrs:{name:"dropdown"},on:{enter:this.setHeight,"after-enter":this.unsetHeight,"before-leave":this.setHeight}},[this._t("default")],2)}),[],!1,null,null,null);e.default=s.exports},242:function(t,e,n){},243:function(t,e,n){"use strict";n(239)},250:function(t,e,n){"use strict";n(242)},254:function(t,e,n){"use strict";n.r(e);var i=n(240),r=n(241),s=n(89),o=n.n(s),a={name:"DropdownLink",components:{NavLink:i.default,DropdownTransition:r.default},props:{item:{required:!0}},data:()=>({open:!1}),computed:{dropdownAriaLabel(){return this.item.ariaLabel||this.item.text}},watch:{$route(){this.open=!1}},methods:{setOpen(t){this.open=t},isLastItemOfArray:(t,e)=>o()(e)===t,handleDropdown(){0===event.detail&&this.setOpen(!this.open)}}},l=(n(250),n(14)),u=Object(l.a)(a,(function(){var t=this,e=t._self._c;return e("div",{staticClass:"dropdown-wrapper",class:{open:t.open}},[e("button",{staticClass:"dropdown-title",attrs:{type:"button","aria-label":t.dropdownAriaLabel},on:{click:t.handleDropdown}},[e("span",{staticClass:"title"},[t._v(t._s(t.item.text))]),t._v(" "),e("span",{staticClass:"arrow down"})]),t._v(" "),e("button",{staticClass:"mobile-dropdown-title",attrs:{type:"button","aria-label":t.dropdownAriaLabel},on:{click:function(e){return t.setOpen(!t.open)}}},[e("span",{staticClass:"title"},[t._v(t._s(t.item.text))]),t._v(" "),e("span",{staticClass:"arrow",class:t.open?"down":"right"})]),t._v(" "),e("DropdownTransition",[e("ul",{directives:[{name:"show",rawName:"v-show",value:t.open,expression:"open"}],staticClass:"nav-dropdown"},t._l(t.item.items,(function(n,i){return e("li",{key:n.link||i,staticClass:"dropdown-item"},["links"===n.type?e("h4",[t._v("\n "+t._s(n.text)+"\n ")]):t._e(),t._v(" "),"links"===n.type?e("ul",{staticClass:"dropdown-subitem-wrapper"},t._l(n.items,(function(i){return e("li",{key:i.link,staticClass:"dropdown-subitem"},[e("NavLink",{attrs:{item:i},on:{focusout:function(e){t.isLastItemOfArray(i,n.items)&&t.isLastItemOfArray(n,t.item.items)&&t.setOpen(!1)}}})],1)})),0):e("NavLink",{attrs:{item:n},on:{focusout:function(e){t.isLastItemOfArray(n,t.item.items)&&t.setOpen(!1)}}})],1)})),0)])],1)}),[],!1,null,null,null);e.default=u.exports}}]); \ No newline at end of file diff --git a/assets/js/17.110836e8.js b/assets/js/17.110836e8.js new file mode 100644 index 000000000..db50cf7cc --- /dev/null +++ b/assets/js/17.110836e8.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[17],{238:function(t,n,e){"use strict";e.d(n,"d",(function(){return r})),e.d(n,"a",(function(){return o})),e.d(n,"i",(function(){return a})),e.d(n,"f",(function(){return u})),e.d(n,"g",(function(){return c})),e.d(n,"h",(function(){return p})),e.d(n,"b",(function(){return l})),e.d(n,"e",(function(){return f})),e.d(n,"k",(function(){return h})),e.d(n,"l",(function(){return d})),e.d(n,"c",(function(){return v})),e.d(n,"j",(function(){return b}));e(88);const r=/#.*$/,i=/\.(md|html)$/,o=/\/$/,a=/^[a-z]+:/i;function s(t){return decodeURI(t).replace(r,"").replace(i,"")}function u(t){return a.test(t)}function c(t){return/^mailto:/.test(t)}function p(t){return/^tel:/.test(t)}function l(t){if(u(t))return t;const n=t.match(r),e=n?n[0]:"",i=s(t);return o.test(i)?t:i+".html"+e}function f(t,n){const e=decodeURIComponent(t.hash),i=function(t){const n=t.match(r);if(n)return n[0]}(n);if(i&&e!==i)return!1;return s(t.path)===s(n)}function h(t,n,e){if(u(n))return{type:"external",path:n};e&&(n=function(t,n,e){const r=t.charAt(0);if("/"===r)return t;if("?"===r||"#"===r)return n+t;const i=n.split("/");e&&i[i.length-1]||i.pop();const o=t.replace(/^\//,"").split("/");for(let t=0;tfunction t(n,e,r,i=1){if("string"==typeof n)return h(e,n,r);if(Array.isArray(n))return Object.assign(h(e,n[0],r),{title:n[1]});{const o=n.children||[];return 0===o.length&&n.path?Object.assign(h(e,n.path,r),{title:n.title}):{type:"group",path:n.path,title:n.title,sidebarDepth:n.sidebarDepth,initialOpenGroupIndex:n.initialOpenGroupIndex,children:o.map(n=>t(n,e,r,i+1)),collapsable:!1!==n.collapsable}}}(t,i,e)):[]}return[]}function g(t){const n=v(t.headers||[]);return[{type:"group",collapsable:!1,title:t.title,path:null,children:n.map(n=>({type:"auto",title:n.title,basePath:t.path,path:t.path+"#"+n.slug,children:n.children||[]}))}]}function v(t){let n;return(t=t.map(t=>Object.assign({},t))).forEach(t=>{2===t.level?n=t:n&&(n.children||(n.children=[])).push(t)}),t.filter(t=>2===t.level)}function b(t){return Object.assign(t,{type:t.items&&t.items.length?"links":"link"})}},245:function(t,n){t.exports=function(t){return null==t}},248:function(t,n,e){},263:function(t,n,e){"use strict";e(248)},264:function(t,n,e){var r=e(11),i=e(4),o=e(10);t.exports=function(t){return"string"==typeof t||!i(t)&&o(t)&&"[object String]"==r(t)}},269:function(t,n,e){"use strict";e.r(n);e(88);var r=e(238),i=e(264),o=e.n(i),a=e(245),s=e.n(a),u={name:"PageNav",props:["sidebarItems"],computed:{prev(){return p(c.PREV,this)},next(){return p(c.NEXT,this)}}};const c={NEXT:{resolveLink:function(t,n){return l(t,n,1)},getThemeLinkConfig:({nextLinks:t})=>t,getPageLinkConfig:({frontmatter:t})=>t.next},PREV:{resolveLink:function(t,n){return l(t,n,-1)},getThemeLinkConfig:({prevLinks:t})=>t,getPageLinkConfig:({frontmatter:t})=>t.prev}};function p(t,{$themeConfig:n,$page:e,$route:i,$site:a,sidebarItems:u}){const{resolveLink:c,getThemeLinkConfig:p,getPageLinkConfig:l}=t,f=p(n),h=l(e),d=s()(h)?f:h;return!1===d?void 0:o()(d)?Object(r.k)(a.pages,d,i.path):c(e,u)}function l(t,n,e){const r=[];!function t(n,e){for(let r=0,i=n.length;r=e?t:""+Array(e+1-r.length).join(n)+t},D={s:m,z:function(t){var e=-t.utcOffset(),n=Math.abs(e),r=Math.floor(n/60),s=n%60;return(e<=0?"+":"-")+m(r,2,"0")+":"+m(s,2,"0")},m:function t(e,n){if(e.date()1)return t(u[0])}else{var a=e.name;g[a]=e,s=a}return!r&&s&&(M=s),s||!r&&M},O=function(t,e){if(y(t))return t.clone();var n="object"==typeof e?e:{};return n.date=t,n.args=arguments,new b(n)},w=D;w.l=S,w.i=y,w.w=function(t,e){return O(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var b=function(){function v(t){this.$L=S(t.locale,null,!0),this.parse(t),this.$x=this.$x||t.x||{},this[p]=!0}var m=v.prototype;return m.parse=function(t){this.$d=function(t){var e=t.date,n=t.utc;if(null===e)return new Date(NaN);if(w.u(e))return new Date;if(e instanceof Date)return new Date(e);if("string"==typeof e&&!/Z$/i.test(e)){var r=e.match(d);if(r){var s=r[2]-1||0,i=(r[7]||"0").substring(0,3);return n?new Date(Date.UTC(r[1],s,r[3]||1,r[4]||0,r[5]||0,r[6]||0,i)):new Date(r[1],s,r[3]||1,r[4]||0,r[5]||0,r[6]||0,i)}}return new Date(e)}(t),this.init()},m.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds()},m.$utils=function(){return w},m.isValid=function(){return!(this.$d.toString()===l)},m.isSame=function(t,e){var n=O(t);return this.startOf(e)<=n&&n<=this.endOf(e)},m.isAfter=function(t,e){return O(t)function t(e,n,i,r=1){if("string"==typeof e)return d(n,e,i);if(Array.isArray(e))return Object.assign(d(n,e[0],i),{title:e[1]});{const a=e.children||[];return 0===a.length&&e.path?Object.assign(d(n,e.path,i),{title:e.title}):{type:"group",path:e.path,title:e.title,sidebarDepth:e.sidebarDepth,initialOpenGroupIndex:e.initialOpenGroupIndex,children:a.map(e=>t(e,n,i,r+1)),collapsable:!1!==e.collapsable}}}(t,r,n)):[]}return[]}function m(t){const e=g(t.headers||[]);return[{type:"group",collapsable:!1,title:t.title,path:null,children:e.map(e=>({type:"auto",title:e.title,basePath:t.path,path:t.path+"#"+e.slug,children:e.children||[]}))}]}function g(t){let e;return(t=t.map(t=>Object.assign({},t))).forEach(t=>{2===t.level?e=t:e&&(e.children||(e.children=[])).push(t)}),t.filter(t=>2===t.level)}function b(t){return Object.assign(t,{type:t.items&&t.items.length?"links":"link"})}},240:function(t,e,n){"use strict";n.r(e);var i=n(238),r={name:"NavLink",props:{item:{required:!0}},computed:{link(){return Object(i.b)(this.item.link)},exact(){return this.$site.locales?Object.keys(this.$site.locales).some(t=>t===this.link):"/"===this.link},isNonHttpURI(){return Object(i.g)(this.link)||Object(i.h)(this.link)},isBlankTarget(){return"_blank"===this.target},isInternal(){return!Object(i.f)(this.link)&&!this.isBlankTarget},target(){return this.isNonHttpURI?null:this.item.target?this.item.target:Object(i.f)(this.link)?"_blank":""},rel(){return this.isNonHttpURI||!1===this.item.rel?null:this.item.rel?this.item.rel:this.isBlankTarget?"noopener noreferrer":null}},methods:{focusoutAction(){this.$emit("focusout")}}},a=n(14),s=Object(a.a)(r,(function(){var t=this,e=t._self._c;return t.isInternal?e("RouterLink",{staticClass:"nav-link",attrs:{to:t.link,exact:t.exact},nativeOn:{focusout:function(e){return t.focusoutAction.apply(null,arguments)}}},[t._v("\n "+t._s(t.item.text)+"\n")]):e("a",{staticClass:"nav-link external",attrs:{href:t.link,target:t.target,rel:t.rel},on:{focusout:t.focusoutAction}},[t._v("\n "+t._s(t.item.text)+"\n "),t.isBlankTarget?e("OutboundLink"):t._e()],1)}),[],!1,null,null,null);e.default=s.exports},259:function(t,e,n){},272:function(t,e,n){"use strict";n(259)},307:function(t,e,n){"use strict";n.r(e);var i={name:"Home",components:{NavLink:n(240).default},computed:{data(){return this.$page.frontmatter},actionLink(){return{link:this.data.actionLink,text:this.data.actionText}}}},r=(n(272),n(14)),a=Object(r.a)(i,(function(){var t=this,e=t._self._c;return e("main",{staticClass:"home",attrs:{"aria-labelledby":null!==t.data.heroText?"main-title":null}},[e("header",{staticClass:"hero"},[t.data.heroImage?e("img",{attrs:{src:t.$withBase(t.data.heroImage),alt:t.data.heroAlt||"hero"}}):t._e(),t._v(" "),null!==t.data.heroText?e("h1",{attrs:{id:"main-title"}},[t._v("\n "+t._s(t.data.heroText||t.$title||"Hello")+"\n ")]):t._e(),t._v(" "),null!==t.data.tagline?e("p",{staticClass:"description"},[t._v("\n "+t._s(t.data.tagline||t.$description||"Welcome to your VuePress site")+"\n ")]):t._e(),t._v(" "),t.data.actionText&&t.data.actionLink?e("p",{staticClass:"action"},[e("NavLink",{staticClass:"action-button",attrs:{item:t.actionLink}})],1):t._e()]),t._v(" "),t.data.features&&t.data.features.length?e("div",{staticClass:"features"},t._l(t.data.features,(function(n,i){return e("div",{key:i,staticClass:"feature"},[e("h2",[t._v(t._s(n.title))]),t._v(" "),e("p",[t._v(t._s(n.details))])])})),0):t._e(),t._v(" "),e("Content",{staticClass:"theme-default-content custom"}),t._v(" "),t.data.footer?e("div",{staticClass:"footer"},[t._v("\n "+t._s(t.data.footer)+"\n ")]):t._e()],1)}),[],!1,null,null,null);e.default=a.exports}}]); \ No newline at end of file diff --git a/assets/js/2.c2b5d71e.js b/assets/js/2.c2b5d71e.js new file mode 100644 index 000000000..9c5b2da01 --- /dev/null +++ b/assets/js/2.c2b5d71e.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[2],{244:function(t,e,a){},245:function(t,e){t.exports=function(t){return null==t}},246:function(t,e,a){},248:function(t,e,a){},249:function(t,e,a){},251:function(t,e,a){"use strict";a(244)},252:function(t,e,a){"use strict";a(246)},253:function(t,e,a){"use strict";a.r(e);var n=a(268),s=a(256),i=a(238);function r(t,e){if("group"===e.type){const a=e.path&&Object(i.e)(t,e.path),n=e.children.some(e=>"group"===e.type?r(t,e):"page"===e.type&&Object(i.e)(t,e.path));return a||n}return!1}var o={name:"SidebarLinks",components:{SidebarGroup:n.default,SidebarLink:s.default},props:["items","depth","sidebarDepth","initialOpenGroupIndex"],data(){return{openGroupIndex:this.initialOpenGroupIndex||0}},watch:{$route(){this.refreshIndex()}},created(){this.refreshIndex()},methods:{refreshIndex(){const t=function(t,e){for(let a=0;a-1&&(this.openGroupIndex=t)},toggleGroup(t){this.openGroupIndex=t===this.openGroupIndex?-1:t},isActive(t){return Object(i.e)(this.$route,t.regularPath)}}},l=a(14),u=Object(l.a)(o,(function(){var t=this,e=t._self._c;return t.items.length?e("ul",{staticClass:"sidebar-links"},t._l(t.items,(function(a,n){return e("li",{key:n},["group"===a.type?e("SidebarGroup",{attrs:{item:a,open:n===t.openGroupIndex,collapsable:a.collapsable||a.collapsible,depth:t.depth},on:{toggle:function(e){return t.toggleGroup(n)}}}):e("SidebarLink",{attrs:{"sidebar-depth":t.sidebarDepth,item:a}})],1)})),0):t._e()}),[],!1,null,null,null);e.default=u.exports},255:function(t,e,a){"use strict";a.r(e);var n=a(245),s=a.n(n),i=a(238),r={name:"PageEdit",computed:{lastUpdated(){return this.$page.lastUpdated},lastUpdatedText(){return"string"==typeof this.$themeLocaleConfig.lastUpdated?this.$themeLocaleConfig.lastUpdated:"string"==typeof this.$site.themeConfig.lastUpdated?this.$site.themeConfig.lastUpdated:"Last Updated"},editLink(){const t=s()(this.$page.frontmatter.editLink)?this.$site.themeConfig.editLinks:this.$page.frontmatter.editLink,{repo:e,docsDir:a="",docsBranch:n="master",docsRepo:i=e}=this.$site.themeConfig;return"string"==typeof t?t:t&&i&&this.$page.relativePath?this.createEditLink(e,i,a,n,this.$page.relativePath):null},editLinkText(){return this.$themeLocaleConfig.editLinkText||this.$site.themeConfig.editLinkText||"Edit this page"}},methods:{createEditLink(t,e,a,n,s){if(/bitbucket.org/.test(e)){return e.replace(i.a,"")+"/src"+`/${n}/`+(a?a.replace(i.a,"")+"/":"")+s+`?mode=edit&spa=0&at=${n}&fileviewer=file-view-default`}if(/gitlab.com/.test(e)){return e.replace(i.a,"")+"/-/edit"+`/${n}/`+(a?a.replace(i.a,"")+"/":"")+s}return(i.i.test(e)?e:"https://github.com/"+e).replace(i.a,"")+"/edit"+`/${n}/`+(a?a.replace(i.a,"")+"/":"")+s}}},o=(a(251),a(14)),l=Object(o.a)(r,(function(){var t=this,e=t._self._c;return e("footer",{staticClass:"page-edit"},[t.editLink?e("div",{staticClass:"edit-link"},[e("a",{attrs:{href:t.editLink,target:"_blank",rel:"noopener noreferrer"}},[t._v(t._s(t.editLinkText))]),t._v(" "),e("OutboundLink")],1):t._e(),t._v(" "),t.lastUpdated?e("div",{staticClass:"last-updated"},[e("span",{staticClass:"prefix"},[t._v(t._s(t.lastUpdatedText)+":")]),t._v(" "),e("span",{staticClass:"time"},[t._v(t._s(t.lastUpdated))])]):t._e()])}),[],!1,null,null,null);e.default=l.exports},256:function(t,e,a){"use strict";a.r(e);var n=a(238);function s(t,e,a,n,s){const i={props:{to:e,activeClass:"",exactActiveClass:""},class:{active:n,"sidebar-link":!0}};return s>2&&(i.style={"padding-left":s+"rem"}),t("RouterLink",i,a)}function i(t,e,a,r,o,l=1){return!e||l>o?null:t("ul",{class:"sidebar-sub-headers"},e.map(e=>{const u=Object(n.e)(r,a+"#"+e.slug);return t("li",{class:"sidebar-sub-header"},[s(t,a+"#"+e.slug,e.title,u,e.level-1),i(t,e.children,a,r,o,l+1)])}))}var r={functional:!0,props:["item","sidebarDepth"],render(t,{parent:{$page:e,$site:a,$route:r,$themeConfig:o,$themeLocaleConfig:l},props:{item:u,sidebarDepth:p}}){const c=Object(n.e)(r,u.path),d="auto"===u.type?c||u.children.some(t=>Object(n.e)(r,u.basePath+"#"+t.slug)):c,h="external"===u.type?function(t,e,a){return t("a",{attrs:{href:e,target:"_blank",rel:"noopener noreferrer"},class:{"sidebar-link":!0}},[a,t("OutboundLink")])}(t,u.path,u.title||u.path):s(t,u.path,u.title||u.path,d),f=[e.frontmatter.sidebarDepth,p,l.sidebarDepth,o.sidebarDepth,1].find(t=>void 0!==t),b=l.displayAllHeaders||o.displayAllHeaders;if("auto"===u.type)return[h,i(t,u.children,u.basePath,r,f)];if((d||b)&&u.headers&&!n.d.test(u.path)){return[h,i(t,Object(n.c)(u.headers),u.path,r,f)]}return h}},o=(a(252),a(14)),l=Object(o.a)(r,void 0,void 0,!1,null,null,null);e.default=l.exports},259:function(t,e,a){},262:function(t,e,a){},263:function(t,e,a){"use strict";a(248)},264:function(t,e,a){var n=a(11),s=a(4),i=a(10);t.exports=function(t){return"string"==typeof t||!s(t)&&i(t)&&"[object String]"==n(t)}},265:function(t,e,a){},266:function(t,e,a){"use strict";a(249)},268:function(t,e,a){"use strict";a.r(e);var n=a(238),s={name:"SidebarGroup",components:{DropdownTransition:a(241).default},props:["item","open","collapsable","depth"],beforeCreate(){this.$options.components.SidebarLinks=a(253).default},methods:{isActive:n.e}},i=(a(266),a(14)),r=Object(i.a)(s,(function(){var t=this,e=t._self._c;return e("section",{staticClass:"sidebar-group",class:[{collapsable:t.collapsable,"is-sub-group":0!==t.depth},"depth-"+t.depth]},[t.item.path?e("RouterLink",{staticClass:"sidebar-heading clickable",class:{open:t.open,active:t.isActive(t.$route,t.item.path)},attrs:{to:t.item.path},nativeOn:{click:function(e){return t.$emit("toggle")}}},[e("span",[t._v(t._s(t.item.title))]),t._v(" "),t.collapsable?e("span",{staticClass:"arrow",class:t.open?"down":"right"}):t._e()]):e("p",{staticClass:"sidebar-heading",class:{open:t.open},on:{click:function(e){return t.$emit("toggle")}}},[e("span",[t._v(t._s(t.item.title))]),t._v(" "),t.collapsable?e("span",{staticClass:"arrow",class:t.open?"down":"right"}):t._e()]),t._v(" "),e("DropdownTransition",[t.open||!t.collapsable?e("SidebarLinks",{staticClass:"sidebar-group-items",attrs:{items:t.item.children,"sidebar-depth":t.item.sidebarDepth,"initial-open-group-index":t.item.initialOpenGroupIndex,depth:t.depth+1}}):t._e()],1)],1)}),[],!1,null,null,null);e.default=r.exports},269:function(t,e,a){"use strict";a.r(e);a(88);var n=a(238),s=a(264),i=a.n(s),r=a(245),o=a.n(r),l={name:"PageNav",props:["sidebarItems"],computed:{prev(){return p(u.PREV,this)},next(){return p(u.NEXT,this)}}};const u={NEXT:{resolveLink:function(t,e){return c(t,e,1)},getThemeLinkConfig:({nextLinks:t})=>t,getPageLinkConfig:({frontmatter:t})=>t.next},PREV:{resolveLink:function(t,e){return c(t,e,-1)},getThemeLinkConfig:({prevLinks:t})=>t,getPageLinkConfig:({frontmatter:t})=>t.prev}};function p(t,{$themeConfig:e,$page:a,$route:s,$site:r,sidebarItems:l}){const{resolveLink:u,getThemeLinkConfig:p,getPageLinkConfig:c}=t,d=p(e),h=c(a),f=o()(h)?d:h;return!1===f?void 0:i()(f)?Object(n.k)(r.pages,f,s.path):u(a,l)}function c(t,e,a){const n=[];!function t(e,a){for(let n=0,s=e.length;n({isSidebarOpen:!1}),computed:{shouldShowNavbar(){const{themeConfig:t}=this.$site,{frontmatter:e}=this.$page;return!1!==e.navbar&&!1!==t.navbar&&(this.$title||t.logo||t.repo||t.nav||this.$themeLocaleConfig.nav)},shouldShowSidebar(){const{frontmatter:t}=this.$page;return!t.home&&!1!==t.sidebar&&this.sidebarItems.length},sidebarItems(){return Object(o.l)(this.$page,this.$page.regularPath,this.$site,this.$localePath)},pageClasses(){const t=this.$page.frontmatter.pageClass;return[{"no-navbar":!this.shouldShowNavbar,"sidebar-open":this.isSidebarOpen,"no-sidebar":!this.shouldShowSidebar},t]}},mounted(){this.$router.afterEach(()=>{this.isSidebarOpen=!1})},methods:{toggleSidebar(t){this.isSidebarOpen="boolean"==typeof t?t:!this.isSidebarOpen,this.$emit("toggle-sidebar",this.isSidebarOpen)},onTouchStart(t){this.touchStart={x:t.changedTouches[0].clientX,y:t.changedTouches[0].clientY}},onTouchEnd(t){const e=t.changedTouches[0].clientX-this.touchStart.x,a=t.changedTouches[0].clientY-this.touchStart.y;Math.abs(e)>Math.abs(a)&&Math.abs(e)>40&&(e>0&&this.touchStart.x<=80?this.toggleSidebar(!0):this.toggleSidebar(!1))}}},u=a(14),p=Object(u.a)(l,(function(){var t=this,e=t._self._c;return e("div",{staticClass:"theme-container",class:t.pageClasses,on:{touchstart:t.onTouchStart,touchend:t.onTouchEnd}},[t.shouldShowNavbar?e("Navbar",{on:{"toggle-sidebar":t.toggleSidebar}}):t._e(),t._v(" "),e("div",{staticClass:"sidebar-mask",on:{click:function(e){return t.toggleSidebar(!1)}}}),t._v(" "),e("Sidebar",{attrs:{items:t.sidebarItems},on:{"toggle-sidebar":t.toggleSidebar},scopedSlots:t._u([{key:"top",fn:function(){return[t._t("sidebar-top")]},proxy:!0},{key:"bottom",fn:function(){return[t._t("sidebar-bottom")]},proxy:!0}],null,!0)}),t._v(" "),t.$page.frontmatter.homepage?e("HomePage",{attrs:{"sidebar-items":t.sidebarItems},scopedSlots:t._u([{key:"top",fn:function(){return[t._t("page-top")]},proxy:!0},{key:"bottom",fn:function(){return[t._t("page-bottom")]},proxy:!0}],null,!0)}):t.$page.frontmatter.news?e("NewsPost",{attrs:{"sidebar-items":t.sidebarItems},scopedSlots:t._u([{key:"top",fn:function(){return[t._t("page-top")]},proxy:!0},{key:"bottom",fn:function(){return[t._t("page-bottom")]},proxy:!0}],null,!0)}):e("Page",{attrs:{"sidebar-items":t.sidebarItems},scopedSlots:t._u([{key:"top",fn:function(){return[t._t("page-top")]},proxy:!0},{key:"bottom",fn:function(){return[t._t("page-bottom")]},proxy:!0}],null,!0)})],1)}),[],!1,null,null,null);e.default=p.exports}}]); \ No newline at end of file diff --git a/assets/js/20.6a9ecf80.js b/assets/js/20.6a9ecf80.js new file mode 100644 index 000000000..dc84f66a6 --- /dev/null +++ b/assets/js/20.6a9ecf80.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[20],{238:function(t,e,n){"use strict";n.d(e,"d",(function(){return i})),n.d(e,"a",(function(){return a})),n.d(e,"i",(function(){return s})),n.d(e,"f",(function(){return c})),n.d(e,"g",(function(){return u})),n.d(e,"h",(function(){return l})),n.d(e,"b",(function(){return d})),n.d(e,"e",(function(){return p})),n.d(e,"k",(function(){return f})),n.d(e,"l",(function(){return h})),n.d(e,"c",(function(){return m})),n.d(e,"j",(function(){return b}));n(88);const i=/#.*$/,r=/\.(md|html)$/,a=/\/$/,s=/^[a-z]+:/i;function o(t){return decodeURI(t).replace(i,"").replace(r,"")}function c(t){return s.test(t)}function u(t){return/^mailto:/.test(t)}function l(t){return/^tel:/.test(t)}function d(t){if(c(t))return t;const e=t.match(i),n=e?e[0]:"",r=o(t);return a.test(r)?t:r+".html"+n}function p(t,e){const n=decodeURIComponent(t.hash),r=function(t){const e=t.match(i);if(e)return e[0]}(e);if(r&&n!==r)return!1;return o(t.path)===o(e)}function f(t,e,n){if(c(e))return{type:"external",path:e};n&&(e=function(t,e,n){const i=t.charAt(0);if("/"===i)return t;if("?"===i||"#"===i)return e+t;const r=e.split("/");n&&r[r.length-1]||r.pop();const a=t.replace(/^\//,"").split("/");for(let t=0;tfunction t(e,n,i,r=1){if("string"==typeof e)return f(n,e,i);if(Array.isArray(e))return Object.assign(f(n,e[0],i),{title:e[1]});{const a=e.children||[];return 0===a.length&&e.path?Object.assign(f(n,e.path,i),{title:e.title}):{type:"group",path:e.path,title:e.title,sidebarDepth:e.sidebarDepth,initialOpenGroupIndex:e.initialOpenGroupIndex,children:a.map(e=>t(e,n,i,r+1)),collapsable:!1!==e.collapsable}}}(t,r,n)):[]}return[]}function g(t){const e=m(t.headers||[]);return[{type:"group",collapsable:!1,title:t.title,path:null,children:e.map(e=>({type:"auto",title:e.title,basePath:t.path,path:t.path+"#"+e.slug,children:e.children||[]}))}]}function m(t){let e;return(t=t.map(t=>Object.assign({},t))).forEach(t=>{2===t.level?e=t:e&&(e.children||(e.children=[])).push(t)}),t.filter(t=>2===t.level)}function b(t){return Object.assign(t,{type:t.items&&t.items.length?"links":"link"})}},244:function(t,e,n){},245:function(t,e){t.exports=function(t){return null==t}},251:function(t,e,n){"use strict";n(244)},255:function(t,e,n){"use strict";n.r(e);var i=n(245),r=n.n(i),a=n(238),s={name:"PageEdit",computed:{lastUpdated(){return this.$page.lastUpdated},lastUpdatedText(){return"string"==typeof this.$themeLocaleConfig.lastUpdated?this.$themeLocaleConfig.lastUpdated:"string"==typeof this.$site.themeConfig.lastUpdated?this.$site.themeConfig.lastUpdated:"Last Updated"},editLink(){const t=r()(this.$page.frontmatter.editLink)?this.$site.themeConfig.editLinks:this.$page.frontmatter.editLink,{repo:e,docsDir:n="",docsBranch:i="master",docsRepo:a=e}=this.$site.themeConfig;return"string"==typeof t?t:t&&a&&this.$page.relativePath?this.createEditLink(e,a,n,i,this.$page.relativePath):null},editLinkText(){return this.$themeLocaleConfig.editLinkText||this.$site.themeConfig.editLinkText||"Edit this page"}},methods:{createEditLink(t,e,n,i,r){if(/bitbucket.org/.test(e)){return e.replace(a.a,"")+"/src"+`/${i}/`+(n?n.replace(a.a,"")+"/":"")+r+`?mode=edit&spa=0&at=${i}&fileviewer=file-view-default`}if(/gitlab.com/.test(e)){return e.replace(a.a,"")+"/-/edit"+`/${i}/`+(n?n.replace(a.a,"")+"/":"")+r}return(a.i.test(e)?e:"https://github.com/"+e).replace(a.a,"")+"/edit"+`/${i}/`+(n?n.replace(a.a,"")+"/":"")+r}}},o=(n(251),n(14)),c=Object(o.a)(s,(function(){var t=this,e=t._self._c;return e("footer",{staticClass:"page-edit"},[t.editLink?e("div",{staticClass:"edit-link"},[e("a",{attrs:{href:t.editLink,target:"_blank",rel:"noopener noreferrer"}},[t._v(t._s(t.editLinkText))]),t._v(" "),e("OutboundLink")],1):t._e(),t._v(" "),t.lastUpdated?e("div",{staticClass:"last-updated"},[e("span",{staticClass:"prefix"},[t._v(t._s(t.lastUpdatedText)+":")]),t._v(" "),e("span",{staticClass:"time"},[t._v(t._s(t.lastUpdated))])]):t._e()])}),[],!1,null,null,null);e.default=c.exports}}]); \ No newline at end of file diff --git a/assets/js/21.953ae055.js b/assets/js/21.953ae055.js new file mode 100644 index 000000000..0416100b2 --- /dev/null +++ b/assets/js/21.953ae055.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[21],{290:function(a,e,n){},359:function(a,e,n){"use strict";n(290)},360:function(a,e){a.exports=["epoberezkin","spaced4ndy","erikbrinkman","jasoniangreen","dependabot[bot]","PBug90","blakeembrey","sambauers","gajus","meirotstein","Tyharo1","igor-savin-ht","b4h0-c4t","willfarrell","boenrobot","yume-chan","GrahamLea","franciscomorais","asaid-0","domoritz","imbstack","pithu","realityking","efebarlas","brendo","pcwiek","rehanvdm","farrago","SoAsEr","kroky","Delagen","YChebotaev","bhvngt","t7yang","teq0","wuweiss","zekth","egfx-notifications","awlayton","HotelDon","donaldpipowitch","mummybot","G-Rath","HolgerJeromin","monkeywithacupcake","ktrueda","lucassaid","marshall007","mattpolzin","MichaelDeBoey","Nonemoticoner","orgads","papb","philsturgeon","carlo-quinonez","radekmie","merlindorin","Romakita","rbuckton","ryanmeador","mighty1231","simon04","SirLich","krenor","stuartpb","TIBCOeddie","bearmini","ahmdsolmn","dzuremar","mxsgx","m00s","mbroadst","MattiAstedrone","MikeRalphson","tyok","MrJithil","mychaelgo","natflow","nwoltman","blottn","nimerritt","nicksrandall","Noam3kCH","eventlistener","Opticsponge","jonganc","jsdevel","oldmud0","ossdev07","pskfyi","qwertyforce","rek","sahilda","schokotets","superfaz","tridium","vlbee","aladdin-add","wyfo","duxing","anchnk","ChALkeR","not-an-aardvark","thernstig","TommyDew42","koba04","isTravis","cvlab","vargaeric","villasv","aristov","billytrend","byr-gdp","cjancsar","dfeufel","ehmicky","fpicalausa","franrolando","fridays","smithc10","caub","dalcib","dannyb648","dancasey","rotu","FunkyDck","darcyparker","daveisfera","dsanders11","Delapouite","dimitropoulos","keyten","thetric","rubiagatra","forivall","ecwyne","alexanderjsx","Alexsey","avanelli","anslzo","asprouse","andyscott","vixalien","kulakowka","wetneb","vendeza","benasher44","bradjones1","eventualbuddha","cbrwflo","cpillsbury","ChuntaoLu","delavara","jonathanGB","josdejong","jboavida","justinpowers","kapouer","lehni","platinumazure","kpping","laurens","johanlelan","leonardovillela","LinusU","alazyzombie","jsbrain","Eomm","VIEWVIEWVIEW","mduu","EtaiG","gj","rgeerts","garrows","gurgunday","hadrien-toma","seriousme","hans-kinnek","handrews","is2ei","idangozlan","ivansieder","P0lip","JamesJansson","mrjgreen","jrr","jonasfj"]},461:function(a,e,n){"use strict";n.r(e);var r=n(360),o=n.n(r),i={data:()=>({contributors:o.a})},t=(n(359),n(14)),s=Object(t.a)(i,(function(){var a=this,e=a._self._c;return e("div",a._l(a.contributors,(function(n,r){return e("a",{staticClass:"contributor",style:"background-position: "+100*r/(a.contributors.length-1)+"% 0",attrs:{href:"https://github.com/"+n}},[a._v("\n "+a._s(n)+"\n ")])})),0)}),[],!1,null,"074475b8",null);e.default=s.exports}}]); \ No newline at end of file diff --git a/assets/js/22.a725bd4b.js b/assets/js/22.a725bd4b.js new file mode 100644 index 000000000..86cdd820a --- /dev/null +++ b/assets/js/22.a725bd4b.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[22],{291:function(t,s,i){},361:function(t,s,i){"use strict";i(291)},362:function(t,s,i){t.exports=i.p+"assets/img/arrow.da0ea705.svg"},462:function(t,s,i){"use strict";i.r(s);var n={props:{type:{type:String},link:{type:String}}},e=(i(361),i(14)),r=Object(e.a)(n,(function(){var t=this._self._c;return t("div",{class:this.type},[this._t("default"),this._v(" "),t("a",{staticClass:"read-more",attrs:{href:this.link}},[t("img",{attrs:{src:i(362)}})])],2)}),[],!1,null,"20681dd8",null);s.default=r.exports}}]); \ No newline at end of file diff --git a/assets/js/23.5340de5c.js b/assets/js/23.5340de5c.js new file mode 100644 index 000000000..cebb88d82 --- /dev/null +++ b/assets/js/23.5340de5c.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[23],{296:function(t,s,i){},367:function(t,s,i){"use strict";i(296)},368:function(t,s,i){t.exports=i.p+"assets/img/hero-image.b1edbb72.svg"},519:function(t,s,i){"use strict";i.r(s);i(367);var e=i(14),n=Object(e.a)({},(function(){var t=this._self._c;return t("div",{staticClass:"hero-section"},[t("div",{staticClass:"section-content"},[t("img",{staticClass:"hero-image",attrs:{src:i(368)}}),this._v(" "),t("div",{staticClass:"section-content-wrapper"},[this._t("default")],2)])])}),[],!1,null,"37c67372",null);s.default=n.exports}}]); \ No newline at end of file diff --git a/assets/js/25.2485018f.js b/assets/js/25.2485018f.js new file mode 100644 index 000000000..00e3208ec --- /dev/null +++ b/assets/js/25.2485018f.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[25],{287:function(s,t,n){},356:function(s,t,n){"use strict";n(287)},459:function(s,t,n){"use strict";n.r(t);var i={props:{link:{type:String},cssClass:{type:String}}},a=(n(356),n(14)),c=Object(a.a)(i,(function(){return(0,this._self._c)("a",{staticClass:"button",class:this.cssClass,attrs:{href:this.link}},[this._t("default")],2)}),[],!1,null,"439d4a3b",null);t.default=c.exports}}]); \ No newline at end of file diff --git a/assets/js/26.356c482c.js b/assets/js/26.356c482c.js new file mode 100644 index 000000000..7b0761119 --- /dev/null +++ b/assets/js/26.356c482c.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[26],{288:function(t,s,n){},357:function(t,s,n){"use strict";n(288)},460:function(t,s,n){"use strict";n.r(s);var i={props:{side:{type:String}}},e=(n(357),n(14)),c=Object(e.a)(i,(function(){return(0,this._self._c)("div",{staticClass:"column",class:this.side},[this._t("default")],2)}),[],!1,null,"71066fea",null);s.default=c.exports}}]); \ No newline at end of file diff --git a/assets/js/27.e43150c1.js b/assets/js/27.e43150c1.js new file mode 100644 index 000000000..f40387db2 --- /dev/null +++ b/assets/js/27.e43150c1.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[27],{289:function(t,n,s){},358:function(t,n,s){"use strict";s(289)},516:function(t,n,s){"use strict";s.r(n);s(358);var u=s(14),c=Object(u.a)({},(function(){return(0,this._self._c)("div",{staticClass:"columns"},[this._t("default")],2)}),[],!1,null,"6d930324",null);n.default=c.exports}}]); \ No newline at end of file diff --git a/assets/js/28.5eaf7f1d.js b/assets/js/28.5eaf7f1d.js new file mode 100644 index 000000000..d2e227d6c --- /dev/null +++ b/assets/js/28.5eaf7f1d.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[28],{292:function(t,n,s){},363:function(t,n,s){"use strict";s(292)},517:function(t,n,s){"use strict";s.r(n);s(363);var c=s(14),u=Object(c.a)({},(function(){return(0,this._self._c)("div",{staticClass:"features"},[this._t("default")],2)}),[],!1,null,"30c230c6",null);n.default=u.exports}}]); \ No newline at end of file diff --git a/assets/js/29.41b754a9.js b/assets/js/29.41b754a9.js new file mode 100644 index 000000000..525d72972 --- /dev/null +++ b/assets/js/29.41b754a9.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[29],{293:function(t,s,n){},364:function(t,s,n){"use strict";n(293)},463:function(t,s,n){"use strict";n.r(s);var c={props:{type:{type:String}}},i=(n(364),n(14)),e=Object(i.a)(c,(function(){return(0,this._self._c)("div",{staticClass:"column",class:this.type},[this._t("default")],2)}),[],!1,null,"f7c18a96",null);s.default=e.exports}}]); \ No newline at end of file diff --git a/assets/js/3.02b8ece9.js b/assets/js/3.02b8ece9.js new file mode 100644 index 000000000..d6da69efb --- /dev/null +++ b/assets/js/3.02b8ece9.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[3,24,40],{238:function(t,e,n){"use strict";n.d(e,"d",(function(){return r})),n.d(e,"a",(function(){return s})),n.d(e,"i",(function(){return a})),n.d(e,"f",(function(){return l})),n.d(e,"g",(function(){return u})),n.d(e,"h",(function(){return c})),n.d(e,"b",(function(){return p})),n.d(e,"e",(function(){return d})),n.d(e,"k",(function(){return h})),n.d(e,"l",(function(){return f})),n.d(e,"c",(function(){return g})),n.d(e,"j",(function(){return m}));n(88);const r=/#.*$/,i=/\.(md|html)$/,s=/\/$/,a=/^[a-z]+:/i;function o(t){return decodeURI(t).replace(r,"").replace(i,"")}function l(t){return a.test(t)}function u(t){return/^mailto:/.test(t)}function c(t){return/^tel:/.test(t)}function p(t){if(l(t))return t;const e=t.match(r),n=e?e[0]:"",i=o(t);return s.test(i)?t:i+".html"+n}function d(t,e){const n=decodeURIComponent(t.hash),i=function(t){const e=t.match(r);if(e)return e[0]}(e);if(i&&n!==i)return!1;return o(t.path)===o(e)}function h(t,e,n){if(l(e))return{type:"external",path:e};n&&(e=function(t,e,n){const r=t.charAt(0);if("/"===r)return t;if("?"===r||"#"===r)return e+t;const i=e.split("/");n&&i[i.length-1]||i.pop();const s=t.replace(/^\//,"").split("/");for(let t=0;tfunction t(e,n,r,i=1){if("string"==typeof e)return h(n,e,r);if(Array.isArray(e))return Object.assign(h(n,e[0],r),{title:e[1]});{const s=e.children||[];return 0===s.length&&e.path?Object.assign(h(n,e.path,r),{title:e.title}):{type:"group",path:e.path,title:e.title,sidebarDepth:e.sidebarDepth,initialOpenGroupIndex:e.initialOpenGroupIndex,children:s.map(e=>t(e,n,r,i+1)),collapsable:!1!==e.collapsable}}}(t,i,n)):[]}return[]}function b(t){const e=g(t.headers||[]);return[{type:"group",collapsable:!1,title:t.title,path:null,children:e.map(e=>({type:"auto",title:e.title,basePath:t.path,path:t.path+"#"+e.slug,children:e.children||[]}))}]}function g(t){let e;return(t=t.map(t=>Object.assign({},t))).forEach(t=>{2===t.level?e=t:e&&(e.children||(e.children=[])).push(t)}),t.filter(t=>2===t.level)}function m(t){return Object.assign(t,{type:t.items&&t.items.length?"links":"link"})}},239:function(t,e,n){},241:function(t,e,n){"use strict";n.r(e);var r={name:"DropdownTransition",methods:{setHeight(t){t.style.height=t.scrollHeight+"px"},unsetHeight(t){t.style.height=""}}},i=(n(243),n(14)),s=Object(i.a)(r,(function(){return(0,this._self._c)("transition",{attrs:{name:"dropdown"},on:{enter:this.setHeight,"after-enter":this.unsetHeight,"before-leave":this.setHeight}},[this._t("default")],2)}),[],!1,null,null,null);e.default=s.exports},243:function(t,e,n){"use strict";n(239)},246:function(t,e,n){},249:function(t,e,n){},252:function(t,e,n){"use strict";n(246)},253:function(t,e,n){"use strict";n.r(e);var r=n(268),i=n(256),s=n(238);function a(t,e){if("group"===e.type){const n=e.path&&Object(s.e)(t,e.path),r=e.children.some(e=>"group"===e.type?a(t,e):"page"===e.type&&Object(s.e)(t,e.path));return n||r}return!1}var o={name:"SidebarLinks",components:{SidebarGroup:r.default,SidebarLink:i.default},props:["items","depth","sidebarDepth","initialOpenGroupIndex"],data(){return{openGroupIndex:this.initialOpenGroupIndex||0}},watch:{$route(){this.refreshIndex()}},created(){this.refreshIndex()},methods:{refreshIndex(){const t=function(t,e){for(let n=0;n-1&&(this.openGroupIndex=t)},toggleGroup(t){this.openGroupIndex=t===this.openGroupIndex?-1:t},isActive(t){return Object(s.e)(this.$route,t.regularPath)}}},l=n(14),u=Object(l.a)(o,(function(){var t=this,e=t._self._c;return t.items.length?e("ul",{staticClass:"sidebar-links"},t._l(t.items,(function(n,r){return e("li",{key:r},["group"===n.type?e("SidebarGroup",{attrs:{item:n,open:r===t.openGroupIndex,collapsable:n.collapsable||n.collapsible,depth:t.depth},on:{toggle:function(e){return t.toggleGroup(r)}}}):e("SidebarLink",{attrs:{"sidebar-depth":t.sidebarDepth,item:n}})],1)})),0):t._e()}),[],!1,null,null,null);e.default=u.exports},256:function(t,e,n){"use strict";n.r(e);var r=n(238);function i(t,e,n,r,i){const s={props:{to:e,activeClass:"",exactActiveClass:""},class:{active:r,"sidebar-link":!0}};return i>2&&(s.style={"padding-left":i+"rem"}),t("RouterLink",s,n)}function s(t,e,n,a,o,l=1){return!e||l>o?null:t("ul",{class:"sidebar-sub-headers"},e.map(e=>{const u=Object(r.e)(a,n+"#"+e.slug);return t("li",{class:"sidebar-sub-header"},[i(t,n+"#"+e.slug,e.title,u,e.level-1),s(t,e.children,n,a,o,l+1)])}))}var a={functional:!0,props:["item","sidebarDepth"],render(t,{parent:{$page:e,$site:n,$route:a,$themeConfig:o,$themeLocaleConfig:l},props:{item:u,sidebarDepth:c}}){const p=Object(r.e)(a,u.path),d="auto"===u.type?p||u.children.some(t=>Object(r.e)(a,u.basePath+"#"+t.slug)):p,h="external"===u.type?function(t,e,n){return t("a",{attrs:{href:e,target:"_blank",rel:"noopener noreferrer"},class:{"sidebar-link":!0}},[n,t("OutboundLink")])}(t,u.path,u.title||u.path):i(t,u.path,u.title||u.path,d),f=[e.frontmatter.sidebarDepth,c,l.sidebarDepth,o.sidebarDepth,1].find(t=>void 0!==t),b=l.displayAllHeaders||o.displayAllHeaders;if("auto"===u.type)return[h,s(t,u.children,u.basePath,a,f)];if((d||b)&&u.headers&&!r.d.test(u.path)){return[h,s(t,Object(r.c)(u.headers),u.path,a,f)]}return h}},o=(n(252),n(14)),l=Object(o.a)(a,void 0,void 0,!1,null,null,null);e.default=l.exports},266:function(t,e,n){"use strict";n(249)},268:function(t,e,n){"use strict";n.r(e);var r=n(238),i={name:"SidebarGroup",components:{DropdownTransition:n(241).default},props:["item","open","collapsable","depth"],beforeCreate(){this.$options.components.SidebarLinks=n(253).default},methods:{isActive:r.e}},s=(n(266),n(14)),a=Object(s.a)(i,(function(){var t=this,e=t._self._c;return e("section",{staticClass:"sidebar-group",class:[{collapsable:t.collapsable,"is-sub-group":0!==t.depth},"depth-"+t.depth]},[t.item.path?e("RouterLink",{staticClass:"sidebar-heading clickable",class:{open:t.open,active:t.isActive(t.$route,t.item.path)},attrs:{to:t.item.path},nativeOn:{click:function(e){return t.$emit("toggle")}}},[e("span",[t._v(t._s(t.item.title))]),t._v(" "),t.collapsable?e("span",{staticClass:"arrow",class:t.open?"down":"right"}):t._e()]):e("p",{staticClass:"sidebar-heading",class:{open:t.open},on:{click:function(e){return t.$emit("toggle")}}},[e("span",[t._v(t._s(t.item.title))]),t._v(" "),t.collapsable?e("span",{staticClass:"arrow",class:t.open?"down":"right"}):t._e()]),t._v(" "),e("DropdownTransition",[t.open||!t.collapsable?e("SidebarLinks",{staticClass:"sidebar-group-items",attrs:{items:t.item.children,"sidebar-depth":t.item.sidebarDepth,"initial-open-group-index":t.item.initialOpenGroupIndex,depth:t.depth+1}}):t._e()],1)],1)}),[],!1,null,null,null);e.default=a.exports}}]); \ No newline at end of file diff --git a/assets/js/30.a66a92da.js b/assets/js/30.a66a92da.js new file mode 100644 index 000000000..7c9d863ff --- /dev/null +++ b/assets/js/30.a66a92da.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[30],{295:function(t,n,s){},366:function(t,n,s){"use strict";s(295)},518:function(t,n,s){"use strict";s.r(n);s(366);var u=s(14),c=Object(u.a)({},(function(){return(0,this._self._c)("div",{staticClass:"footer-columns"},[this._t("default")],2)}),[],!1,null,"de1d7950",null);n.default=c.exports}}]); \ No newline at end of file diff --git a/assets/js/31.dd964fda.js b/assets/js/31.dd964fda.js new file mode 100644 index 000000000..93a9707ab --- /dev/null +++ b/assets/js/31.dd964fda.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[31],{294:function(t,a,n){},365:function(t,a,n){"use strict";n(294)},464:function(t,a,n){"use strict";n.r(a);var e={mounted(){let t=document.createElement("script");t.setAttribute("src","https://buttons.github.io/buttons.js"),document.head.appendChild(t)}},s=(n(365),n(14)),i=Object(s.a)(e,(function(){var t=this._self._c;return t("ClientOnly",[t("span",[t("a",{staticClass:"github-button",attrs:{href:"https://github.com/ajv-validator/ajv","data-show-count":"true","data-size":"large","aria-label":"Star ajv-validator/ajv on GitHub"}},[this._v("\n Star\n ")])])])}),[],!1,null,"3ac601d9",null);a.default=i.exports}}]); \ No newline at end of file diff --git a/assets/js/32.4d83c0d4.js b/assets/js/32.4d83c0d4.js new file mode 100644 index 000000000..afe99ceba --- /dev/null +++ b/assets/js/32.4d83c0d4.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[32],{297:function(t,n,s){},369:function(t,n,s){"use strict";s(297)},520:function(t,n,s){"use strict";s.r(n);s(369);var e=s(14),i=Object(e.a)({},(function(){var t=this._self._c;return t("main",{staticClass:"homepage"},[this._t("top"),this._v(" "),t("Content"),this._v(" "),this._t("bottom")],2)}),[],!1,null,"07ee638e",null);n.default=i.exports}}]); \ No newline at end of file diff --git a/assets/js/33.7244e27d.js b/assets/js/33.7244e27d.js new file mode 100644 index 000000000..821287d24 --- /dev/null +++ b/assets/js/33.7244e27d.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[33],{298:function(t,s,n){},370:function(t,s,n){"use strict";n(298)},465:function(t,s,n){"use strict";n.r(s);var i={props:{section:{type:String}}},c=(n(370),n(14)),e=Object(c.a)(i,(function(){var t=this._self._c;return t("div",{staticClass:"home-section",class:this.section},[t("div",{staticClass:"section-content"},[this._t("default")],2)])}),[],!1,null,"aed41194",null);s.default=e.exports}}]); \ No newline at end of file diff --git a/assets/js/34.2668d09c.js b/assets/js/34.2668d09c.js new file mode 100644 index 000000000..4b38dfbc2 --- /dev/null +++ b/assets/js/34.2668d09c.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[34],{299:function(t,s,e){},371:function(t,s,e){"use strict";e(299)},466:function(t,s,e){"use strict";e.r(s);var r={computed:{posts(){return this.$site.pages.filter(t=>t.path.startsWith("/news/")&&!t.frontmatter.newsIndex).sort((t,s)=>new Date(s.frontmatter.date)-new Date(t.frontmatter.date)).slice(0,3)}}},a=(e(371),e(14)),n=Object(a.a)(r,(function(){var t=this,s=t._self._c;return s("div",[t._l(t.posts,(function(e,r){return s("div",{staticClass:"post"},[s("Columns",[s("Column",{attrs:{side:"left"}},[s("h3",[t._v(t._s(e.frontmatter.title))]),t._v(" "),s("NewsPostMeta",{attrs:{date:e.frontmatter.date}})],1),t._v(" "),s("Column",{attrs:{side:"right"}},[s("div",{domProps:{innerHTML:t._s(e.excerpt)}}),t._v(" "),!1!==e.frontmatter.more?s("Button",{attrs:{link:e.path,cssClass:"read-more"}},[t._v("Read more")]):t._e()],1)],1)],1)})),t._v(" "),s("p",{staticClass:"subscribe"},[s("Subscribe"),t._v(" "),s("a",{staticClass:"all-news",attrs:{href:"/news/"}},[t._v("All news")])],1)],2)}),[],!1,null,"a228e400",null);s.default=n.exports}}]); \ No newline at end of file diff --git a/assets/js/35.69f17b7b.js b/assets/js/35.69f17b7b.js new file mode 100644 index 000000000..ad1a17b8d --- /dev/null +++ b/assets/js/35.69f17b7b.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[35],{302:function(t,n,s){},376:function(t,n,s){"use strict";s(302)},521:function(t,n,s){"use strict";s.r(n);s(376);var e=s(14),c=Object(e.a)({},(function(){return(0,this._self._c)("div",{staticClass:"projects"},[this._t("default")],2)}),[],!1,null,"7ef3dfe8",null);n.default=c.exports}}]); \ No newline at end of file diff --git a/assets/js/36.cc9280ab.js b/assets/js/36.cc9280ab.js new file mode 100644 index 000000000..0ba7e9760 --- /dev/null +++ b/assets/js/36.cc9280ab.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[36],{303:function(s,t,n){},377:function(s,t,n){"use strict";n(303)},470:function(s,t,n){"use strict";n.r(t);var e={props:{level:{type:String}}},c=(n(377),n(14)),i=Object(c.a)(e,(function(){return(0,this._self._c)("div",{staticClass:"sponsors",class:this.level},[this._t("default")],2)}),[],!1,null,"c1b00a8c",null);t.default=i.exports}}]); \ No newline at end of file diff --git a/assets/js/37.58445429.js b/assets/js/37.58445429.js new file mode 100644 index 000000000..19cdd0b5f --- /dev/null +++ b/assets/js/37.58445429.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[37],{304:function(t,i,s){},378:function(t,i,s){"use strict";s(304)},522:function(t,i,s){"use strict";s.r(i);s(378);var a=s(14),e=Object(a.a)({},(function(){this._self._c;return this._m(0)}),[function(){var t=this._self._c;return t("form",{attrs:{action:"https://ajv.us1.list-manage.com/subscribe/post?u=4343a2a251fa30892c2360003&id=304f51cbc3",method:"post",target:"_blank",novalidate:""}},[t("label",{attrs:{for:"subscription-email"}},[this._v("Subscribe to Ajv news")]),this._v(" "),t("input",{attrs:{id:"subscription-email",name:"EMAIL",placeholder:"Your email"}}),this._v(" "),t("div",{staticStyle:{position:"absolute",left:"-5000px"},attrs:{"aria-hidden":"true"}},[t("input",{attrs:{type:"text",name:"b_4343a2a251fa30892c2360003_304f51cbc3",tabindex:"-1",value:""}})]),this._v(" "),t("button",{attrs:{type:"submit"}},[this._v("Submit")])])}],!1,null,"410e8fc2",null);i.default=e.exports}}]); \ No newline at end of file diff --git a/assets/js/38.c4825bd7.js b/assets/js/38.c4825bd7.js new file mode 100644 index 000000000..4b521546f --- /dev/null +++ b/assets/js/38.c4825bd7.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[38],{305:function(t,n,s){},379:function(t,n,s){"use strict";s(305)},471:function(t,n,s){"use strict";s.r(n);var c={props:{color:{type:String}}},i=(s(379),s(14)),o=Object(i.a)(c,(function(){return(0,this._self._c)("div",{staticClass:"testimonial-content",class:this.color},[this._t("default")],2)}),[],!1,null,"2c05e654",null);n.default=o.exports}}]); \ No newline at end of file diff --git a/assets/js/39.ffceb34d.js b/assets/js/39.ffceb34d.js new file mode 100644 index 000000000..38587a1ec --- /dev/null +++ b/assets/js/39.ffceb34d.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[39],{306:function(t,n,s){},380:function(t,n,s){"use strict";s(306)},523:function(t,n,s){"use strict";s.r(n);s(380);var i=s(14),u=Object(i.a)({},(function(){return(0,this._self._c)("div",{staticClass:"testimonials"},[this._t("default")],2)}),[],!1,null,"729b0721",null);n.default=u.exports}}]); \ No newline at end of file diff --git a/assets/js/4.aa0b1621.js b/assets/js/4.aa0b1621.js new file mode 100644 index 000000000..66e4ef34a --- /dev/null +++ b/assets/js/4.aa0b1621.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[4],{284:function(t,e,n){},322:function(t,e,n){"use strict";n(284)},472:function(t,e,n){"use strict";n.r(e);var i={functional:!0,props:{type:{type:String,default:"tip"},text:String,vertical:{type:String,default:"top"}},render:(t,{props:e,slots:n})=>t("span",{class:["badge",e.type],style:{verticalAlign:e.vertical}},e.text||n().default)},p=(n(322),n(14)),l=Object(p.a)(i,void 0,void 0,!1,null,"6eb0829b",null);e.default=l.exports}}]); \ No newline at end of file diff --git a/assets/js/40.ab659ceb.js b/assets/js/40.ab659ceb.js new file mode 100644 index 000000000..5a90fef8c --- /dev/null +++ b/assets/js/40.ab659ceb.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[40],{239:function(t,e,n){},241:function(t,e,n){"use strict";n.r(e);var s={name:"DropdownTransition",methods:{setHeight(t){t.style.height=t.scrollHeight+"px"},unsetHeight(t){t.style.height=""}}},i=(n(243),n(14)),o=Object(i.a)(s,(function(){return(0,this._self._c)("transition",{attrs:{name:"dropdown"},on:{enter:this.setHeight,"after-enter":this.unsetHeight,"before-leave":this.setHeight}},[this._t("default")],2)}),[],!1,null,null,null);e.default=o.exports},243:function(t,e,n){"use strict";n(239)}}]); \ No newline at end of file diff --git a/assets/js/41.ba61b100.js b/assets/js/41.ba61b100.js new file mode 100644 index 000000000..b16e67389 --- /dev/null +++ b/assets/js/41.ba61b100.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[41],{261:function(t,c,n){},273:function(t,c,n){"use strict";n(261)},310:function(t,c,n){"use strict";n.r(c);n(273);var i=n(14),s=Object(i.a)({},(function(){var t=this,c=t._self._c;return c("div",{staticClass:"sidebar-button",on:{click:function(c){return t.$emit("toggle-sidebar")}}},[c("svg",{staticClass:"icon",attrs:{xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",role:"img",viewBox:"0 0 448 512"}},[c("path",{attrs:{fill:"currentColor",d:"M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"}})])])}),[],!1,null,null,null);c.default=s.exports}}]); \ No newline at end of file diff --git a/assets/js/42.fb040498.js b/assets/js/42.fb040498.js new file mode 100644 index 000000000..cb66fa51e --- /dev/null +++ b/assets/js/42.fb040498.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[42],{238:function(t,n,e){"use strict";e.d(n,"d",(function(){return r})),e.d(n,"a",(function(){return s})),e.d(n,"i",(function(){return u})),e.d(n,"f",(function(){return a})),e.d(n,"g",(function(){return l})),e.d(n,"h",(function(){return c})),e.d(n,"b",(function(){return f})),e.d(n,"e",(function(){return h})),e.d(n,"k",(function(){return p})),e.d(n,"l",(function(){return d})),e.d(n,"c",(function(){return b})),e.d(n,"j",(function(){return m}));e(88);const r=/#.*$/,i=/\.(md|html)$/,s=/\/$/,u=/^[a-z]+:/i;function o(t){return decodeURI(t).replace(r,"").replace(i,"")}function a(t){return u.test(t)}function l(t){return/^mailto:/.test(t)}function c(t){return/^tel:/.test(t)}function f(t){if(a(t))return t;const n=t.match(r),e=n?n[0]:"",i=o(t);return s.test(i)?t:i+".html"+e}function h(t,n){const e=decodeURIComponent(t.hash),i=function(t){const n=t.match(r);if(n)return n[0]}(n);if(i&&e!==i)return!1;return o(t.path)===o(n)}function p(t,n,e){if(a(n))return{type:"external",path:n};e&&(n=function(t,n,e){const r=t.charAt(0);if("/"===r)return t;if("?"===r||"#"===r)return n+t;const i=n.split("/");e&&i[i.length-1]||i.pop();const s=t.replace(/^\//,"").split("/");for(let t=0;tfunction t(n,e,r,i=1){if("string"==typeof n)return p(e,n,r);if(Array.isArray(n))return Object.assign(p(e,n[0],r),{title:n[1]});{const s=n.children||[];return 0===s.length&&n.path?Object.assign(p(e,n.path,r),{title:n.title}):{type:"group",path:n.path,title:n.title,sidebarDepth:n.sidebarDepth,initialOpenGroupIndex:n.initialOpenGroupIndex,children:s.map(n=>t(n,e,r,i+1)),collapsable:!1!==n.collapsable}}}(t,i,e)):[]}return[]}function g(t){const n=b(t.headers||[]);return[{type:"group",collapsable:!1,title:t.title,path:null,children:n.map(n=>({type:"auto",title:n.title,basePath:t.path,path:t.path+"#"+n.slug,children:n.children||[]}))}]}function b(t){let n;return(t=t.map(t=>Object.assign({},t))).forEach(t=>{2===t.level?n=t:n&&(n.children||(n.children=[])).push(t)}),t.filter(t=>2===t.level)}function m(t){return Object.assign(t,{type:t.items&&t.items.length?"links":"link"})}},240:function(t,n,e){"use strict";e.r(n);var r=e(238),i={name:"NavLink",props:{item:{required:!0}},computed:{link(){return Object(r.b)(this.item.link)},exact(){return this.$site.locales?Object.keys(this.$site.locales).some(t=>t===this.link):"/"===this.link},isNonHttpURI(){return Object(r.g)(this.link)||Object(r.h)(this.link)},isBlankTarget(){return"_blank"===this.target},isInternal(){return!Object(r.f)(this.link)&&!this.isBlankTarget},target(){return this.isNonHttpURI?null:this.item.target?this.item.target:Object(r.f)(this.link)?"_blank":""},rel(){return this.isNonHttpURI||!1===this.item.rel?null:this.item.rel?this.item.rel:this.isBlankTarget?"noopener noreferrer":null}},methods:{focusoutAction(){this.$emit("focusout")}}},s=e(14),u=Object(s.a)(i,(function(){var t=this,n=t._self._c;return t.isInternal?n("RouterLink",{staticClass:"nav-link",attrs:{to:t.link,exact:t.exact},nativeOn:{focusout:function(n){return t.focusoutAction.apply(null,arguments)}}},[t._v("\n "+t._s(t.item.text)+"\n")]):n("a",{staticClass:"nav-link external",attrs:{href:t.link,target:t.target,rel:t.rel},on:{focusout:t.focusoutAction}},[t._v("\n "+t._s(t.item.text)+"\n "),t.isBlankTarget?n("OutboundLink"):t._e()],1)}),[],!1,null,null,null);n.default=u.exports}}]); \ No newline at end of file diff --git a/assets/js/43.3c93a81f.js b/assets/js/43.3c93a81f.js new file mode 100644 index 000000000..efd47c5da --- /dev/null +++ b/assets/js/43.3c93a81f.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[43],{467:function(t,e,r){"use strict";r.r(e);var n={computed:{posts(){return this.$site.pages.filter(t=>t.path.startsWith("/news/")&&!t.frontmatter.newsIndex).sort((t,e)=>new Date(e.frontmatter.date)-new Date(t.frontmatter.date))}}},a=r(14),s=Object(a.a)(n,(function(){var t=this,e=t._self._c;return e("div",t._l(t.posts,(function(r){return e("div",[e("h2",[t._v(t._s(r.frontmatter.title))]),t._v(" "),e("router-link",{attrs:{to:r.path}},[e("NewsPostMeta",{attrs:{date:r.frontmatter.date}})],1),t._v(" "),e("div",{domProps:{innerHTML:t._s(r.excerpt)}}),t._v(" "),!1!==r.frontmatter.more?e("p",[e("router-link",{attrs:{to:r.path}},[t._v("Read more")])],1):t._e()],1)})),0)}),[],!1,null,null,null);e.default=s.exports}}]); \ No newline at end of file diff --git a/assets/js/44.ac9324da.js b/assets/js/44.ac9324da.js new file mode 100644 index 000000000..437f4dbd9 --- /dev/null +++ b/assets/js/44.ac9324da.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[44],{474: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:"api-reference"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#api-reference"}},[t._v("#")]),t._v(" API Reference")]),t._v(" "),a("p"),a("div",{staticClass:"table-of-contents"},[a("ul",[a("li",[a("a",{attrs:{href:"#ajv-constructor-and-methods"}},[t._v("Ajv constructor and methods")]),a("ul",[a("li",[a("a",{attrs:{href:"#new-ajv-options-object"}},[t._v("new Ajv(options: object)")])]),a("li",[a("a",{attrs:{href:"#ajv-compile-schema-object-data-any-boolean-promise-any"}},[t._v("ajv.compile(schema: object): (data: any) => boolean | Promise < any >")])]),a("li",[a("a",{attrs:{href:"#ajv-compileserializer-schema-object-data-any-string"}},[t._v("ajv.compileSerializer(schema: object): (data: any) => string "),a("Badge",{attrs:{text:"NEW"}})],1)]),a("li",[a("a",{attrs:{href:"#ajv-compileparser-schema-object-json-string-any"}},[t._v("ajv.compileParser(schema: object): (json: string) => any "),a("Badge",{attrs:{text:"NEW"}})],1)]),a("li",[a("a",{attrs:{href:"#ajv-compileasync-schema-object-meta-boolean-promise-function"}},[t._v("ajv.compileAsync(schema: object, meta?: boolean): Promise < Function >")])]),a("li",[a("a",{attrs:{href:"#ajv-validate-schemaorref-object-string-data-any-boolean"}},[t._v("ajv.validate(schemaOrRef: object | string, data: any): boolean")])]),a("li",[a("a",{attrs:{href:"#ajv-addschema-schema-object-object-key-string-ajv"}},[t._v("ajv.addSchema(schema: object | object[], key?: string): Ajv")])]),a("li",[a("a",{attrs:{href:"#ajv-addmetaschema-schema-object-object-key-string-ajv"}},[t._v("ajv.addMetaSchema(schema: object | object[], key?: string): Ajv")])]),a("li",[a("a",{attrs:{href:"#ajv-validateschema-schema-object-boolean"}},[t._v("ajv.validateSchema(schema: object): boolean")])]),a("li",[a("a",{attrs:{href:"#ajv-getschema-key-string-undefined-data-any-boolean-promise-any"}},[t._v("ajv.getSchema(key: string): undefined | ((data: any) => boolean | Promise < any >)")])]),a("li",[a("a",{attrs:{href:"#ajv-removeschema-schemaorref-object-string-regexp-ajv"}},[t._v("ajv.removeSchema(schemaOrRef: object | string | RegExp): Ajv")])]),a("li",[a("a",{attrs:{href:"#ajv-addformat-name-string-format-format-ajv"}},[t._v("ajv.addFormat(name: string, format: Format): Ajv")])]),a("li",[a("a",{attrs:{href:"#ajv-addkeyword-definition-string-object-ajv"}},[t._v("ajv.addKeyword(definition: string | object): Ajv")])]),a("li",[a("a",{attrs:{href:"#ajv-getkeyword-keyword-string-object-boolean"}},[t._v("ajv.getKeyword(keyword: string): object | boolean")])]),a("li",[a("a",{attrs:{href:"#ajv-removekeyword-keyword-string-ajv"}},[t._v("ajv.removeKeyword(keyword: string): Ajv")])]),a("li",[a("a",{attrs:{href:"#ajv-errorstext-errors-object-options-object-string"}},[t._v("ajv.errorsText(errors?: object[], options?: object): string")])])])]),a("li",[a("a",{attrs:{href:"#validation-errors"}},[t._v("Validation errors")]),a("ul",[a("li",[a("a",{attrs:{href:"#error-objects"}},[t._v("Error objects")])]),a("li",[a("a",{attrs:{href:"#error-parameters"}},[t._v("Error parameters")])]),a("li",[a("a",{attrs:{href:"#errors-i18n"}},[t._v("Errors i18n")])]),a("li",[a("a",{attrs:{href:"#error-logging"}},[t._v("Error logging")])])])])])]),a("p"),t._v(" "),a("h2",{attrs:{id:"ajv-constructor-and-methods"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#ajv-constructor-and-methods"}},[t._v("#")]),t._v(" Ajv constructor and methods")]),t._v(" "),a("h3",{attrs:{id:"new-ajv-options-object"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#new-ajv-options-object"}},[t._v("#")]),t._v(" new Ajv(options: object)")]),t._v(" "),a("p",[t._v("Create 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 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("p",[t._v("See "),a("a",{attrs:{href:"./options"}},[t._v("Options")])]),t._v(" "),a("h3",{attrs:{id:"ajv-compile-schema-object-data-any-boolean-promise-any"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#ajv-compile-schema-object-data-any-boolean-promise-any"}},[t._v("#")]),t._v(" ajv.compile(schema: object): (data: any) => boolean | Promise < any >")]),t._v(" "),a("p",[t._v("Generate validating function and cache the compiled schema for future use.")]),t._v(" "),a("p",[t._v("Validating function returns a boolean value (or promise for async schemas that must have "),a("code",[t._v("$async: true")]),t._v(" property - see "),a("RouterLink",{attrs:{to:"/guide/async-validation.html"}},[t._v("Asynchronous validation")]),t._v("). This function has properties "),a("code",[t._v("errors")]),t._v(" and "),a("code",[t._v("schema")]),t._v(". Errors encountered during the last validation are assigned to "),a("code",[t._v("errors")]),t._v(" property (it is assigned "),a("code",[t._v("null")]),t._v(" if there was no errors). "),a("code",[t._v("schema")]),t._v(" property contains the reference to the original schema.")],1),t._v(" "),a("p",[t._v("The schema passed to this method will be validated against meta-schema unless "),a("code",[t._v("validateSchema")]),t._v(" option is false. If schema is invalid, an error will be thrown. See "),a("a",{attrs:{href:"#options"}},[t._v("options")]),t._v(".")]),t._v(" "),a("p",[t._v("In typescript returned validation function can be a type guard if you pass type parameter:")]),t._v(" "),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("interface")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("Foo")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n foo"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("number")]),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(" FooSchema"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" JSONSchemaType"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<")]),t._v("Foo"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(">")]),t._v(" "),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 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 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("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("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 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 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 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 generic-function"}},[a("span",{pre:!0,attrs:{class:"token function"}},[t._v("compile")]),a("span",{pre:!0,attrs:{class:"token generic class-name"}},[a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<")]),t._v("Foo"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(">")])])]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("FooSchema"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// type of validate extends `(data: any) => data is Foo`")]),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 builtin"}},[t._v("any")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),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 keyword"}},[t._v("if")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[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(")")]),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 comment"}},[t._v("// data is Foo here")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token builtin"}},[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("data"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("foo"),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(" "),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 "),a("span",{pre:!0,attrs:{class:"token builtin"}},[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"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])]),a("p",[t._v("See more advanced example in "),a("a",{attrs:{href:"https://github.com/ajv-validator/ajv/blob/master/spec/types/json-schema.spec.ts",target:"_blank",rel:"noopener noreferrer"}},[t._v("the test"),a("OutboundLink")],1),t._v(".")]),t._v(" "),a("p",[a("a",{attrs:{name:"jtd-serialize"}})]),t._v(" "),a("h3",{attrs:{id:"ajv-compileserializer-schema-object-data-any-string"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#ajv-compileserializer-schema-object-data-any-string"}},[t._v("#")]),t._v(" ajv.compileSerializer(schema: object): (data: any) => string "),a("Badge",{attrs:{text:"NEW"}})],1),t._v(" "),a("p",[t._v("Generate serializing function based on the "),a("RouterLink",{attrs:{to:"/json-type-definition.html"}},[t._v("JTD schema")]),t._v(" (caches the schema) - only in JTD instance of Ajv (see example below).")],1),t._v(" "),a("p",[t._v("Serializers compiled from JTD schemas can be more than 10 times faster than using "),a("code",[t._v("JSON.stringify")]),t._v(", because they do not traverse all the data, only the properties that are defined in the schema.")]),t._v(" "),a("p",[t._v("Properties not defined in the schema will not be included in serialized JSON, unless the schema has "),a("code",[t._v("additionalProperties: true")]),t._v(" flag. It can also be beneficial from the application security point of view, as it prevents leaking accidentally/temporarily added additional properties to the API responses.")]),t._v(" "),a("p",[t._v("If you use JTD with typescript, the type for the schema can be derived from the data type, and generated serializer would only accept correct data type in this case:")]),t._v(" "),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 punctuation"}},[t._v(",")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("JTDSchemaType"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v(" "),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/jtd"')]),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\n"),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("interface")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("MyData")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n foo"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("number")]),t._v("\n bar"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("string")]),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(" mySchema"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" JTDSchemaType"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<")]),t._v("MyData"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(">")]),t._v(" "),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 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 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("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(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// any JTD number type would be accepted here")]),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 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 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("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(" serializeMyData "),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("mySchema"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// serializeMyData has type (x: MyData) => string")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// it prevents you from accidentally passing the wrong type")]),t._v("\n")])])]),a("div",{staticClass:"custom-block warning"},[a("p",{staticClass:"custom-block-title"},[t._v("Compiled serializers do NOT validate data!")]),t._v(" "),a("p",[t._v("It is assumed that the data is valid according to the schema.")])]),t._v(" "),a("p",[a("a",{attrs:{name:"jtd-parse"}})]),t._v(" "),a("h3",{attrs:{id:"ajv-compileparser-schema-object-json-string-any"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#ajv-compileparser-schema-object-json-string-any"}},[t._v("#")]),t._v(" ajv.compileParser(schema: object): (json: string) => any "),a("Badge",{attrs:{text:"NEW"}})],1),t._v(" "),a("p",[t._v("Generate parsing function based on the "),a("RouterLink",{attrs:{to:"/json-type-definition.html"}},[t._v("JTD schema")]),t._v(" (caches the schema) - only in JTD instance of Ajv (see example below).")],1),t._v(" "),a("p",[t._v("Parsers compiled from JTD schemas have comparable performance to "),a("code",[t._v("JSON.parse")]),a("sup",[t._v("*")]),t._v(" in case JSON string is valid according to the schema (and they do not just parse JSON - they ensure that parsed JSON is valid according to the schema as they parse), but they can be many times faster in case the string is invalid - for example, if schema expects an object, and JSON string is array the parser would fail on the first character.")]),t._v(" "),a("p",[t._v("Parsing will fail if there are properties not defined in the schema, unless the schema has "),a("code",[t._v("additionalProperties: true")]),t._v(" flag.")]),t._v(" "),a("p",[t._v("If you use JTD with typescript, the type for the schema can be derived from the data type, and generated parser will return correct data type (see definitions example in the "),a("a",{attrs:{href:"#jtd-serialize"}},[t._v("serialize")]),t._v(" section):")]),t._v(" "),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("const")]),t._v(" parseMyData "),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("mySchema"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// parseMyData has type (s: string) => MyData | undefined")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// it returns correct data type in case parsing is successful and undefined if not")]),t._v("\n\n"),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" validData "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("parseMyData")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token string"}},[t._v("'{\"foo\":1}'")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// {foo: 1} - success")]),t._v("\n\n"),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" invalidData "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("parseMyData")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token string"}},[t._v("'{\"x\":1}'")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// undefined - failure")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token builtin"}},[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("parseMyData"),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("// 4")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token builtin"}},[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("parseMyData"),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("// property x not allowed")]),t._v("\n")])])]),a("p",[a("sup",[t._v("*")]),t._v(" As long as empty schema "),a("code",[t._v("{}")]),t._v(" is not used - there is a possibility to improve performance in this case. Also, the performance of parsing "),a("code",[t._v("discriminator")]),t._v(" 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",[a("a",{attrs:{name:"api-compileAsync"}})]),t._v(" "),a("h3",{attrs:{id:"ajv-compileasync-schema-object-meta-boolean-promise-function"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#ajv-compileasync-schema-object-meta-boolean-promise-function"}},[t._v("#")]),t._v(" ajv.compileAsync(schema: object, meta?: boolean): Promise < Function >")]),t._v(" "),a("p",[t._v("Asynchronous version of "),a("code",[t._v("compile")]),t._v(" method that loads missing remote schemas using asynchronous function in "),a("code",[t._v("options.loadSchema")]),t._v(". This function returns a Promise that resolves to a validation function. An optional callback passed to "),a("code",[t._v("compileAsync")]),t._v(" will be called with 2 parameters: error (or null) and validating function. The returned promise will reject (and the callback will be called with an error) when:")]),t._v(" "),a("ul",[a("li",[t._v("missing schema can't be loaded ("),a("code",[t._v("loadSchema")]),t._v(" returns a Promise that rejects).")]),t._v(" "),a("li",[t._v("a schema containing a missing reference is loaded, but the reference cannot be resolved.")]),t._v(" "),a("li",[t._v("schema (or some loaded/referenced schema) is invalid.")])]),t._v(" "),a("p",[t._v("The function compiles schema and loads the first missing schema (or meta-schema) until all missing schemas are loaded.")]),t._v(" "),a("p",[t._v("You can asynchronously compile meta-schema by passing "),a("code",[t._v("true")]),t._v(" as the second parameter.")]),t._v(" "),a("p",[t._v("Similarly to "),a("code",[t._v("compile")]),t._v(", it can return type guard in typescript.")]),t._v(" "),a("p",[t._v("See example in "),a("RouterLink",{attrs:{to:"/guide/managing-schemas.html#asynchronous-schema-loading"}},[t._v("Asynchronous schema loading")]),t._v(".")],1),t._v(" "),a("h3",{attrs:{id:"ajv-validate-schemaorref-object-string-data-any-boolean"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#ajv-validate-schemaorref-object-string-data-any-boolean"}},[t._v("#")]),t._v(" ajv.validate(schemaOrRef: object | string, data: any): boolean")]),t._v(" "),a("p",[t._v("Validate data using passed schema (it will be compiled and cached).")]),t._v(" "),a("p",[t._v("Instead of the schema you can use the key that was previously passed to "),a("code",[t._v("addSchema")]),t._v(", the schema id if it was present in the schema or any previously resolved reference.")]),t._v(" "),a("p",[t._v("Validation errors will be available in the "),a("code",[t._v("errors")]),t._v(" property of Ajv instance ("),a("code",[t._v("null")]),t._v(" if there were no errors).")]),t._v(" "),a("p",[t._v("In typescript this method can act as a type guard (similarly to function returned by "),a("code",[t._v("compile")]),t._v(" method - see example there).")]),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 this method is called the errors are overwritten so you need to copy them to another variable if you want to use them later.")])]),t._v(" "),a("p",[t._v("If the schema is asynchronous (has "),a("code",[t._v("$async")]),t._v(" keyword on the top level) this method returns a Promise. See "),a("RouterLink",{attrs:{to:"/guide/async-validation.html"}},[t._v("Asynchronous validation")]),t._v(".")],1),t._v(" "),a("p",[a("a",{attrs:{id:"add-schema"}})]),t._v(" "),a("h3",{attrs:{id:"ajv-addschema-schema-object-object-key-string-ajv"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#ajv-addschema-schema-object-object-key-string-ajv"}},[t._v("#")]),t._v(" ajv.addSchema(schema: object | object[], key?: string): Ajv")]),t._v(" "),a("p",[t._v("Add schema(s) to validator instance. This method does not compile schemas (but it still validates them). Because of that dependencies can be added in any order and circular dependencies are supported. It also prevents unnecessary compilation of schemas that are containers for other schemas but not used as a whole.")]),t._v(" "),a("p",[t._v("Array of schemas can be passed (schemas should have ids), the second parameter will be ignored.")]),t._v(" "),a("p",[t._v("Key can be passed that can be used to reference the schema and will be used as the schema id if there is no id inside the schema. If the key is not passed, the schema id will be used as the key.")]),t._v(" "),a("p",[t._v("Once the schema is added, it (and all the references inside it) can be referenced in other schemas and used to validate data.")]),t._v(" "),a("p",[t._v("Although "),a("code",[t._v("addSchema")]),t._v(" does not compile schemas, explicit compilation is not required - the schema will be compiled when it is used first time.")]),t._v(" "),a("p",[t._v("By default the schema is validated against meta-schema before it is added, and if the schema does not pass validation the exception is thrown. This behaviour is controlled by "),a("code",[t._v("validateSchema")]),t._v(" option.")]),t._v(" "),a("div",{staticClass:"custom-block tip"},[a("p",{staticClass:"custom-block-title"},[t._v("Method chaining")]),t._v(" "),a("p",[t._v("Ajv returns its instance for chaining from all methods prefixed "),a("code",[t._v("add*")]),t._v(" and "),a("code",[t._v("remove*")]),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 keyword"}},[t._v("const")]),t._v(" validate "),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 punctuation"}},[t._v(".")]),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("addSchema")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("schema"),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 function"}},[t._v("addFormat")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("name"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" regex"),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 function"}},[t._v("getSchema")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("uri"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n")])])])]),t._v(" "),a("h3",{attrs:{id:"ajv-addmetaschema-schema-object-object-key-string-ajv"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#ajv-addmetaschema-schema-object-object-key-string-ajv"}},[t._v("#")]),t._v(" ajv.addMetaSchema(schema: object | object[], key?: string): Ajv")]),t._v(" "),a("p",[t._v("Adds meta schema(s) that can be used to validate other schemas. That function should be used instead of "),a("code",[t._v("addSchema")]),t._v(" because there may be instance options that would compile a meta schema incorrectly (at the moment it is "),a("code",[t._v("removeAdditional")]),t._v(" option).")]),t._v(" "),a("p",[t._v("There is no need to explicitly add draft-07 meta schema (http://json-schema.org/draft-07/schema) - it is added by default, unless option "),a("code",[t._v("meta")]),t._v(" is set to "),a("code",[t._v("false")]),t._v(". You only need to use it if you have a changed meta-schema that you want to use to validate your schemas. See "),a("code",[t._v("validateSchema")]),t._v(".")]),t._v(" "),a("p",[a("a",{attrs:{name:"api-validateschema"}})]),t._v(" "),a("h3",{attrs:{id:"ajv-validateschema-schema-object-boolean"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#ajv-validateschema-schema-object-boolean"}},[t._v("#")]),t._v(" ajv.validateSchema(schema: object): boolean")]),t._v(" "),a("p",[t._v("Validates schema. This method should be used to validate schemas rather than "),a("code",[t._v("validate")]),t._v(" due to the inconsistency of "),a("code",[t._v("uri")]),t._v(" format in JSON Schema standard.")]),t._v(" "),a("p",[t._v("By default this method is called automatically when the schema is added, so you rarely need to use it directly.")]),t._v(" "),a("p",[t._v("If schema doesn't have "),a("code",[t._v("$schema")]),t._v(" property, it is validated against draft 6 meta-schema (option "),a("code",[t._v("meta")]),t._v(" should not be false).")]),t._v(" "),a("p",[t._v("If schema has "),a("code",[t._v("$schema")]),t._v(" property, then the schema with this id (that should be previously added) is used to validate passed schema.")]),t._v(" "),a("p",[t._v("Errors will be available at "),a("code",[t._v("ajv.errors")]),t._v(".")]),t._v(" "),a("h3",{attrs:{id:"ajv-getschema-key-string-undefined-data-any-boolean-promise-any"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#ajv-getschema-key-string-undefined-data-any-boolean-promise-any"}},[t._v("#")]),t._v(" ajv.getSchema(key: string): undefined | ((data: any) => boolean | Promise < any >)")]),t._v(" "),a("p",[t._v("Retrieve compiled schema previously added with "),a("code",[t._v("addSchema")]),t._v(" by the key passed to "),a("code",[t._v("addSchema")]),t._v(" or by its full reference (id). The returned validating function has "),a("code",[t._v("schema")]),t._v(" property with the reference to the original schema.")]),t._v(" "),a("h3",{attrs:{id:"ajv-removeschema-schemaorref-object-string-regexp-ajv"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#ajv-removeschema-schemaorref-object-string-regexp-ajv"}},[t._v("#")]),t._v(" ajv.removeSchema(schemaOrRef: object | string | RegExp): Ajv")]),t._v(" "),a("p",[t._v("Remove added/cached schema. Even if schema is referenced by other schemas it can be safely removed as dependent schemas have local references.")]),t._v(" "),a("p",[t._v("Schema can be removed using:")]),t._v(" "),a("ul",[a("li",[t._v("key passed to "),a("code",[t._v("addSchema")])]),t._v(" "),a("li",[t._v("it's full reference (id)")]),t._v(" "),a("li",[t._v("RegExp that should match schema id or key (meta-schemas won't be removed)")]),t._v(" "),a("li",[t._v("actual schema object (that will be optionally serialized) to remove schema from cache")])]),t._v(" "),a("p",[t._v("If no parameter is passed all schemas but meta-schemas will be removed and the cache will be cleared.")]),t._v(" "),a("p",[a("a",{attrs:{name:"api-addformat"}})]),t._v(" "),a("h3",{attrs:{id:"ajv-addformat-name-string-format-format-ajv"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#ajv-addformat-name-string-format-format-ajv"}},[t._v("#")]),t._v(" ajv.addFormat(name: string, format: Format): Ajv")]),t._v(" "),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("type")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("Format")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v("\n "),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(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// to ignore this format (and pass validation)")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("|")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("string")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// will be converted to RegExp")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("|")]),t._v(" RegExp\n "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("|")]),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 builtin"}},[t._v("string")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=>")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("boolean")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("|")]),t._v(" Object "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// format definition (see below and in types)")]),t._v("\n")])])]),a("p",[t._v("Add format to validate strings or numbers.")]),t._v(" "),a("p",[t._v("If object is passed it should have properties "),a("code",[t._v("validate")]),t._v(", "),a("code",[t._v("compare")]),t._v(" and "),a("code",[t._v("async")]),t._v(":")]),t._v(" "),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("interface")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("FormatDefinition")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// actual type definition is more precise - see types.ts")]),t._v("\n validate"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("string")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("|")]),t._v(" RegExp "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("|")]),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 builtin"}},[t._v("number")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("|")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("string")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=>")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("boolean")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("|")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("Promise")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<")]),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("boolean")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(">")]),t._v("\n compare"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("data1"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("string")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" data2"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("string")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("number")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// an optional function that accepts two strings")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// and compares them according to the format meaning.")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// This function is used with keywords `formatMaximum`/`formatMinimum`")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// (defined in [ajv-keywords](https://github.com/ajv-validator/ajv-keywords) package).")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// It should return `1` if the first value is bigger than the second value,")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// `-1` if it is smaller and `0` if it is equal.")]),t._v("\n async"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),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(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// if `validate` is an asynchronous function")]),t._v("\n type"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"string"')]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("|")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"number"')]),t._v(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v('// "string" is default. If data type is different, the validation will pass.')]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])]),a("p",[t._v("Formats can be also added via "),a("code",[t._v("formats")]),t._v(" option.")]),t._v(" "),a("p",[a("a",{attrs:{name:"api-addkeyword"}})]),t._v(" "),a("h3",{attrs:{id:"ajv-addkeyword-definition-string-object-ajv"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#ajv-addkeyword-definition-string-object-ajv"}},[t._v("#")]),t._v(" ajv.addKeyword(definition: string | object): Ajv")]),t._v(" "),a("p",[t._v("Add validation keyword to Ajv instance.")]),t._v(" "),a("p",[t._v("Keyword should be different from all standard JSON Schema keywords and different from previously defined keywords. There is no way to redefine keywords or to remove keyword definition from the instance.")]),t._v(" "),a("p",[t._v("Keyword must start with an ASCII letter, "),a("code",[t._v("_")]),t._v(" or "),a("code",[t._v("$")]),t._v(", and may continue with ASCII letters, numbers, "),a("code",[t._v("_")]),t._v(", "),a("code",[t._v("$")]),t._v(", "),a("code",[t._v("-")]),t._v(", or "),a("code",[t._v(":")]),t._v(".\nIt is recommended to use an application-specific prefix for keywords to avoid current and future name collisions.")]),t._v(" "),a("p",[t._v("Example Keywords:")]),t._v(" "),a("ul",[a("li",[a("code",[t._v('"xyz-example"')]),t._v(": valid, and uses prefix for the xyz project to avoid name collisions.")]),t._v(" "),a("li",[a("code",[t._v('"example"')]),t._v(": valid, but not recommended as it may collide with future versions of JSON Schema etc.")]),t._v(" "),a("li",[a("code",[t._v('"3-example"')]),t._v(": invalid as numbers are not allowed to be the first character in a keyword")])]),t._v(" "),a("p",[t._v("Keyword definition is an object with the following properties:")]),t._v(" "),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("interface")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("KeywordDefinition")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// actual type definition is more precise - see types.ts")]),t._v("\n keyword"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("string")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// keyword name")]),t._v("\n type"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("string")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("|")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[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(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// JSON data type(s) the keyword applies to. Default - all types.")]),t._v("\n schemaType"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("string")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("|")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[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(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// the required schema JSON type")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("code")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("Function")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// function to generate code, used for all pre-defined keywords")]),t._v("\n validate"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("Function")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// validating function")]),t._v("\n compile"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("Function")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// compiling function")]),t._v("\n macro"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("Function")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// macro function")]),t._v("\n error"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" object "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// error definition object - see types.ts")]),t._v("\n schema"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),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(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v('// used with "validate" keyword to not pass schema to function')]),t._v("\n metaSchema"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" object "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// meta-schema for keyword schema")]),t._v("\n dependencies"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[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(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// properties that must be present in the parent schema -")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// it will be checked during schema compilation")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("implements")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[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(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// keyword names to reserve that this keyword implements")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("modifying")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),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(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// MUST be passed if keyword modifies data")]),t._v("\n valid"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("boolean")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// to pre-define validation result, validation function result will be ignored -")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// this option MUST NOT be used with `macro` keywords.")]),t._v("\n $data"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),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(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// to support [\\$data reference](./guide/combining-schemas.md#data-reference) as the value of keyword.")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// The reference will be resolved at validation time. If the keyword has meta-schema,")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// it would be extended to allow $data and it will be used to validate the resolved value.")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// Supporting $data reference requires that keyword has `code` or `validate` function")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// (the latter can be used in addition to `compile` or `macro`).")]),t._v("\n $dataError"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" object "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// error definition object for invalid \\$data schema - see types.ts")]),t._v("\n async"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),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(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// if the validation function is asynchronous")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// (whether it is returned from `compile` or passed in `validate` property).")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// It should return a promise that resolves with a value `true` or `false`.")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v('// This option is ignored in case of "macro" and "code" keywords.')]),t._v("\n errors"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("boolean")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("|")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"full"')]),t._v(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// whether keyword returns errors.")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// If this property is not passed Ajv will determine")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// if the errors were set in case of failed validation.")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])]),a("p",[t._v("If only the property "),a("code",[t._v("keyword")]),t._v(" is provided in the definition object, you can also pass the keyword name as the argument.")]),t._v(" "),a("p",[a("code",[t._v("compile")]),t._v(", "),a("code",[t._v("macro")]),t._v(" and "),a("code",[t._v("code")]),t._v(" are mutually exclusive, only one should be used at a time. "),a("code",[t._v("validate")]),t._v(" can be used separately or in addition to "),a("code",[t._v("compile")]),t._v(" or "),a("code",[t._v("macro")]),t._v(" to support "),a("RouterLink",{attrs:{to:"/guide/combining-schemas.html#data-reference"}},[t._v("$data reference")]),t._v(".")],1),t._v(" "),a("div",{staticClass:"custom-block tip"},[a("p",{staticClass:"custom-block-title"},[t._v("Keyword is validated only for applicable data types")]),t._v(" "),a("p",[t._v("If the keyword is validating data type that is different from the type(s) in its definition, the validation function will not be called (and expanded macro will not be used), so there is no need to check for data type inside validation function or inside schema returned by macro function (unless you want to enforce a specific type and for some reason do not want to use a separate "),a("code",[t._v("type")]),t._v(" keyword for that). In the same way as standard keywords work, if the keyword does not apply to the data type being validated, the validation of this keyword will succeed.")])]),t._v(" "),a("p",[t._v("See "),a("RouterLink",{attrs:{to:"/keywords.html"}},[t._v("User defined keywords")]),t._v(" for more details.")],1),t._v(" "),a("h3",{attrs:{id:"ajv-getkeyword-keyword-string-object-boolean"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#ajv-getkeyword-keyword-string-object-boolean"}},[t._v("#")]),t._v(" ajv.getKeyword(keyword: string): object | boolean")]),t._v(" "),a("p",[t._v("Returns keyword definition, "),a("code",[t._v("false")]),t._v(" if the keyword is unknown.")]),t._v(" "),a("h3",{attrs:{id:"ajv-removekeyword-keyword-string-ajv"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#ajv-removekeyword-keyword-string-ajv"}},[t._v("#")]),t._v(" ajv.removeKeyword(keyword: string): Ajv")]),t._v(" "),a("p",[t._v("Removes added or pre-defined keyword so you can redefine them.")]),t._v(" "),a("p",[t._v("While this method can be used to extend pre-defined keywords, it can also be used to completely change their meaning - it may lead to unexpected results.")]),t._v(" "),a("div",{staticClass:"custom-block warning"},[a("p",{staticClass:"custom-block-title"},[t._v("Compiled schemas and removed keywords")]),t._v(" "),a("p",[t._v("The schemas compiled before the keyword is removed will continue to work without changes. To recompile schemas use "),a("code",[t._v("removeSchema")]),t._v(" method and compile them again.")])]),t._v(" "),a("h3",{attrs:{id:"ajv-errorstext-errors-object-options-object-string"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#ajv-errorstext-errors-object-options-object-string"}},[t._v("#")]),t._v(" ajv.errorsText(errors?: object[], options?: object): string")]),t._v(" "),a("p",[t._v("Returns the text with all errors in a String.")]),t._v(" "),a("p",[t._v("Options can have properties "),a("code",[t._v("separator")]),t._v(' (string used to separate errors, ", " by default) and '),a("code",[t._v("dataVar")]),t._v(' (the variable name that instancePath is prefixed with, "data" by default).')]),t._v(" "),a("h2",{attrs:{id:"validation-errors"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#validation-errors"}},[t._v("#")]),t._v(" Validation errors")]),t._v(" "),a("p",[t._v("In case of validation failure, Ajv assigns the array of errors to "),a("code",[t._v("errors")]),t._v(" property of validation function (or to "),a("code",[t._v("errors")]),t._v(" property of Ajv instance when "),a("code",[t._v("validate")]),t._v(" or "),a("code",[t._v("validateSchema")]),t._v(" methods were called). In case of "),a("RouterLink",{attrs:{to:"/guide/async-validation.html"}},[t._v("asynchronous validation")]),t._v(", the returned promise is rejected with exception "),a("code",[t._v("Ajv.ValidationError")]),t._v(" that has "),a("code",[t._v("errors")]),t._v(" property.")],1),t._v(" "),a("h3",{attrs:{id:"error-objects"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#error-objects"}},[t._v("#")]),t._v(" Error objects")]),t._v(" "),a("p",[t._v("Each reported error is an object with the following properties:")]),t._v(" "),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("interface")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("ErrorObject")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n keyword"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("string")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// validation keyword.")]),t._v("\n instancePath"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("string")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v('// JSON Pointer to the location in the data instance (e.g., `"/prop/1/subProp"`).')]),t._v("\n schemaPath"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("string")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// JSON Pointer to the location of the failing keyword in the schema")]),t._v("\n params"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" object "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// type is defined by keyword value, see below")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// params property is the object with the additional information about error")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// it can be used to generate error messages")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// (e.g., using [ajv-i18n](https://github.com/ajv-validator/ajv-i18n) package).")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// See below for parameters set by all keywords.")]),t._v("\n propertyName"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("string")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// set for errors in `propertyNames` keyword schema.")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// `instancePath` still points to the object in this case.")]),t._v("\n message"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("string")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// the error message (can be excluded with option `messages: false`).")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// Options below are added with `verbose` option:")]),t._v("\n schema"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("any")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// the value of the failing keyword in the schema.")]),t._v("\n parentSchema"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" object "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// the schema containing the keyword.")]),t._v("\n data"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("any")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// the data validated by the keyword.")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])]),a("p",[t._v("For "),a("RouterLink",{attrs:{to:"/json-type-definition.html"}},[t._v("JTD")]),t._v(" schemas "),a("code",[t._v("instancePath")]),t._v(" and "),a("code",[t._v("schemaPath")]),t._v(" depend on the nature of the failure - the errors are consistent with "),a("a",{attrs:{href:"https://datatracker.ietf.org/doc/rfc8927/",target:"_blank",rel:"noopener noreferrer"}},[t._v("RFC8927"),a("OutboundLink")],1),t._v(".")],1),t._v(" "),a("h3",{attrs:{id:"error-parameters"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#error-parameters"}},[t._v("#")]),t._v(" Error parameters")]),t._v(" "),a("p",[t._v("Properties of "),a("code",[t._v("params")]),t._v(" object in errors depend on the keyword that failed validation.")]),t._v(" "),a("p",[t._v("In typescript, the ErrorObject is a discriminated union that allows to determine the type of error parameters based on the value of keyword:")]),t._v(" "),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("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 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 generic-function"}},[a("span",{pre:!0,attrs:{class:"token function"}},[t._v("compile")]),a("span",{pre:!0,attrs:{class:"token generic class-name"}},[a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<")]),t._v("MyData"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(">")])])]),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"),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 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(")")]),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 comment"}},[t._v("// data is MyData here")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// ...")]),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 "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// DefinedError is a type for all pre-defined keywords errors,")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// validate.errors has type ErrorObject[] - to allow user-defined keywords with any error parameters.")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// Users can extend DefinedError to include the keywords errors they defined.")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("for")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" err "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("of")]),t._v(" validate"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("errors "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("as")]),t._v(" DefinedError"),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 punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("switch")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("err"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("keyword"),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("case")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"maximum"')]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token builtin"}},[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("err"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("limit"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("break")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("case")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"pattern"')]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token builtin"}},[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("err"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("pattern"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("break")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token comment"}},[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",[t._v("Also see an example in "),a("a",{attrs:{href:"https://github.com/ajv-validator/ajv/blob/master/spec/types/error-parameters.spec.ts",target:"_blank",rel:"noopener noreferrer"}},[t._v("this test"),a("OutboundLink")],1)]),t._v(" "),a("ul",[a("li",[a("code",[t._v("maxItems")]),t._v(", "),a("code",[t._v("minItems")]),t._v(", "),a("code",[t._v("maxLength")]),t._v(", "),a("code",[t._v("minLength")]),t._v(", "),a("code",[t._v("maxProperties")]),t._v(", "),a("code",[t._v("minProperties")]),t._v(":")])]),t._v(" "),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("type")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("ErrorParams")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("limit"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("number")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// keyword value")]),t._v("\n")])])]),a("ul",[a("li",[a("code",[t._v("additionalItems")]),t._v(":")])]),t._v(" "),a("div",{staticClass:"language-typescript extra-class"},[a("pre",{pre:!0,attrs:{class:"language-typescript"}},[a("code",[a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// when `items` is an array of schemas and `additionalItems` is false:")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("type")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("ErrorParams")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("limit"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("number")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// the maximum number of allowed items")]),t._v("\n")])])]),a("ul",[a("li",[a("code",[t._v("additionalProperties")]),t._v(":")])]),t._v(" "),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("type")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("ErrorParams")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("additionalProperty"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("string")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// the property not defined in `properties` and `patternProperties` keywords")]),t._v("\n")])])]),a("ul",[a("li",[a("code",[t._v("dependencies")]),t._v(":")])]),t._v(" "),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("type")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("ErrorParams")]),t._v(" "),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 property"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("string")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// dependent property,")]),t._v("\n missingProperty"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("string")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// required missing dependency - only the first one is reported")]),t._v("\n deps"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("string")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// required dependencies, comma separated list as a string (TODO change to string[])")]),t._v("\n depsCount"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("number")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// the number of required dependencies")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])]),a("ul",[a("li",[a("code",[t._v("format")]),t._v(":")])]),t._v(" "),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("type")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("ErrorParams")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("format"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("string")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// keyword value")]),t._v("\n")])])]),a("ul",[a("li",[a("code",[t._v("maximum")]),t._v(", "),a("code",[t._v("minimum")]),t._v(", "),a("code",[t._v("exclusiveMaximum")]),t._v(", "),a("code",[t._v("exclusiveMinimum")]),t._v(":")])]),t._v(" "),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("type")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("ErrorParams")]),t._v(" "),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 limit"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("number")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// keyword value")]),t._v("\n comparison"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"<="')]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("|")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('">="')]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("|")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"<"')]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("|")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('">"')]),t._v(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// operation to compare the data to the limit,")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// with data on the left and the limit on the right")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])]),a("ul",[a("li",[a("code",[t._v("multipleOf")]),t._v(":")])]),t._v(" "),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("type")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("ErrorParams")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("multipleOf"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("number")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// keyword value")]),t._v("\n")])])]),a("ul",[a("li",[a("code",[t._v("pattern")]),t._v(":")])]),t._v(" "),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("type")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("ErrorParams")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("pattern"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("string")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// keyword value")]),t._v("\n")])])]),a("ul",[a("li",[a("code",[t._v("required")]),t._v(":")])]),t._v(" "),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("type")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("ErrorParams")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("missingProperty"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("string")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// required property that is missing")]),t._v("\n")])])]),a("ul",[a("li",[a("code",[t._v("propertyNames")]),t._v(":")])]),t._v(" "),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("type")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("ErrorParams")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("propertyName"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("string")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// invalid property name")]),t._v("\n")])])]),a("p",[t._v("User-defined keywords can define other keyword parameters.")]),t._v(" "),a("h3",{attrs:{id:"errors-i18n"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#errors-i18n"}},[t._v("#")]),t._v(" Errors i18n")]),t._v(" "),a("p",[t._v("You can use "),a("a",{attrs:{href:"https://github.com/ajv-validator/ajv-i18n",target:"_blank",rel:"noopener noreferrer"}},[t._v("ajv-i18n"),a("OutboundLink")],1),t._v(" package to generate errors in other languages.")]),t._v(" "),a("h3",{attrs:{id:"error-logging"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#error-logging"}},[t._v("#")]),t._v(" Error logging")]),t._v(" "),a("p",[t._v("A logger instance can be passed via "),a("code",[t._v("logger")]),t._v(" option to Ajv constructor. The use of other logging packages is supported as long as the package or its associated wrapper exposes the required methods. If any of the required methods are missing an exception will be thrown.")]),t._v(" "),a("ul",[a("li",[a("strong",[t._v("Required Methods")]),t._v(": "),a("code",[t._v("log")]),t._v(", "),a("code",[t._v("warn")]),t._v(", "),a("code",[t._v("error")])])]),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(" otherLogger "),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("OtherLogger")]),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("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 literal-property property"}},[t._v("logger")]),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("log")]),a("span",{pre:!0,attrs:{class:"token operator"}},[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(".")]),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("bind")]),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 punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token function-variable function"}},[t._v("warn")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("function")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("warn")]),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("{")]),t._v("\n otherLogger"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("logWarn")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("apply")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("otherLogger"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" arguments"),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 function-variable function"}},[t._v("error")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("function")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("error")]),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("{")]),t._v("\n otherLogger"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("logError")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("apply")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("otherLogger"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" arguments"),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("error")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("apply")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("console"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" arguments"),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("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n")])])]),a("h5",{attrs:{id:"options"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#options"}},[t._v("#")]),t._v(" Options")]),t._v(" "),a("p",[t._v("This section is moved to "),a("RouterLink",{attrs:{to:"/options.html"}},[t._v("Initialization options")]),t._v(" page")],1)])}),[],!1,null,null,null);a.default=r.exports}}]); \ No newline at end of file diff --git a/assets/js/45.80625da8.js b/assets/js/45.80625da8.js new file mode 100644 index 000000000..3e94e01c8 --- /dev/null +++ b/assets/js/45.80625da8.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[45],{475:function(e,t,o){"use strict";o.r(t);var a=o(14),i=Object(a.a)({},(function(){var e=this,t=e._self._c;return t("ContentSlotsDistributor",{attrs:{"slot-key":e.$parent.slotKey}},[t("h1",{attrs:{id:"contributor-covenant-code-of-conduct"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#contributor-covenant-code-of-conduct"}},[e._v("#")]),e._v(" Contributor Covenant Code of Conduct")]),e._v(" "),t("h3",{attrs:{id:"our-pledge"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#our-pledge"}},[e._v("#")]),e._v(" Our Pledge")]),e._v(" "),t("p",[e._v("We commit to creating and maintaining an open and welcoming environment. We, as contributors and maintainers, commit to building a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.")]),e._v(" "),t("h3",{attrs:{id:"our-standards"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#our-standards"}},[e._v("#")]),e._v(" Our Standards")]),e._v(" "),t("p",[t("strong",[e._v("Behaviour that contributes to creating a positive environment include")]),e._v(":")]),e._v(" "),t("ul",[t("li",[e._v("Using welcoming and inclusive language\n"),t("ul",[t("li",[e._v("Consider when identity words like race or ethnicity matter")]),e._v(" "),t("li",[e._v("Be conscious of language with discriminatory connotations (e.g. gendered, ableist, racialized phrases)")]),e._v(" "),t("li",[e._v("Be open to being corrected if you make a mistake - it’s okay to mess up, what matters is your follow up")])])]),e._v(" "),t("li",[e._v("Gracefully accepting constructive criticism")]),e._v(" "),t("li",[e._v("Showing empathy towards other community members")]),e._v(" "),t("li",[e._v("Treat other community members and project team members with respect")]),e._v(" "),t("li",[e._v("Report if you witness harassment or wrongdoing in our spaces")])]),e._v(" "),t("p",[t("strong",[e._v("Unacceptable behaviour by participants include")]),e._v(":")]),e._v(" "),t("ul",[t("li",[e._v("The use of sexualized language or imagery and unwelcome sexual attention or advances")]),e._v(" "),t("li",[e._v("Trolling, insulting/derogatory comments, and personal or political attacks")]),e._v(" "),t("li",[e._v("Public or private harassment")]),e._v(" "),t("li",[e._v("Publishing others' private information, such as a physical or electronic address, without explicit permission")]),e._v(" "),t("li",[e._v("Other conduct which could reasonably be considered inappropriate in a professional setting")])]),e._v(" "),t("h3",{attrs:{id:"our-responsibilities"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#our-responsibilities"}},[e._v("#")]),e._v(" Our Responsibilities")]),e._v(" "),t("p",[e._v("Project maintainers are responsible for clarifying the standards of acceptable behaviour and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behaviour.")]),e._v(" "),t("p",[e._v("Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.")]),e._v(" "),t("h3",{attrs:{id:"scope"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#scope"}},[e._v("#")]),e._v(" Scope")]),e._v(" "),t("p",[e._v("The goal of this Code of Conduct is to set standards and expectations around how we interact within this community. It’s scope applies to all project participants and covers all interactions within the community associated with this project including, but not limited to, email communication, issue trackers, source code repositories, forums, and social media.")]),e._v(" "),t("p",[e._v("Examples of representing a project or community include:")]),e._v(" "),t("ul",[t("li",[e._v("Using an official project e-mail address")]),e._v(" "),t("li",[e._v("Posting via an official social media account")]),e._v(" "),t("li",[e._v("Acting as an appointed representative at an online or offline event")])]),e._v(" "),t("p",[e._v("Representation of a project may be further defined and clarified by project maintainers.")]),e._v(" "),t("h3",{attrs:{id:"enforcement"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#enforcement"}},[e._v("#")]),e._v(" Enforcement")]),e._v(" "),t("p",[e._v("We will not tolerate abuse, harassment, or any other unacceptable behaviour made against community members, project maintainers, or members of our project team, either online or offline.")]),e._v(" "),t("p",[e._v("Violations of our Code of Conduct may be reported by contacting the project team at "),t("a",{attrs:{href:"mailto:ajv.validator@gmail.com"}},[e._v("ajv.validator@gmail.com")]),e._v(". The project team will review and investigate all complaints, to the best of our ability, and will respond in a way that it deems appropriate to the circumstances.")]),e._v(" "),t("p",[e._v("Reports of violations will be investigated in a respectful, professional manner as promptly and confidentially as possible. We will have zero tolerance for intimidation or retaliation against anyone who raises a concern, makes a report or cooperates in an investigation around a violation of our code of conduct. Further details of specific enforcement policies may be posted separately.")]),e._v(" "),t("p",[e._v("Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions or removal as determined by other members of the project's leadership.")]),e._v(" "),t("h3",{attrs:{id:"attribution"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#attribution"}},[e._v("#")]),e._v(" Attribution")]),e._v(" "),t("p",[e._v("This Code of Conduct is adapted from the "),t("a",{attrs:{href:"https://www.contributor-covenant.org",target:"_blank",rel:"noopener noreferrer"}},[e._v("Contributor Covenant"),t("OutboundLink")],1),e._v(", version 1.4,\navailable at "),t("a",{attrs:{href:"https://www.contributor-covenant.org/version/1/4/code-of-conduct.html",target:"_blank",rel:"noopener noreferrer"}},[e._v("https://www.contributor-covenant.org/version/1/4/code-of-conduct.html"),t("OutboundLink")],1)]),e._v(" "),t("p",[e._v("For answers to common questions about this code of conduct, see\n"),t("a",{attrs:{href:"https://www.contributor-covenant.org/faq",target:"_blank",rel:"noopener noreferrer"}},[e._v("https://www.contributor-covenant.org/faq"),t("OutboundLink")],1)])])}),[],!1,null,null,null);t.default=i.exports}}]); \ No newline at end of file diff --git a/assets/js/46.ad06d4d0.js b/assets/js/46.ad06d4d0.js new file mode 100644 index 000000000..80531db0b --- /dev/null +++ b/assets/js/46.ad06d4d0.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[46],{476:function(t,e,s){"use strict";s.r(e);var a=s(14),n=Object(a.a)({},(function(){var t=this,e=t._self._c;return e("ContentSlotsDistributor",{attrs:{"slot-key":t.$parent.slotKey}},[e("h1",{attrs:{id:"code-generation-design"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#code-generation-design"}},[t._v("#")]),t._v(" Code generation design")]),t._v(" "),e("p"),e("div",{staticClass:"table-of-contents"},[e("ul",[e("li",[e("a",{attrs:{href:"#safe-code-generation"}},[t._v("Safe code generation")])]),e("li",[e("a",{attrs:{href:"#code-optimization"}},[t._v("Code optimization")])]),e("li",[e("a",{attrs:{href:"#user-defined-keywords"}},[t._v("User-defined keywords")])])])]),e("p"),t._v(" "),e("p",[t._v("Starting from v7 Ajv uses "),e("a",{attrs:{href:"https://github.com/ajv-validator/ajv/blob/master/lib/compile/codegen/index.ts",target:"_blank",rel:"noopener noreferrer"}},[t._v("CodeGen module"),e("OutboundLink")],1),t._v(" that replaced "),e("a",{attrs:{href:"https://github.com/olado/dot",target:"_blank",rel:"noopener noreferrer"}},[t._v("doT"),e("OutboundLink")],1),t._v(" templates used earlier.")]),t._v(" "),e("p",[t._v("The motivations for this change:")]),t._v(" "),e("ul",[e("li",[t._v("doT templates were difficult to maintain and to change, particularly for the occasional contributors.")]),t._v(" "),e("li",[t._v("they discouraged modularity within validation keywords code and also led to implicit dependencies between different parts of code.")]),t._v(" "),e("li",[t._v("they had risks of remote code execution in case untrusted schemas were used, even though all identified issues were patched.")]),t._v(" "),e("li",[t._v("ES6 template literals that are now widely supported offer a great alternative to both ASTs and to plain string concatenation - this option was not available when Ajv started.")])]),t._v(" "),e("h2",{attrs:{id:"safe-code-generation"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#safe-code-generation"}},[t._v("#")]),t._v(" Safe code generation")]),t._v(" "),e("p",[t._v("CodeGen module defines two tagged templates that should be passed to all code generation methods and used in other tagged templates:")]),t._v(" "),e("ul",[e("li",[e("code",[t._v("_")]),t._v(" - to create instances of private _Code class that will not be escaped when used in code or other tagged templates.")]),t._v(" "),e("li",[e("code",[t._v("str")]),t._v(" - to create code for string expressions.")])]),t._v(" "),e("p",[t._v("For example, this code:")]),t._v(" "),e("div",{staticClass:"language-typescript extra-class"},[e("pre",{pre:!0,attrs:{class:"language-typescript"}},[e("code",[e("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" x "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token number"}},[t._v("0")]),t._v("\n"),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// Name is a subclass of _Code that can be safely used in code - it only allows valid identifiers")]),t._v("\n"),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v('// gen.const creates a unique variable name with the prefix "num".')]),t._v("\n"),e("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" num"),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" Name "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" gen"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),e("span",{pre:!0,attrs:{class:"token function"}},[t._v("const")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),e("span",{pre:!0,attrs:{class:"token string"}},[t._v('"num"')]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token number"}},[t._v("5")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\ngen"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),e("span",{pre:!0,attrs:{class:"token function"}},[t._v("if")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// _`...` returns the instance of _Code with safe interpolation of `num` and `x`.")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// if `x` was a string, it would be inserted into code as a quoted string value rather than as a code fragment,")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// so if `x` contained some code, it would not be executed.")]),t._v("\n _"),e("span",{pre:!0,attrs:{class:"token template-string"}},[e("span",{pre:!0,attrs:{class:"token template-punctuation string"}},[t._v("`")]),e("span",{pre:!0,attrs:{class:"token interpolation"}},[e("span",{pre:!0,attrs:{class:"token interpolation-punctuation punctuation"}},[t._v("${")]),t._v("num"),e("span",{pre:!0,attrs:{class:"token interpolation-punctuation punctuation"}},[t._v("}")])]),e("span",{pre:!0,attrs:{class:"token string"}},[t._v(" > ")]),e("span",{pre:!0,attrs:{class:"token interpolation"}},[e("span",{pre:!0,attrs:{class:"token interpolation-punctuation punctuation"}},[t._v("${")]),t._v("x"),e("span",{pre:!0,attrs:{class:"token interpolation-punctuation punctuation"}},[t._v("}")])]),e("span",{pre:!0,attrs:{class:"token template-punctuation string"}},[t._v("`")])]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=>")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token function"}},[t._v("log")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),e("span",{pre:!0,attrs:{class:"token string"}},[t._v('"greater"')]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=>")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token function"}},[t._v("log")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),e("span",{pre:!0,attrs:{class:"token string"}},[t._v('"smaller or equal"')]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n\n"),e("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("function")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token function"}},[t._v("log")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("comparison"),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("string")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("void")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// msg creates a string expression with concatenation - see generated code below")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// type Code = _Code | Name, _Code can only be constructed with template literals")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" msg"),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" Code "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" str"),e("span",{pre:!0,attrs:{class:"token template-string"}},[e("span",{pre:!0,attrs:{class:"token template-punctuation string"}},[t._v("`")]),e("span",{pre:!0,attrs:{class:"token interpolation"}},[e("span",{pre:!0,attrs:{class:"token interpolation-punctuation punctuation"}},[t._v("${")]),t._v("num"),e("span",{pre:!0,attrs:{class:"token interpolation-punctuation punctuation"}},[t._v("}")])]),e("span",{pre:!0,attrs:{class:"token string"}},[t._v(" is ")]),e("span",{pre:!0,attrs:{class:"token interpolation"}},[e("span",{pre:!0,attrs:{class:"token interpolation-punctuation punctuation"}},[t._v("${")]),t._v("comparison"),e("span",{pre:!0,attrs:{class:"token interpolation-punctuation punctuation"}},[t._v("}")])]),e("span",{pre:!0,attrs:{class:"token string"}},[t._v(" than ")]),e("span",{pre:!0,attrs:{class:"token interpolation"}},[e("span",{pre:!0,attrs:{class:"token interpolation-punctuation punctuation"}},[t._v("${")]),t._v("x"),e("span",{pre:!0,attrs:{class:"token interpolation-punctuation punctuation"}},[t._v("}")])]),e("span",{pre:!0,attrs:{class:"token template-punctuation string"}},[t._v("`")])]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// msg is _Code instance, so it will be inserted via another template without quotes")]),t._v("\n gen"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),e("span",{pre:!0,attrs:{class:"token function"}},[t._v("code")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("_"),e("span",{pre:!0,attrs:{class:"token template-string"}},[e("span",{pre:!0,attrs:{class:"token template-punctuation string"}},[t._v("`")]),e("span",{pre:!0,attrs:{class:"token string"}},[t._v("console.log(")]),e("span",{pre:!0,attrs:{class:"token interpolation"}},[e("span",{pre:!0,attrs:{class:"token interpolation-punctuation punctuation"}},[t._v("${")]),t._v("msg"),e("span",{pre:!0,attrs:{class:"token interpolation-punctuation punctuation"}},[t._v("}")])]),e("span",{pre:!0,attrs:{class:"token string"}},[t._v(")")]),e("span",{pre:!0,attrs:{class:"token template-punctuation string"}},[t._v("`")])]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])]),e("p",[t._v("generates this javascript code:")]),t._v(" "),e("div",{staticClass:"language-javascript extra-class"},[e("pre",{pre:!0,attrs:{class:"language-javascript"}},[e("code",[e("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" num0 "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token number"}},[t._v("5")]),t._v("\n"),e("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("if")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("num0 "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(">")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token number"}},[t._v("0")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n console"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),e("span",{pre:!0,attrs:{class:"token function"}},[t._v("log")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("num0 "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("+")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token string"}},[t._v('" is greater than 0"')]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("else")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n console"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),e("span",{pre:!0,attrs:{class:"token function"}},[t._v("log")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("num0 "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("+")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token string"}},[t._v('" is smaller or equal than 0"')]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])]),e("p",[e("code",[t._v(".const")]),t._v(", "),e("code",[t._v(".if")]),t._v(" and "),e("code",[t._v(".code")]),t._v(" above are methods of CodeGen class that generate code inside class instance "),e("code",[t._v("gen")]),t._v(" - see "),e("a",{attrs:{href:"https://github.com/ajv-validator/ajv/blob/master/lib/compile/codegen/index.ts",target:"_blank",rel:"noopener noreferrer"}},[t._v("source code"),e("OutboundLink")],1),t._v(" for all available methods and "),e("a",{attrs:{href:"https://github.com/ajv-validator/ajv/blob/master/spec/codegen.spec.ts",target:"_blank",rel:"noopener noreferrer"}},[t._v("tests"),e("OutboundLink")],1),t._v(" for other code generation examples.")]),t._v(" "),e("p",[t._v("These methods only accept instances of private class "),e("code",[t._v("_Code")]),t._v(", other values will be rejected by Typescript compiler - the risk to pass unsafe string is mitigated on type level.")]),t._v(" "),e("p",[t._v("If a string variable were used in "),e("code",[t._v("_")]),t._v(" template literal, its value would be safely wrapped in quotes - in many cases it is quite useful, as it allows to inject values that can be either string or number via the same template. In the worst case, the generated code could be invalid, but it will prevent the risk of code execution that attacker could pass via untrusted schema as a string value that should be inserted in code (e.g., instead of a number). Also see the comment in the example.")]),t._v(" "),e("h2",{attrs:{id:"code-optimization"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#code-optimization"}},[t._v("#")]),t._v(" Code optimization")]),t._v(" "),e("p",[t._v("CodeGen class generates code trees and performs several optimizations before the code is rendered:")]),t._v(" "),e("ol",[e("li",[t._v("removes empty and unreachable branches (e.g. "),e("code",[t._v("else")]),t._v(" branch after "),e("code",[t._v("if(true)")]),t._v(", etc.).")]),t._v(" "),e("li",[t._v("removes unused variable declarations.")]),t._v(" "),e("li",[t._v('replaces variables that are used only once and assigned expressions that are explicitly marked as "constant" (i.e. having referential transparency) with the expressions themselves.')])]),t._v(" "),e("div",{staticClass:"custom-block warning"},[e("p",{staticClass:"custom-block-title"},[t._v("Optimizations assume no side effects")]),t._v(" "),e("p",[t._v("These optimizations assume that the expressions in "),e("code",[t._v("if")]),t._v(" conditions, "),e("code",[t._v("for")]),t._v(" statement headers and assigned expressions are free of any side effects - this is the case for all pre-defined validation keywords.")])]),t._v(" "),e("p",[t._v("See "),e("a",{attrs:{href:"https://github.com/ajv-validator/ajv/blob/master/spec/codegen.spec.ts",target:"_blank",rel:"noopener noreferrer"}},[t._v("these tests"),e("OutboundLink")],1),t._v(" for examples.")]),t._v(" "),e("p",[t._v("By default Ajv does 1-pass optimization - based on the test suite it reduces the code size by 10.5% and the number of tree nodes by 16.7% (TODO benchmark the validation time). The second optimization pass changes it by less than 0.1%, so you won't need it unless you have really complex schemas or if you generate standalone code and want it to pass relevant eslint rules.")]),t._v(" "),e("p",[t._v("Optimization mode can be changed with "),e("RouterLink",{attrs:{to:"/api.html#options"}},[t._v("options")]),t._v(":")],1),t._v(" "),e("ul",[e("li",[e("code",[t._v("{code: {optimize: false}}")]),t._v(" - to disable (e.g., when schema compilation time is more important),")]),t._v(" "),e("li",[e("code",[t._v("{code: {optimize: 2}}")]),t._v(" - 2-pass optimization.")])]),t._v(" "),e("h2",{attrs:{id:"user-defined-keywords"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#user-defined-keywords"}},[t._v("#")]),t._v(" User-defined keywords")]),t._v(" "),e("p",[t._v("While tagged template literals wrap passed strings based on their run-time values, CodeGen class methods rely on types to ensure safety of passed parameters - there is no run-time checks that the passed value is an instance of _Code class.")]),t._v(" "),e("p",[t._v("It is strongly recommended to define additional keywords only with Typescript - using plain JavaScript would still allow passing unsafe strings to code generation methods.")]),t._v(" "),e("div",{staticClass:"custom-block warning"},[e("p",{staticClass:"custom-block-title"},[t._v("Optimization and side-effects")]),t._v(" "),e("p",[t._v("If your user-defined keywords need to have side-effects that are removed by optimization (see above), you may need to disable it.")])])])}),[],!1,null,null,null);e.default=n.exports}}]); \ No newline at end of file diff --git a/assets/js/47.90eeca64.js b/assets/js/47.90eeca64.js new file mode 100644 index 000000000..8f823cdc1 --- /dev/null +++ b/assets/js/47.90eeca64.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[47],{478: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/48.24b46e89.js b/assets/js/48.24b46e89.js new file mode 100644 index 000000000..9aecf65c2 --- /dev/null +++ b/assets/js/48.24b46e89.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[48],{477:function(e,t,a){"use strict";a.r(t);var r=a(14),o=Object(r.a)({},(function(){var e=this,t=e._self._c;return t("ContentSlotsDistributor",{attrs:{"slot-key":e.$parent.slotKey}},[t("h1",{attrs:{id:"code-components"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#code-components"}},[e._v("#")]),e._v(" Code components")]),e._v(" "),t("p"),t("div",{staticClass:"table-of-contents"},[t("ul",[t("li",[t("a",{attrs:{href:"#ajv-classes"}},[e._v("Ajv classes")])]),t("li",[t("a",{attrs:{href:"#schema-compilation"}},[e._v("Schema compilation")])]),t("li",[t("a",{attrs:{href:"#other-components"}},[e._v("Other components")])])])]),t("p"),e._v(" "),t("h2",{attrs:{id:"ajv-classes"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#ajv-classes"}},[e._v("#")]),e._v(" Ajv classes")]),e._v(" "),t("p",[t("a",{attrs:{href:"https://github.com/ajv-validator/ajv/blob/master/lib/core.ts",target:"_blank",rel:"noopener noreferrer"}},[e._v("lib/core.ts"),t("OutboundLink")],1),e._v(" - core Ajv class without any keywords. All Ajv methods for managing schemas and extensions are defined in this class.")]),e._v(" "),t("p",[t("a",{attrs:{href:"https://github.com/ajv-validator/ajv/blob/master/lib/ajv.ts",target:"_blank",rel:"noopener noreferrer"}},[e._v("lib/ajv.ts"),t("OutboundLink")],1),e._v(" - subclass of Ajv core with JSON Schema draft-07 keywords.")]),e._v(" "),t("p",[t("a",{attrs:{href:"https://github.com/ajv-validator/ajv/blob/master/lib/2019.ts",target:"_blank",rel:"noopener noreferrer"}},[e._v("lib/2019.ts"),t("OutboundLink")],1),e._v(" - subclass of Ajv core with JSON Schema draft-2019-09 keywords.")]),e._v(" "),t("p",[t("a",{attrs:{href:"https://github.com/ajv-validator/ajv/blob/master/lib/jtd.ts",target:"_blank",rel:"noopener noreferrer"}},[e._v("lib/jtd.ts"),t("OutboundLink")],1),e._v(" - subclass of Ajv core with JSON Type Definition support.")]),e._v(" "),t("h2",{attrs:{id:"schema-compilation"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#schema-compilation"}},[e._v("#")]),e._v(" Schema compilation")]),e._v(" "),t("p",[t("a",{attrs:{href:"https://github.com/ajv-validator/ajv/blob/master/lib/compile",target:"_blank",rel:"noopener noreferrer"}},[e._v("lib/compile"),t("OutboundLink")],1),e._v(" - code for schema compilation")]),e._v(" "),t("p",[t("a",{attrs:{href:"https://github.com/ajv-validator/ajv/blob/master/lib/compile/index.ts",target:"_blank",rel:"noopener noreferrer"}},[e._v("lib/compile/index.ts"),t("OutboundLink")],1),e._v(" - the main recursive function code for schema compilation, functions for reference resolution, the interface for schema compilation context ("),t("code",[e._v("SchemaCxt")]),e._v(").")]),e._v(" "),t("p",[t("a",{attrs:{href:"https://github.com/ajv-validator/ajv/blob/master/lib/compile/context.ts",target:"_blank",rel:"noopener noreferrer"}},[e._v("lib/compile/context.ts"),t("OutboundLink")],1),e._v(" - the class for keyword code generation "),t("code",[e._v("KeywordCxt")]),e._v(". All pre-defined keywords and user-defined keywords that use "),t("code",[e._v("code")]),e._v(" function are passed an instance of this class.")]),e._v(" "),t("p",[t("a",{attrs:{href:"https://github.com/ajv-validator/ajv/blob/master/lib/compile/rules.ts",target:"_blank",rel:"noopener noreferrer"}},[e._v("lib/compile/rules.ts"),t("OutboundLink")],1),e._v(" - data structure to store references to all all keyword definitions that were added to Ajv instance, organised by data type.")]),e._v(" "),t("p",[t("a",{attrs:{href:"https://github.com/ajv-validator/ajv/blob/master/lib/compile/subschema.ts",target:"_blank",rel:"noopener noreferrer"}},[e._v("lib/compile/subschema.ts"),t("OutboundLink")],1),e._v(" - creates schema context ("),t("code",[e._v("SchemaCxt")]),e._v(") to generate code for subschemas - used by all applicator keywords in "),t("a",{attrs:{href:"https://github.com/ajv-validator/ajv/blob/master/lib/vocabularies/applicator",target:"_blank",rel:"noopener noreferrer"}},[e._v("lib/vocabularies/applicator"),t("OutboundLink")],1),e._v(".")]),e._v(" "),t("p",[t("a",{attrs:{href:"https://github.com/ajv-validator/ajv/blob/master/lib/compile/codegen",target:"_blank",rel:"noopener noreferrer"}},[e._v("lib/compile/codegen"),t("OutboundLink")],1),e._v(" - the api for "),t("RouterLink",{attrs:{to:"/codegen.html"}},[e._v("code generation")]),e._v(".")],1),e._v(" "),t("p",[t("a",{attrs:{href:"https://github.com/ajv-validator/ajv/blob/master/lib/compile/validate",target:"_blank",rel:"noopener noreferrer"}},[e._v("lib/compile/validate"),t("OutboundLink")],1),e._v(" - code to iterate the schema to generate code of validation function.")]),e._v(" "),t("h2",{attrs:{id:"other-components"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#other-components"}},[e._v("#")]),e._v(" Other components")]),e._v(" "),t("p",[t("a",{attrs:{href:"https://github.com/ajv-validator/ajv/blob/master/lib/standalone",target:"_blank",rel:"noopener noreferrer"}},[e._v("lib/standalone"),t("OutboundLink")],1),e._v(" - module to generate "),t("RouterLink",{attrs:{to:"/standalone.html"}},[e._v("standalone validation code")]),e._v(".")],1),e._v(" "),t("p",[t("a",{attrs:{href:"https://github.com/ajv-validator/ajv/blob/master/lib/vocabularies",target:"_blank",rel:"noopener noreferrer"}},[e._v("lib/vocabularies"),t("OutboundLink")],1),e._v(" - pre-defined validation keywords.")]),e._v(" "),t("p",[t("a",{attrs:{href:"https://github.com/ajv-validator/ajv/blob/master/lib/refs",target:"_blank",rel:"noopener noreferrer"}},[e._v("lib/refs"),t("OutboundLink")],1),e._v(" - JSON Schema meta-schemas.")])])}),[],!1,null,null,null);t.default=o.exports}}]); \ No newline at end of file diff --git a/assets/js/49.28645124.js b/assets/js/49.28645124.js new file mode 100644 index 000000000..dace86693 --- /dev/null +++ b/assets/js/49.28645124.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[49],{479:function(e,t,a){"use strict";a.r(t);var s=a(14),i=Object(s.a)({},(function(){var e=this,t=e._self._c;return t("ContentSlotsDistributor",{attrs:{"slot-key":e.$parent.slotKey}},[t("h1",{attrs:{id:"contributing-guide"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#contributing-guide"}},[e._v("#")]),e._v(" Contributing guide")]),e._v(" "),t("p",[e._v("Thank you for your help making Ajv better! Every contribution is appreciated. There are many areas where you can contribute.")]),e._v(" "),t("p",[e._v("More than 100 people contributed to Ajv, and we would love to have you join the development. We welcome implementing new features that will benefit many users and ideas to improve our documentation.")]),e._v(" "),t("p",[e._v("At Ajv, we are committed to creating more equitable and inclusive spaces for our community and team members to contribute to discussions that affect both this project and our ongoing work in the open source ecosystem.")]),e._v(" "),t("p",[e._v("We strive to create an environment of respect and healthy discourse by setting standards for our interactions and we expect it from all members of our community - from long term project member to first time visitor. For more information, review our "),t("RouterLink",{attrs:{to:"/CODE_OF_CONDUCT.html"}},[e._v("code of conduct")]),e._v(" and values.")],1),e._v(" "),t("div",{staticClass:"custom-block tip"},[t("p",{staticClass:"custom-block-title"},[e._v("Submit issue first")]),e._v(" "),t("p",[e._v("If you plan to implement a new feature or some other change please create an issue first, to make sure that your work is not lost.")])]),e._v(" "),t("p"),t("div",{staticClass:"table-of-contents"},[t("ul",[t("li",[t("a",{attrs:{href:"#documentation"}},[e._v("Documentation")])]),t("li",[t("a",{attrs:{href:"#issues"}},[e._v("Issues")]),t("ul",[t("li",[t("a",{attrs:{href:"#bug-reports"}},[e._v("Bug reports")])]),t("li",[t("a",{attrs:{href:"#security-vulnerabilities"}},[e._v("Security vulnerabilities")])]),t("li",[t("a",{attrs:{href:"#change-proposals"}},[e._v("Change proposals")])]),t("li",[t("a",{attrs:{href:"#browser-and-compatibility-issues"}},[e._v("Browser and compatibility issues")])]),t("li",[t("a",{attrs:{href:"#installation-and-dependency-issues"}},[e._v("Installation and dependency issues")])]),t("li",[t("a",{attrs:{href:"#using-json-schema-standard"}},[e._v("Using JSON Schema standard")])]),t("li",[t("a",{attrs:{href:"#ajv-usage-questions"}},[e._v("Ajv usage questions")])])])]),t("li",[t("a",{attrs:{href:"#code"}},[e._v("Code")]),t("ul",[t("li",[t("a",{attrs:{href:"#how-we-make-decisions"}},[e._v("How we make decisions")])]),t("li",[t("a",{attrs:{href:"#development"}},[e._v("Development")])]),t("li",[t("a",{attrs:{href:"#pull-requests"}},[e._v("Pull requests")])]),t("li",[t("a",{attrs:{href:"#contributions-license"}},[e._v("Contributions license")])])])])])]),t("p"),e._v(" "),t("h2",{attrs:{id:"documentation"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#documentation"}},[e._v("#")]),e._v(" Documentation")]),e._v(" "),t("p",[e._v("Ajv has a lot of features and maintaining documentation takes time. If anything is unclear, or could be explained better, we appreciate the time you spend correcting or clarifying it.")]),e._v(" "),t("p",[e._v("There is a link in the bottom of each website page to quickly edit it.")]),e._v(" "),t("h2",{attrs:{id:"issues"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#issues"}},[e._v("#")]),e._v(" Issues")]),e._v(" "),t("p",[e._v("Before submitting the issue:")]),e._v(" "),t("ul",[t("li",[e._v("Search the existing issues")]),e._v(" "),t("li",[e._v("Review "),t("RouterLink",{attrs:{to:"/faq.html"}},[e._v("Frequently Asked Questions")]),e._v(".")],1),e._v(" "),t("li",[e._v("Provide all the relevant information, reducing both your schema and data to the smallest possible size when they still have the issue.")])]),e._v(" "),t("p",[e._v("We value simplicity - simplifying the example that shows the issue makes it more valuable for other users. This process helps us reduce situations where an error is occurring due to incorrect usage rather than a bug.")]),e._v(" "),t("h3",{attrs:{id:"bug-reports"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#bug-reports"}},[e._v("#")]),e._v(" Bug reports")]),e._v(" "),t("p",[e._v("Please make sure to include the following information in the issue:")]),e._v(" "),t("ol",[t("li",[e._v("What version of Ajv are you using?")]),e._v(" "),t("li",[e._v("Does the issue happen if you use the latest version?")]),e._v(" "),t("li",[e._v("Ajv "),t("a",{attrs:{href:"./options"}},[e._v("options object")])]),e._v(" "),t("li",[e._v("Schema and the data you are validating (please make it as small as possible to reproduce the issue).")]),e._v(" "),t("li",[e._v("Your code sample (please use "),t("code",[e._v("options")]),e._v(", "),t("code",[e._v("schema")]),e._v(" and "),t("code",[e._v("data")]),e._v(" as variables).")]),e._v(" "),t("li",[e._v("Validation result, data AFTER validation, error messages.")]),e._v(" "),t("li",[e._v("What results did you expect?")])]),e._v(" "),t("p",[e._v("To speed up investigation and fixes, please include the link to the working code sample at runkit.com (please clone https://runkit.com/esp/ajv-issue).")]),e._v(" "),t("p",[t("a",{attrs:{href:"https://github.com/ajv-validator/ajv/issues/new?template=bug-or-error-report.md",target:"_blank",rel:"noopener noreferrer"}},[e._v("Create bug report"),t("OutboundLink")],1),e._v(".")]),e._v(" "),t("h3",{attrs:{id:"security-vulnerabilities"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#security-vulnerabilities"}},[e._v("#")]),e._v(" Security vulnerabilities")]),e._v(" "),t("p",[e._v("To report a security vulnerability, please use the\n"),t("a",{attrs:{href:"https://tidelift.com/security",target:"_blank",rel:"noopener noreferrer"}},[e._v("Tidelift security contact"),t("OutboundLink")],1),e._v(".\nTidelift will coordinate the fix and disclosure.")]),e._v(" "),t("p",[e._v("Please do NOT report security vulnerabilities via GitHub issues.")]),e._v(" "),t("p",[t("a",{attrs:{name:"changes"}})]),e._v(" "),t("h3",{attrs:{id:"change-proposals"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#change-proposals"}},[e._v("#")]),e._v(" Change proposals")]),e._v(" "),t("p",[t("a",{attrs:{href:"https://github.com/ajv-validator/ajv/issues/new?template=change.md",target:"_blank",rel:"noopener noreferrer"}},[e._v("Create a proposal"),t("OutboundLink")],1),e._v(" for a new feature, option or some other improvement.")]),e._v(" "),t("p",[e._v("Please include this information:")]),e._v(" "),t("ol",[t("li",[e._v("The version of Ajv you are using.")]),e._v(" "),t("li",[e._v("The problem you want to solve.")]),e._v(" "),t("li",[e._v("Your solution to the problem.")]),e._v(" "),t("li",[e._v("Would you like to implement it?")])]),e._v(" "),t("p",[e._v("If you’re requesting a change, it would be helpful to include this as well:")]),e._v(" "),t("ol",[t("li",[e._v("What you did.")]),e._v(" "),t("li",[e._v("What happened.")]),e._v(" "),t("li",[e._v("What you would like to happen.")])]),e._v(" "),t("p",[e._v("Please include as much details as possible - the more information, the better.")]),e._v(" "),t("p",[t("a",{attrs:{name:"compatibility"}})]),e._v(" "),t("h3",{attrs:{id:"browser-and-compatibility-issues"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#browser-and-compatibility-issues"}},[e._v("#")]),e._v(" Browser and compatibility issues")]),e._v(" "),t("p",[t("a",{attrs:{href:"https://github.com/ajv-validator/ajv/issues/new?template=compatibility.md",target:"_blank",rel:"noopener noreferrer"}},[e._v("Create an issue"),t("OutboundLink")],1),e._v(" to report a compatibility problem that only happens in a particular environment (when your code works correctly in the latest stable Node.js in linux systems but fails in some other environment).")]),e._v(" "),t("p",[e._v("Please include this information:")]),e._v(" "),t("ol",[t("li",[e._v("The version of Ajv you are using.")]),e._v(" "),t("li",[e._v("The environment you have the problem with.")]),e._v(" "),t("li",[e._v("Your code (please make it as small as possible to reproduce the issue).")]),e._v(" "),t("li",[e._v("If your issue is in the browser, please list the other packages loaded in the page in the order they are loaded. Please check if the issue gets resolved (or results change) if you move Ajv bundle closer to the top.")]),e._v(" "),t("li",[e._v("Results in the latest stable Node.js.")]),e._v(" "),t("li",[e._v("Results and error messages in your platform.")])]),e._v(" "),t("p",[t("a",{attrs:{name:"installation"}})]),e._v(" "),t("h3",{attrs:{id:"installation-and-dependency-issues"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#installation-and-dependency-issues"}},[e._v("#")]),e._v(" Installation and dependency issues")]),e._v(" "),t("p",[t("a",{attrs:{href:"https://github.com/ajv-validator/ajv/issues/new?template=installation.md",target:"_blank",rel:"noopener noreferrer"}},[e._v("Create an issue"),t("OutboundLink")],1),e._v(" to report problems that happen during Ajv installation or when Ajv is missing some dependency.")]),e._v(" "),t("p",[e._v("Before submitting the issue, please try the following:")]),e._v(" "),t("ul",[t("li",[e._v("use the latest stable Node.js and "),t("code",[e._v("npm")])]),e._v(" "),t("li",[e._v("try using "),t("code",[e._v("yarn")]),e._v(" instead of "),t("code",[e._v("npm")]),e._v(" - the issue can be related to https://github.com/npm/npm/issues/19877")]),e._v(" "),t("li",[e._v("remove "),t("code",[e._v("node_modules")]),e._v(" and "),t("code",[e._v("package-lock.json")]),e._v(" and run "),t("code",[e._v("npm install")]),e._v(" again")])]),e._v(" "),t("p",[e._v("If nothing helps, please submit:")]),e._v(" "),t("ol",[t("li",[e._v("The version of Ajv you are using")]),e._v(" "),t("li",[e._v("Operating system and Node.js version")]),e._v(" "),t("li",[e._v("Package manager and its version")]),e._v(" "),t("li",[e._v("Link to (or contents of) package.json and package-lock.json")]),e._v(" "),t("li",[e._v("Error messages")]),e._v(" "),t("li",[e._v("The output of "),t("code",[e._v("npm ls")])])]),e._v(" "),t("p",[t("a",{attrs:{name:"json-schema"}})]),e._v(" "),t("h3",{attrs:{id:"using-json-schema-standard"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#using-json-schema-standard"}},[e._v("#")]),e._v(" Using JSON Schema standard")]),e._v(" "),t("p",[e._v("Ajv implements JSON Schema standard draft-04 and draft-06/07.")]),e._v(" "),t("p",[e._v("If it is a general issue related to using the standard keywords included in JSON Schema specification or implementing some advanced validation logic please ask the question on "),t("a",{attrs:{href:"https://stackoverflow.com/questions/ask?tags=jsonschema,ajv",target:"_blank",rel:"noopener noreferrer"}},[e._v("Stack Overflow"),t("OutboundLink")],1),e._v(" (my account is "),t("a",{attrs:{href:"https://stackoverflow.com/users/1816503/esp",target:"_blank",rel:"noopener noreferrer"}},[e._v("esp"),t("OutboundLink")],1),e._v(") or submit the question to "),t("a",{attrs:{href:"https://github.com/json-schema-org/json-schema-spec/issues/new",target:"_blank",rel:"noopener noreferrer"}},[e._v("json-schema.org"),t("OutboundLink")],1),e._v(". Please mention @epoberezkin.")]),e._v(" "),t("p",[t("a",{attrs:{name:"usage"}})]),e._v(" "),t("h3",{attrs:{id:"ajv-usage-questions"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#ajv-usage-questions"}},[e._v("#")]),e._v(" Ajv usage questions")]),e._v(" "),t("p",[e._v("The best place to ask a question about using Ajv is "),t("a",{attrs:{href:"https://gitter.im/ajv-validator/ajv",target:"_blank",rel:"noopener noreferrer"}},[e._v("Gitter chat"),t("OutboundLink")],1),e._v(".")]),e._v(" "),t("p",[e._v("If the question is advanced, it can be submitted to "),t("a",{attrs:{href:"http://stackoverflow.com/questions/ask?tags=jsonschema,ajv",target:"_blank",rel:"noopener noreferrer"}},[e._v("Stack Overflow"),t("OutboundLink")],1),e._v(".")]),e._v(" "),t("h2",{attrs:{id:"code"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#code"}},[e._v("#")]),e._v(" Code")]),e._v(" "),t("p",[e._v("Thanks a lot for considering contributing to Ajv! Our users have created many great features, and we look forward to your contributions.")]),e._v(" "),t("p",[e._v("For help navigating the code, please review the "),t("RouterLink",{attrs:{to:"/components.html"}},[e._v("Code components")]),e._v(" document.")],1),e._v(" "),t("h3",{attrs:{id:"how-we-make-decisions"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#how-we-make-decisions"}},[e._v("#")]),e._v(" How we make decisions")]),e._v(" "),t("p",[e._v("We value conscious curation of our library size, and balancing performance and functionality. To that end, we cannot accept every suggestion. When evaluating pull requests we consider:")]),e._v(" "),t("ul",[t("li",[e._v("Will this benefit many users or a niche use case?")]),e._v(" "),t("li",[e._v("How will this impact the performance of Ajv?")]),e._v(" "),t("li",[e._v("How will this expand our library size?")])]),e._v(" "),t("p",[e._v("To help us evaluate and understand, when you submit an issue and pull request:")]),e._v(" "),t("ul",[t("li",[e._v("Explain why this feature is important to the user base")]),e._v(" "),t("li",[e._v("Include documentation")]),e._v(" "),t("li",[e._v("Include test coverage with any new feature implementations")])]),e._v(" "),t("p",[e._v("Please include documentation and test coverage with any new feature implementations.")]),e._v(" "),t("h3",{attrs:{id:"development"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#development"}},[e._v("#")]),e._v(" Development")]),e._v(" "),t("p",[e._v("Running tests:")]),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("\n"),t("span",{pre:!0,attrs:{class:"token function"}},[e._v("git")]),e._v(" submodule update "),t("span",{pre:!0,attrs:{class:"token parameter variable"}},[e._v("--init")]),e._v("\n"),t("span",{pre:!0,attrs:{class:"token function"}},[e._v("npm")]),e._v(" "),t("span",{pre:!0,attrs:{class:"token builtin class-name"}},[e._v("test")]),e._v("\n")])])]),t("p",[t("code",[e._v("npm run build")]),e._v(" - compiles typescript to dist folder.")]),e._v(" "),t("p",[t("code",[e._v("npm run watch")]),e._v(" - automatically compiles typescript when files on lib folder changes.")]),e._v(" "),t("h3",{attrs:{id:"pull-requests"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#pull-requests"}},[e._v("#")]),e._v(" Pull requests")]),e._v(" "),t("p",[e._v("We want to iterate on the code efficiently. To speed up the process, please follow these steps:")]),e._v(" "),t("ol",[t("li",[e._v("Submit an "),t("a",{attrs:{href:"https://github.com/ajv-validator/ajv/issues/new",target:"_blank",rel:"noopener noreferrer"}},[e._v("issue with the bug"),t("OutboundLink")],1),e._v(" or with the proposed change (unless the contribution is to fix the documentation typos and mistakes).")]),e._v(" "),t("li",[e._v("Describe the proposed api and implementation plan (unless the issue is a relatively simple bug and fixing it doesn't change any api).")]),e._v(" "),t("li",[e._v("Once agreed, please write as little code as possible to achieve the desired result. We are passionate about keeping our library size optimized.")]),e._v(" "),t("li",[e._v("Please add the tests both for the added feature and, if you are submitting an option, for the existing behaviour when this option is turned off or not passed.")]),e._v(" "),t("li",[e._v("Please avoid unnecessary changes, refactoring or changing coding styles as part of your change (unless the change was proposed as refactoring).")]),e._v(" "),t("li",[e._v("Follow the coding conventions even if they are not validated.")]),e._v(" "),t("li",[e._v("Please run the tests before committing your code.")]),e._v(" "),t("li",[e._v("If tests fail in CI build after you make a PR please investigate and fix the issue.")])]),e._v(" "),t("h3",{attrs:{id:"contributions-license"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#contributions-license"}},[e._v("#")]),e._v(" Contributions license")]),e._v(" "),t("p",[e._v("When contributing the code you confirm that:")]),e._v(" "),t("ol",[t("li",[e._v("Your contribution is created by you.")]),e._v(" "),t("li",[e._v("You have the right to submit it under the MIT license.")]),e._v(" "),t("li",[e._v("You understand and agree that your contribution is public, will be stored indefinitely, can be redistributed as the part of Ajv or another related package under MIT license, modified or completely removed from Ajv.")]),e._v(" "),t("li",[e._v("You grant irrevocable MIT license to use your contribution as part of Ajv or any other package.")]),e._v(" "),t("li",[e._v("You waive all rights to your contribution.")]),e._v(" "),t("li",[e._v("Unless you request otherwise, you can be mentioned as the author of the contribution in the Ajv documentation and change log.")])])])}),[],!1,null,null,null);t.default=i.exports}}]); \ No newline at end of file diff --git a/assets/js/5.31d93674.js b/assets/js/5.31d93674.js new file mode 100644 index 000000000..5b4bb7624 --- /dev/null +++ b/assets/js/5.31d93674.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[5],{285:function(t,e,s){},323:function(t,e,s){"use strict";s(285)},455:function(t,e,s){"use strict";s.r(e);var a={name:"CodeBlock",props:{title:{type:String,required:!0},active:{type:Boolean,default:!1}},mounted(){this.$parent&&this.$parent.loadTabs&&this.$parent.loadTabs()}},i=(s(323),s(14)),n=Object(i.a)(a,(function(){return(0,this._self._c)("div",{staticClass:"theme-code-block",class:{"theme-code-block__active":this.active}},[this._t("default")],2)}),[],!1,null,"311ec9b4",null);e.default=n.exports}}]); \ No newline at end of file diff --git a/assets/js/50.d9f5c1d1.js b/assets/js/50.d9f5c1d1.js new file mode 100644 index 000000000..99ce19392 --- /dev/null +++ b/assets/js/50.d9f5c1d1.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[50],{482: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:"frequently-asked-questions"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#frequently-asked-questions"}},[e._v("#")]),e._v(" Frequently Asked Questions")]),e._v(" "),t("p",[e._v("The purpose of this document is to help find answers quicker. I am happy to continue the discussion about these issues, so please comment on some of the issues mentioned below or create a new issue if it seems more appropriate.")]),e._v(" "),t("p"),t("div",{staticClass:"table-of-contents"},[t("ul",[t("li",[t("a",{attrs:{href:"#using-json-schema"}},[e._v("Using JSON schema")]),t("ul",[t("li",[t("a",{attrs:{href:"#why-ajv-validates-empty-object-as-valid"}},[e._v("Why Ajv validates empty object as valid?")])]),t("li",[t("a",{attrs:{href:"#why-ajv-validates-only-the-first-item-of-the-array"}},[e._v("Why Ajv validates only the first item of the array?")])])])]),t("li",[t("a",{attrs:{href:"#ajv-api-for-returning-validation-errors"}},[e._v("Ajv API for returning validation errors")]),t("ul",[t("li",[t("a",{attrs:{href:"#why-ajv-assigns-errors-as-a-property-of-validation-function-or-instance-instead-of-returning-an-object-with-validation-results-and-errors"}},[e._v("Why Ajv assigns errors as a property of validation function (or instance) instead of returning an object with validation results and errors?")])]),t("li",[t("a",{attrs:{href:"#would-errors-get-overwritten-in-case-of-concurrent-validations"}},[e._v('Would errors get overwritten in case of "concurrent" validations?')])]),t("li",[t("a",{attrs:{href:"#can-we-change-extend-api-to-add-a-method-that-would-return-errors-rather-than-assign-them-to-errors-property"}},[e._v("Can we change / extend API to add a method that would return errors (rather than assign them to errors property)?")])]),t("li",[t("a",{attrs:{href:"#why-don-t-additionalproperties-false-errors-display-the-property-name"}},[e._v('Why don\'t "additionalProperties": false errors display the property name?')])])])]),t("li",[t("a",{attrs:{href:"#additional-properties-inside-compound-keywords-anyof-oneof-etc"}},[e._v("Additional properties inside compound keywords anyOf, oneOf, etc.")]),t("ul",[t("li",[t("a",{attrs:{href:"#why-the-keyword-additionalproperties-false-fails-validation-when-some-properties-are-declared-inside-a-subschema-in-anyof-etc"}},[e._v('Why the keyword additionalProperties: false fails validation when some properties are "declared" inside a subschema in anyOf/etc.?')])]),t("li",[t("a",{attrs:{href:"#why-the-validation-fails-when-i-use-option-removeadditional-with-the-keyword-anyof-etc"}},[e._v("Why the validation fails when I use option removeAdditional with the keyword anyOf/etc.?")])])])]),t("li",[t("a",{attrs:{href:"#generating-schemas-with-resolved-references-ref"}},[e._v("Generating schemas with resolved references ($ref)")]),t("ul",[t("li",[t("a",{attrs:{href:"#why-ajv-does-not-replace-references-ref-with-the-actual-referenced-schemas-as-some-validators-do"}},[e._v("Why Ajv does not replace references ($ref) with the actual referenced schemas as some validators do?")])]),t("li",[t("a",{attrs:{href:"#how-can-i-generate-a-schema-where-ref-keywords-are-replaced-with-referenced-schemas"}},[e._v("How can I generate a schema where $ref keywords are replaced with referenced schemas?")])])])])])]),t("p"),e._v(" "),t("h2",{attrs:{id:"using-json-schema"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#using-json-schema"}},[e._v("#")]),e._v(" Using JSON schema")]),e._v(" "),t("p",[e._v("Ajv implements JSON schema specification. Before submitting the issue about the behaviour of any validation keywords please review them in:")]),e._v(" "),t("ul",[t("li",[t("a",{attrs:{href:"https://tools.ietf.org/html/draft-handrews-json-schema-validation-00",target:"_blank",rel:"noopener noreferrer"}},[e._v("JSON Schema specification"),t("OutboundLink")],1),e._v(" (draft-07)")]),e._v(" "),t("li",[t("RouterLink",{attrs:{to:"/json-schema.html"}},[e._v("JSON Schema reference")]),e._v(" in Ajv documentation")],1),e._v(" "),t("li",[t("a",{attrs:{href:"https://spacetelescope.github.io/understanding-json-schema/",target:"_blank",rel:"noopener noreferrer"}},[e._v("JSON Schema tutorial"),t("OutboundLink")],1),e._v(" (for draft-04)")])]),e._v(" "),t("h4",{attrs:{id:"why-ajv-validates-empty-object-as-valid"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#why-ajv-validates-empty-object-as-valid"}},[e._v("#")]),e._v(" Why Ajv validates empty object as valid?")]),e._v(" "),t("p",[e._v('"properties" keyword does not require the presence of any properties, you need to use "required" keyword. It also doesn\'t require that the data is an object, so any other type of data will also be valid. To require a specific type use "type" keyword. '),t("RouterLink",{attrs:{to:"/strict-mode.html#strict-types"}},[e._v("Strict types mode")]),e._v(' introduced in v7 requires presence of "type" when "properties" are used, so the mistakes are less likely.')],1),e._v(" "),t("h4",{attrs:{id:"why-ajv-validates-only-the-first-item-of-the-array"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#why-ajv-validates-only-the-first-item-of-the-array"}},[e._v("#")]),e._v(" Why Ajv validates only the first item of the array?")]),e._v(" "),t("p",[e._v('"items" keyword support '),t("RouterLink",{attrs:{to:"/json-schema.html#items"}},[e._v("two syntaxes")]),e._v(" - 1) when the schema applies to all items; 2) when there is a different schema for each item in the beginning of the array. This problem means you are using the second syntax.")],1),e._v(" "),t("p",[e._v("In v7 with option "),t("code",[e._v("strictTuples")]),e._v(" ("),t("code",[e._v('"log"')]),e._v(' by default) this problem is less likely to happen, as Ajv would log warning about missing "minItems" and other keywords that are required to constrain tuple size.')]),e._v(" "),t("h2",{attrs:{id:"ajv-api-for-returning-validation-errors"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#ajv-api-for-returning-validation-errors"}},[e._v("#")]),e._v(" Ajv API for returning validation errors")]),e._v(" "),t("p",[e._v("See "),t("a",{attrs:{href:"https://github.com/ajv-validator/ajv/issues/65",target:"_blank",rel:"noopener noreferrer"}},[e._v("#65"),t("OutboundLink")],1),e._v(", "),t("a",{attrs:{href:"https://github.com/ajv-validator/ajv/issues/212",target:"_blank",rel:"noopener noreferrer"}},[e._v("#212"),t("OutboundLink")],1),e._v(", "),t("a",{attrs:{href:"https://github.com/ajv-validator/ajv/issues/236",target:"_blank",rel:"noopener noreferrer"}},[e._v("#236"),t("OutboundLink")],1),e._v(", "),t("a",{attrs:{href:"https://github.com/ajv-validator/ajv/issues/242",target:"_blank",rel:"noopener noreferrer"}},[e._v("#242"),t("OutboundLink")],1),e._v(", "),t("a",{attrs:{href:"https://github.com/ajv-validator/ajv/issues/256",target:"_blank",rel:"noopener noreferrer"}},[e._v("#256"),t("OutboundLink")],1),e._v(".")]),e._v(" "),t("h4",{attrs:{id:"why-ajv-assigns-errors-as-a-property-of-validation-function-or-instance-instead-of-returning-an-object-with-validation-results-and-errors"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#why-ajv-assigns-errors-as-a-property-of-validation-function-or-instance-instead-of-returning-an-object-with-validation-results-and-errors"}},[e._v("#")]),e._v(" Why Ajv assigns errors as a property of validation function (or instance) instead of returning an object with validation results and errors?")]),e._v(" "),t("p",[e._v("The reasons are history (other fast validators with the same api) and performance (returning boolean is faster). Although more code is written to process errors than to handle successful results, almost all server-side validations pass. The existing API is more efficient from the performance point of view.")]),e._v(" "),t("p",[e._v("Ajv also supports asynchronous validation (with asynchronous formats and keywords) that returns a promise that either resolves to "),t("code",[e._v("true")]),e._v(" or rejects with an error.")]),e._v(" "),t("h4",{attrs:{id:"would-errors-get-overwritten-in-case-of-concurrent-validations"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#would-errors-get-overwritten-in-case-of-concurrent-validations"}},[e._v("#")]),e._v(' Would errors get overwritten in case of "concurrent" validations?')]),e._v(" "),t("p",[e._v("No. There is no parallel execution in JavaScript, and the cooperative concurrency model of javascript makes this pattern safe. While a validation is run, no other JavaScript code that can access the same memory can be executed. As long as the errors are used in the same execution block, the errors will not be overwritten.")]),e._v(" "),t("h4",{attrs:{id:"can-we-change-extend-api-to-add-a-method-that-would-return-errors-rather-than-assign-them-to-errors-property"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#can-we-change-extend-api-to-add-a-method-that-would-return-errors-rather-than-assign-them-to-errors-property"}},[e._v("#")]),e._v(" Can we change / extend API to add a method that would return errors (rather than assign them to "),t("code",[e._v("errors")]),e._v(" property)?")]),e._v(" "),t("p",[e._v("No. In many cases there is a module responsible for the validation in the application, usually to load schemas and to process errors. This module is the right place to introduce any user-defined API. Convenience is a subjective thing, changing or extending API purely because of convenience would either break backward compatibility (even if it's done in a new major version it still complicates migration) or bloat API (making it more difficult to maintain).")]),e._v(" "),t("h4",{attrs:{id:"why-don-t-additionalproperties-false-errors-display-the-property-name"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#why-don-t-additionalproperties-false-errors-display-the-property-name"}},[e._v("#")]),e._v(" Why don't "),t("code",[e._v('"additionalProperties": false')]),e._v(" errors display the property name?")]),e._v(" "),t("p",[e._v("Doing this would create a precedent where validated data is used in error messages, creating a vulnerability (e.g., when ajv is used to validate API data/parameters and error messages are logged).")]),e._v(" "),t("p",[e._v("Since the property name is already in the params object, in an application you can modify the messages in any way you need. ajv-errors package allows modifying messages as well.")]),e._v(" "),t("h2",{attrs:{id:"additional-properties-inside-compound-keywords-anyof-oneof-etc"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#additional-properties-inside-compound-keywords-anyof-oneof-etc"}},[e._v("#")]),e._v(" Additional properties inside compound keywords anyOf, oneOf, etc.")]),e._v(" "),t("p",[e._v("See "),t("a",{attrs:{href:"https://github.com/ajv-validator/ajv/issues/127",target:"_blank",rel:"noopener noreferrer"}},[e._v("#127"),t("OutboundLink")],1),e._v(", "),t("a",{attrs:{href:"https://github.com/ajv-validator/ajv/issues/129",target:"_blank",rel:"noopener noreferrer"}},[e._v("#129"),t("OutboundLink")],1),e._v(", "),t("a",{attrs:{href:"https://github.com/ajv-validator/ajv/issues/134",target:"_blank",rel:"noopener noreferrer"}},[e._v("#134"),t("OutboundLink")],1),e._v(", "),t("a",{attrs:{href:"https://github.com/ajv-validator/ajv/issues/140",target:"_blank",rel:"noopener noreferrer"}},[e._v("#140"),t("OutboundLink")],1),e._v(", "),t("a",{attrs:{href:"https://github.com/ajv-validator/ajv/issues/193",target:"_blank",rel:"noopener noreferrer"}},[e._v("#193"),t("OutboundLink")],1),e._v(", "),t("a",{attrs:{href:"https://github.com/ajv-validator/ajv/issues/205",target:"_blank",rel:"noopener noreferrer"}},[e._v("#205"),t("OutboundLink")],1),e._v(", "),t("a",{attrs:{href:"https://github.com/ajv-validator/ajv/issues/238",target:"_blank",rel:"noopener noreferrer"}},[e._v("#238"),t("OutboundLink")],1),e._v(", "),t("a",{attrs:{href:"https://github.com/ajv-validator/ajv/issues/264",target:"_blank",rel:"noopener noreferrer"}},[e._v("#264"),t("OutboundLink")],1),e._v(".")]),e._v(" "),t("h4",{attrs:{id:"why-the-keyword-additionalproperties-false-fails-validation-when-some-properties-are-declared-inside-a-subschema-in-anyof-etc"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#why-the-keyword-additionalproperties-false-fails-validation-when-some-properties-are-declared-inside-a-subschema-in-anyof-etc"}},[e._v("#")]),e._v(" Why the keyword "),t("code",[e._v("additionalProperties: false")]),e._v(' fails validation when some properties are "declared" inside a subschema in '),t("code",[e._v("anyOf")]),e._v("/etc.?")]),e._v(" "),t("p",[e._v("The keyword "),t("code",[e._v("additionalProperties")]),e._v(" creates the restriction on validated data based on its own value ("),t("code",[e._v("false")]),e._v(" or schema object) and on the keywords "),t("code",[e._v("properties")]),e._v(" and "),t("code",[e._v("patternProperties")]),e._v(" in the SAME schema object. JSON Schema validators must NOT take into account properties used in other schema objects.")]),e._v(" "),t("p",[e._v("While you can expect that the schema below would allow the objects either with properties "),t("code",[e._v("foo")]),e._v(" and "),t("code",[e._v("bar")]),e._v(" or with properties "),t("code",[e._v("foo")]),e._v(" and "),t("code",[e._v("baz")]),e._v(" and all other properties will be prohibited, this schema will only allow objects with one property "),t("code",[e._v("foo")]),e._v(" (an empty object and any non-objects will also be valid):")]),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 punctuation"}},[e._v("{")]),e._v("\n "),t("span",{pre:!0,attrs:{class:"token literal-property property"}},[e._v("type")]),t("span",{pre:!0,attrs:{class:"token operator"}},[e._v(":")]),e._v(" "),t("span",{pre:!0,attrs:{class:"token string"}},[e._v('"object"')]),t("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(",")]),e._v("\n "),t("span",{pre:!0,attrs:{class:"token literal-property property"}},[e._v("properties")]),t("span",{pre:!0,attrs:{class:"token operator"}},[e._v(":")]),e._v(" "),t("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("{")]),t("span",{pre:!0,attrs:{class:"token literal-property property"}},[e._v("foo")]),t("span",{pre:!0,attrs:{class:"token operator"}},[e._v(":")]),e._v(" "),t("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("{")]),t("span",{pre:!0,attrs:{class:"token literal-property property"}},[e._v("type")]),t("span",{pre:!0,attrs:{class:"token operator"}},[e._v(":")]),e._v(" "),t("span",{pre:!0,attrs:{class:"token string"}},[e._v('"number"')]),t("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("}")]),t("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("}")]),t("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(",")]),e._v("\n "),t("span",{pre:!0,attrs:{class:"token literal-property property"}},[e._v("additionalProperties")]),t("span",{pre:!0,attrs:{class:"token operator"}},[e._v(":")]),e._v(" "),t("span",{pre:!0,attrs:{class:"token boolean"}},[e._v("false")]),t("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(",")]),e._v("\n "),t("span",{pre:!0,attrs:{class:"token literal-property property"}},[e._v("oneOf")]),t("span",{pre:!0,attrs:{class:"token operator"}},[e._v(":")]),e._v(" "),t("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("[")]),e._v("\n "),t("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("{")]),t("span",{pre:!0,attrs:{class:"token literal-property property"}},[e._v("properties")]),t("span",{pre:!0,attrs:{class:"token operator"}},[e._v(":")]),e._v(" "),t("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("{")]),t("span",{pre:!0,attrs:{class:"token literal-property property"}},[e._v("bar")]),t("span",{pre:!0,attrs:{class:"token operator"}},[e._v(":")]),e._v(" "),t("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("{")]),t("span",{pre:!0,attrs:{class:"token literal-property property"}},[e._v("type")]),t("span",{pre:!0,attrs:{class:"token operator"}},[e._v(":")]),e._v(" "),t("span",{pre:!0,attrs:{class:"token string"}},[e._v('"number"')]),t("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("}")]),t("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("}")]),t("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("}")]),t("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(",")]),e._v("\n "),t("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("{")]),t("span",{pre:!0,attrs:{class:"token literal-property property"}},[e._v("properties")]),t("span",{pre:!0,attrs:{class:"token operator"}},[e._v(":")]),e._v(" "),t("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("{")]),t("span",{pre:!0,attrs:{class:"token literal-property property"}},[e._v("baz")]),t("span",{pre:!0,attrs:{class:"token operator"}},[e._v(":")]),e._v(" "),t("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("{")]),t("span",{pre:!0,attrs:{class:"token literal-property property"}},[e._v("type")]),t("span",{pre:!0,attrs:{class:"token operator"}},[e._v(":")]),e._v(" "),t("span",{pre:!0,attrs:{class:"token string"}},[e._v('"number"')]),t("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("}")]),t("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("}")]),t("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("}")]),e._v("\n "),t("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("]")]),e._v("\n"),t("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("}")]),e._v("\n")])])]),t("p",[e._v("The reason for that is that "),t("code",[e._v("additionalProperties")]),e._v(" keyword ignores properties inside "),t("code",[e._v("oneOf")]),e._v(" keyword subschemas. That's not the limitation of Ajv or any other validator, that's how it must work according to the standard.")]),e._v(" "),t("p",[e._v("There are several ways to implement the described logic that would allow two properties, please see the suggestions in the issues mentioned above.")]),e._v(" "),t("h4",{attrs:{id:"why-the-validation-fails-when-i-use-option-removeadditional-with-the-keyword-anyof-etc"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#why-the-validation-fails-when-i-use-option-removeadditional-with-the-keyword-anyof-etc"}},[e._v("#")]),e._v(" Why the validation fails when I use option "),t("code",[e._v("removeAdditional")]),e._v(" with the keyword "),t("code",[e._v("anyOf")]),e._v("/etc.?")]),e._v(" "),t("p",[e._v("This problem is related to the problem explained above - properties treated as additional in the sense of "),t("code",[e._v("additionalProperties")]),e._v(" keyword, based on "),t("code",[e._v("properties")]),e._v("/"),t("code",[e._v("patternProperties")]),e._v(" keyword in the same schema object.")]),e._v(" "),t("p",[e._v("See the example in the "),t("a",{attrs:{href:"https://ajv.js.org/guide/modifying-data.html#removing-additional-properties",target:"_blank",rel:"noopener noreferrer"}},[e._v("Removing Additional Data"),t("OutboundLink")],1),e._v(" section of the docs.")]),e._v(" "),t("h2",{attrs:{id:"generating-schemas-with-resolved-references-ref"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#generating-schemas-with-resolved-references-ref"}},[e._v("#")]),e._v(" Generating schemas with resolved references ($ref)")]),e._v(" "),t("p",[e._v("See "),t("a",{attrs:{href:"https://github.com/ajv-validator/ajv/issues/22",target:"_blank",rel:"noopener noreferrer"}},[e._v("#22"),t("OutboundLink")],1),e._v(", "),t("a",{attrs:{href:"https://github.com/ajv-validator/ajv/issues/125",target:"_blank",rel:"noopener noreferrer"}},[e._v("#125"),t("OutboundLink")],1),e._v(", "),t("a",{attrs:{href:"https://github.com/ajv-validator/ajv/issues/146",target:"_blank",rel:"noopener noreferrer"}},[e._v("#146"),t("OutboundLink")],1),e._v(", "),t("a",{attrs:{href:"https://github.com/ajv-validator/ajv/issues/228",target:"_blank",rel:"noopener noreferrer"}},[e._v("#228"),t("OutboundLink")],1),e._v(", "),t("a",{attrs:{href:"https://github.com/ajv-validator/ajv/issues/336",target:"_blank",rel:"noopener noreferrer"}},[e._v("#336"),t("OutboundLink")],1),e._v(", "),t("a",{attrs:{href:"https://github.com/ajv-validator/ajv/issues/454",target:"_blank",rel:"noopener noreferrer"}},[e._v("#454"),t("OutboundLink")],1),e._v(".")]),e._v(" "),t("h4",{attrs:{id:"why-ajv-does-not-replace-references-ref-with-the-actual-referenced-schemas-as-some-validators-do"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#why-ajv-does-not-replace-references-ref-with-the-actual-referenced-schemas-as-some-validators-do"}},[e._v("#")]),e._v(" Why Ajv does not replace references ($ref) with the actual referenced schemas as some validators do?")]),e._v(" "),t("ol",[t("li",[e._v("The scope of Ajv is validating data against JSON Schemas; inlining referenced schemas is not necessary for validation. When Ajv generates code for validation it either inlines the code of referenced schema or uses function calls. Doing schema manipulation is more complex and out of scope.")]),e._v(" "),t("li",[e._v("When schemas are recursive (or mutually recursive) resolving references would result in self-referencing recursive data-structures that can be difficult to process.")]),e._v(" "),t("li",[e._v("There are cases when such inlining would also require adding (or modifying) "),t("code",[e._v("id")]),e._v(" attribute in the inlined schema fragment to make the resulting schema equivalent.")])]),e._v(" "),t("p",[e._v("There were many conversations about the meaning of "),t("code",[e._v("$ref")]),e._v(" in "),t("a",{attrs:{href:"https://github.com/json-schema-org",target:"_blank",rel:"noopener noreferrer"}},[e._v("JSON Schema GitHub organisation"),t("OutboundLink")],1),e._v(". The consensus is that while it is possible to treat "),t("code",[e._v("$ref")]),e._v(" as schema inclusion with two caveats (above), this interpretation is unnecessary complex. A more efficient approach is to treat "),t("code",[e._v("$ref")]),e._v(" as a delegation, i.e. a special keyword that validates the current data instance against the referenced schema. The analogy with programming languages is that "),t("code",[e._v("$ref")]),e._v(" is a function call rather than a macro. See "),t("a",{attrs:{href:"https://github.com/json-schema-org/json-schema-spec/issues/279",target:"_blank",rel:"noopener noreferrer"}},[e._v("here"),t("OutboundLink")],1),e._v(", for example.")]),e._v(" "),t("h4",{attrs:{id:"how-can-i-generate-a-schema-where-ref-keywords-are-replaced-with-referenced-schemas"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#how-can-i-generate-a-schema-where-ref-keywords-are-replaced-with-referenced-schemas"}},[e._v("#")]),e._v(" How can I generate a schema where "),t("code",[e._v("$ref")]),e._v(" keywords are replaced with referenced schemas?")]),e._v(" "),t("p",[e._v("There are two possible approaches:")]),e._v(" "),t("ol",[t("li",[e._v("Traverse schema (e.g. with json-schema-traverse) and replace every "),t("code",[e._v("$ref")]),e._v(" with the referenced schema.")]),e._v(" "),t("li",[e._v("Use a specially constructed JSON Schema with a "),t("RouterLink",{attrs:{to:"/keywords.html"}},[e._v("user-defined keyword")]),e._v(" to traverse and modify your schema.")],1)])])}),[],!1,null,null,null);t.default=s.exports}}]); \ No newline at end of file diff --git a/assets/js/51.80400edb.js b/assets/js/51.80400edb.js new file mode 100644 index 000000000..3a270b593 --- /dev/null +++ b/assets/js/51.80400edb.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[51],{480:function(t,s,a){"use strict";a.r(s);var n=a(14),r=Object(n.a)({},(function(){var t=this,s=t._self._c;return s("ContentSlotsDistributor",{attrs:{"slot-key":t.$parent.slotKey}},[s("h1",{attrs:{id:"asynchronous-validation"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#asynchronous-validation"}},[t._v("#")]),t._v(" Asynchronous validation")]),t._v(" "),s("p",[t._v("You can define formats and keywords that perform validation asynchronously by accessing database or some other service. You should add "),s("code",[t._v("async: true")]),t._v(" in the keyword or format definition (see "),s("RouterLink",{attrs:{to:"/guide/api.html#api-addformat"}},[t._v("addFormat")]),t._v(", "),s("RouterLink",{attrs:{to:"/guide/api.html#api-addkeyword"}},[t._v("addKeyword")]),t._v(" and "),s("RouterLink",{attrs:{to:"/guide/keywords.html"}},[t._v("User-defined keywords")]),t._v(").")],1),t._v(" "),s("p",[t._v("If your schema uses asynchronous formats/keywords or refers to some schema that contains them it should have "),s("code",[t._v('"$async": true')]),t._v(" keyword so that Ajv can compile it correctly. If asynchronous format/keyword or reference to asynchronous schema is used in the schema without "),s("code",[t._v("$async")]),t._v(" keyword Ajv will throw an exception during schema compilation.")]),t._v(" "),s("div",{staticClass:"custom-block warning"},[s("p",{staticClass:"custom-block-title"},[t._v("Use $async: true in referenced schemas")]),t._v(" "),s("p",[t._v("All asynchronous subschemas that are referenced from the current or other schemas should have "),s("code",[t._v('"$async": true')]),t._v(" keyword as well, otherwise the schema compilation will fail.")])]),t._v(" "),s("p",[t._v("Validation function for an asynchronous format/keyword should return a promise that resolves with "),s("code",[t._v("true")]),t._v(" or "),s("code",[t._v("false")]),t._v(" (or rejects with "),s("code",[t._v("new Ajv.ValidationError(errors)")]),t._v(" if you want to return errors from the keyword function).")]),t._v(" "),s("p",[t._v("Ajv compiles asynchronous schemas to "),s("a",{attrs:{href:"http://tc39.github.io/ecmascript-asyncawait/",target:"_blank",rel:"noopener noreferrer"}},[t._v("async functions"),s("OutboundLink")],1),t._v(". Async functions are supported in Node.js 7+ and all modern browsers. You can supply a transpiler as a function via "),s("code",[t._v("processCode")]),t._v(" option. See "),s("RouterLink",{attrs:{to:"/guide/api.html#options"}},[t._v("Options")]),t._v(".")],1),t._v(" "),s("p",[t._v("The compiled validation function has "),s("code",[t._v("$async: true")]),t._v(" property (if the schema is asynchronous), so you can differentiate these functions if you are using both synchronous and asynchronous schemas.")]),t._v(" "),s("p",[t._v("Validation result will be a promise that resolves with validated data or rejects with an exception "),s("code",[t._v("Ajv.ValidationError")]),t._v(" that contains the array of validation errors in "),s("code",[t._v("errors")]),t._v(" property.")]),t._v(" "),s("p",[t._v("Example:")]),t._v(" "),s("div",{staticClass:"language-javascript extra-class"},[s("pre",{pre:!0,attrs:{class:"language-javascript"}},[s("code",[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\najv"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("addKeyword")]),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 literal-property property"}},[t._v("keyword")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"idExists"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("async")]),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 literal-property property"}},[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('"number"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("validate")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" checkIdExists"),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\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("async")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("function")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("checkIdExists")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token parameter"}},[t._v("schema"),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(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// this is just an example, you would want to avoid SQL injection in your code")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" rows "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("await")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("sql")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token template-string"}},[s("span",{pre:!0,attrs:{class:"token template-punctuation string"}},[t._v("`")]),s("span",{pre:!0,attrs:{class:"token string"}},[t._v("SELECT id FROM ")]),s("span",{pre:!0,attrs:{class:"token interpolation"}},[s("span",{pre:!0,attrs:{class:"token interpolation-punctuation punctuation"}},[t._v("${")]),t._v("schema"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("table"),s("span",{pre:!0,attrs:{class:"token interpolation-punctuation punctuation"}},[t._v("}")])]),s("span",{pre:!0,attrs:{class:"token string"}},[t._v(" WHERE id = ")]),s("span",{pre:!0,attrs:{class:"token interpolation"}},[s("span",{pre:!0,attrs:{class:"token interpolation-punctuation punctuation"}},[t._v("${")]),t._v("data"),s("span",{pre:!0,attrs:{class:"token interpolation-punctuation punctuation"}},[t._v("}")])]),s("span",{pre:!0,attrs:{class:"token template-punctuation string"}},[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("return")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("!")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("!")]),t._v("rows"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("length "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// true if record is found")]),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(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("$async")]),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 literal-property property"}},[t._v("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 "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("userId")]),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 literal-property property"}},[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(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("idExists")]),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 literal-property property"}},[t._v("table")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"users"')]),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 literal-property property"}},[t._v("postId")]),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 literal-property property"}},[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(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("idExists")]),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 literal-property property"}},[t._v("table")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"posts"')]),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("}")]),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 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 function"}},[t._v("validate")]),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 literal-property property"}},[t._v("userId")]),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(" "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("postId")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("19")]),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 function"}},[t._v("then")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("function")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token parameter"}},[t._v("data")]),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 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 string"}},[t._v('"Data is valid"')]),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(" "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// { userId: 1, postId: 19 }")]),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(".")]),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("catch")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("function")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token parameter"}},[t._v("err")]),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("if")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("!")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("err "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("instanceof")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("Ajv"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("ValidationError")]),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 keyword"}},[t._v("throw")]),t._v(" err\n "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// data is invalid")]),t._v("\n 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 string"}},[t._v('"Validation errors:"')]),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("errors"),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("h3",{attrs:{id:"using-transpilers"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#using-transpilers"}},[t._v("#")]),t._v(" Using transpilers")]),t._v(" "),s("div",{staticClass:"language-javascript extra-class"},[s("pre",{pre:!0,attrs:{class:"language-javascript"}},[s("code",[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("{")]),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("processCode")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" transpileFunc"),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 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(" "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// transpiled es7 async function")]),t._v("\n"),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(".")]),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("then")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("successFunc"),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 function"}},[t._v("catch")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("errorFunc"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n")])])]),s("p",[t._v("See "),s("a",{attrs:{href:"../options"}},[t._v("Options")]),t._v(".")])])}),[],!1,null,null,null);s.default=r.exports}}]); \ No newline at end of file diff --git a/assets/js/52.18fd879d.js b/assets/js/52.18fd879d.js new file mode 100644 index 000000000..e408a0378 --- /dev/null +++ b/assets/js/52.18fd879d.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[52],{481:function(t,a,s){"use strict";s.r(a);var e=s(14),r=Object(e.a)({},(function(){var t=this,a=t._self._c;return a("ContentSlotsDistributor",{attrs:{"slot-key":t.$parent.slotKey}},[a("h1",{attrs:{id:"combining-schemas"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#combining-schemas"}},[t._v("#")]),t._v(" Combining schemas")]),t._v(" "),a("p"),a("div",{staticClass:"table-of-contents"},[a("ul",[a("li",[a("a",{attrs:{href:"#a-name-ref-a-combining-schemas-with-ref"}},[a("a",{attrs:{name:"ref"}}),t._v("Combining schemas with $ref")])]),a("li",[a("a",{attrs:{href:"#extending-recursive-schemas"}},[t._v("Extending recursive schemas")])]),a("li",[a("a",{attrs:{href:"#data-reference"}},[t._v("$data reference")])]),a("li",[a("a",{attrs:{href:"#merge-and-patch-keywords"}},[t._v("$merge and $patch keywords")])])])]),a("p"),t._v(" "),a("h2",{attrs:{id:"combining-schemas-with-ref"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#combining-schemas-with-ref"}},[t._v("#")]),t._v(" "),a("a",{attrs:{name:"ref"}}),t._v("Combining schemas with $ref")]),t._v(" "),a("p",[t._v("You can structure your validation logic across multiple schema files and have schemas reference each other using "),a("code",[t._v("$ref")]),t._v(" keyword.")]),t._v(" "),a("p",[t._v("Example:")]),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(" 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("$id")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"http://example.com/schemas/schema.json"')]),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("$ref")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"defs.json#/definitions/int"')]),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("$ref")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"defs.json#/definitions/str"')]),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\n"),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" defsSchema "),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("$id")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"http://example.com/schemas/defs.json"')]),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("definitions")]),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("int")]),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("str")]),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 punctuation"}},[t._v("}")]),t._v("\n")])])]),a("p",[t._v("Now to compile your schema you can either pass all schemas 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 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("schemas")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),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(" defsSchema"),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("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("getSchema")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"http://example.com/schemas/schema.json"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n")])])]),a("p",[t._v("or use "),a("code",[t._v("addSchema")]),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 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 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("addSchema")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("defsSchema"),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 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")])])]),a("p",[t._v("See "),a("RouterLink",{attrs:{to:"/options.html"}},[t._v("Options")]),t._v(" and "),a("RouterLink",{attrs:{to:"/api.html#add-schema"}},[t._v("addSchema")]),t._v(" method.")],1),t._v(" "),a("div",{staticClass:"custom-block tip"},[a("p",{staticClass:"custom-block-title"},[t._v("Reference resolution")]),t._v(" "),a("ul",[a("li",[a("code",[t._v("$ref")]),t._v(" is resolved as the uri-reference using schema $id as the base URI (see the example).")]),t._v(" "),a("li",[t._v("References can be recursive (and mutually recursive) to implement the schemas for different data structures (such as linked lists, trees, graphs, etc.).")]),t._v(" "),a("li",[t._v("You don't have to host your schema files at the URIs that you use as schema $id. These URIs are only used to identify the schemas, and according to JSON Schema specification validators should not expect to be able to download the schemas from these URIs.")]),t._v(" "),a("li",[t._v("The actual location of the schema file in the file system is not used.")]),t._v(" "),a("li",[t._v("You can pass the identifier of the schema as the second parameter of "),a("code",[t._v("addSchema")]),t._v(" method or as a property name in "),a("code",[t._v("schemas")]),t._v(" option. This identifier can be used instead of (or in addition to) schema $id.")]),t._v(" "),a("li",[t._v("You cannot have the same $id (or the schema identifier) used for more than one schema - the exception will be thrown.")]),t._v(" "),a("li",[t._v("You can implement dynamic resolution of the referenced schemas using "),a("code",[t._v("compileAsync")]),t._v(" method. In this way you can store schemas in any system (files, web, database, etc.) and reference them without explicitly adding to Ajv instance. See "),a("RouterLink",{attrs:{to:"/guide/managing-schemas.html#asynchronous-schema-compilation"}},[t._v("Asynchronous schema compilation")]),t._v(".")],1)])]),t._v(" "),a("h2",{attrs:{id:"extending-recursive-schemas"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#extending-recursive-schemas"}},[t._v("#")]),t._v(" Extending recursive schemas")]),t._v(" "),a("p",[t._v("While statically defined "),a("code",[t._v("$ref")]),t._v(" keyword allows to split schemas to multiple files, it is difficult to extend recursive schemas - the recursive reference(s) in the original schema points to the original schema, and not to the extended one. So in JSON Schema draft-07 the only available solution to extend the recursive schema was to redefine all sections of the original schema that have recursion.")]),t._v(" "),a("p",[t._v("It was particularly repetitive when extending meta-schema, as it has many recursive references, but even in a schema with a single recursive reference extending it was very verbose.")]),t._v(" "),a("p",[t._v("JSON Schema draft-2019-09 and the upcoming draft defined the mechanism for dynamic recursion using keywords "),a("code",[t._v("$recursiveRef")]),t._v("/"),a("code",[t._v("$recursiveAnchor")]),t._v(" (draft-2019-09) or "),a("code",[t._v("$dynamicRef")]),t._v("/"),a("code",[t._v("$dynamicAnchor")]),t._v(' (the next JSON Schema draft) that is somewhat similar to "open recursion" in functional programming.')]),t._v(" "),a("p",[t._v("Consider this recursive schema with static recursion:")]),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(" treeSchema "),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("$id")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"https://example.com/tree"')]),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('"data"')]),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("{")]),t._v("\n "),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 boolean"}},[t._v("true")]),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("children")]),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('"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 literal-property property"}},[t._v("$ref")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[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 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",[t._v("The only way to extend this schema to prohibit additional properties is by adding "),a("code",[t._v("additionalProperties")]),t._v(" keyword right in the schema - this approach can be impossible if you do not control the source of the original schema. Ajv also provided the additional keywords in "),a("a",{attrs:{href:"https://github.com/ajv-validator/ajv-merge-patch",target:"_blank",rel:"noopener noreferrer"}},[t._v("ajv-merge-patch"),a("OutboundLink")],1),t._v(" package to extend schemas by treating them as plain JSON data. While this approach may work for you, it is non-standard and therefore not portable.")]),t._v(" "),a("p",[t._v("The new keywords for dynamic recursive references allow extending this schema without modifying it:")]),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(" treeSchema "),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("$id")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"https://example.com/tree"')]),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("$recursiveAnchor")]),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("\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('"data"')]),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("{")]),t._v("\n "),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 boolean"}},[t._v("true")]),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("children")]),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('"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 literal-property property"}},[t._v("$recursiveRef")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[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 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\n"),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" strictTreeSchema "),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("$id")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"https://example.com/strict-tree"')]),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("$recursiveAnchor")]),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("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("$ref")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"tree"')]),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 punctuation"}},[t._v("}")]),t._v("\n\n"),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 comment"}},[t._v('// const Ajv2019 = require("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 "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("schemas")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),t._v("treeSchema"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" strictTreeSchema"),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 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("getSchema")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"https://example.com/strict-tree"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n")])])]),a("p",[t._v("See "),a("a",{attrs:{href:"https://github.com/ajv-validator/ajv/blob/master/spec/dynamic-ref.spec.ts",target:"_blank",rel:"noopener noreferrer"}},[t._v("dynamic-refs"),a("OutboundLink")],1),t._v(" test for the example using "),a("code",[t._v("$dynamicAnchor")]),t._v("/"),a("code",[t._v("$dynamicRef")]),t._v(".")]),t._v(" "),a("p",[t._v("At the moment Ajv implements the spec for dynamic recursive references with these limitations:")]),t._v(" "),a("ul",[a("li",[a("code",[t._v("$recursiveAnchor")]),t._v("/"),a("code",[t._v("$dynamicAnchor")]),t._v(" can only be used in the schema root.")]),t._v(" "),a("li",[a("code",[t._v("$recursiveRef")]),t._v("/"),a("code",[t._v("$dynamicRef")]),t._v(" can only be hash fragments, without URI.")])]),t._v(" "),a("p",[t._v("Ajv also does not support dynamic references in "),a("a",{attrs:{href:"#asynchronous-validation"}},[t._v("asynchronous schemas")]),t._v(" (Ajv extension) - it is assumed that the referenced schema is synchronous, and there is no validation-time check for it.")]),t._v(" "),a("h2",{attrs:{id:"data-reference"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#data-reference"}},[t._v("#")]),t._v(" $data reference")]),t._v(" "),a("p",[t._v("With "),a("code",[t._v("$data")]),t._v(" option you can use values from the validated data as the values for the schema keywords. See "),a("a",{attrs:{href:"https://github.com/json-schema-org/json-schema-spec/issues/51",target:"_blank",rel:"noopener noreferrer"}},[t._v("proposal"),a("OutboundLink")],1),t._v(" for more information about how it works.")]),t._v(" "),a("p",[a("code",[t._v("$data")]),t._v(" reference is supported in the keywords: const, enum, format, maximum/minimum, exclusiveMaximum / exclusiveMinimum, maxLength / minLength, maxItems / minItems, maxProperties / minProperties, formatMaximum / formatMinimum, formatExclusiveMaximum / formatExclusiveMinimum, multipleOf, pattern, required, uniqueItems.")]),t._v(" "),a("p",[t._v('The value of "$data" should be a '),a("a",{attrs:{href:"https://datatracker.ietf.org/doc/rfc6901/",target:"_blank",rel:"noopener noreferrer"}},[t._v("JSON-pointer"),a("OutboundLink")],1),t._v(" to the data (the root is always the top level data object, even if the $data reference is inside a referenced subschema) or a "),a("a",{attrs:{href:"http://tools.ietf.org/html/draft-luff-relative-json-pointer-00",target:"_blank",rel:"noopener noreferrer"}},[t._v("relative JSON-pointer"),a("OutboundLink")],1),t._v(" (it is relative to the current point in data; if the $data reference is inside a referenced subschema it cannot point to the data outside of the root level for this subschema).")]),t._v(" "),a("p",[t._v("Examples.")]),t._v(" "),a("p",[t._v("This schema requires that the value in property "),a("code",[t._v("smaller")]),t._v(" is less or equal than the value in the property larger:")]),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("$data")]),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\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("smaller")]),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("maximum")]),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/larger"')]),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("larger")]),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("}")]),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(" validData "),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("smaller")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("5")]),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("larger")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("7")]),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\najv"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[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("schema"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" validData"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// true")]),t._v("\n")])])]),a("p",[t._v("This schema requires that the properties have the same format as their field names:")]),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(" 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("additionalProperties")]),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 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('"0#"')]),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\n"),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" validData "),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('"date-time"')]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"1963-06-19T08:30:06.283185Z"')]),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("email")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"joe.bloggs@example.com"')]),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("code",[t._v("$data")]),t._v(" reference is resolved safely - it won't throw even if some property is undefined. If "),a("code",[t._v("$data")]),t._v(" resolves to "),a("code",[t._v("undefined")]),t._v(" the validation succeeds (with the exclusion of "),a("code",[t._v("const")]),t._v(" keyword). If "),a("code",[t._v("$data")]),t._v(' resolves to incorrect type (e.g. not "number" for maximum keyword) the validation fails.')]),t._v(" "),a("h2",{attrs:{id:"merge-and-patch-keywords"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#merge-and-patch-keywords"}},[t._v("#")]),t._v(" $merge and $patch keywords")]),t._v(" "),a("p",[t._v("With the package "),a("a",{attrs:{href:"https://github.com/ajv-validator/ajv-merge-patch",target:"_blank",rel:"noopener noreferrer"}},[t._v("ajv-merge-patch"),a("OutboundLink")],1),t._v(" you can use the keywords "),a("code",[t._v("$merge")]),t._v(" and "),a("code",[t._v("$patch")]),t._v(" that allow extending JSON Schemas with patches using formats "),a("a",{attrs:{href:"https://datatracker.ietf.org/doc/rfc7396/",target:"_blank",rel:"noopener noreferrer"}},[t._v("JSON Merge Patch (RFC 7396)"),a("OutboundLink")],1),t._v(" and "),a("a",{attrs:{href:"https://datatracker.ietf.org/doc/rfc6902/",target:"_blank",rel:"noopener noreferrer"}},[t._v("JSON Patch (RFC 6902)"),a("OutboundLink")],1),t._v(".")]),t._v(" "),a("p",[t._v("To add keywords "),a("code",[t._v("$merge")]),t._v(" and "),a("code",[t._v("$patch")]),t._v(" to Ajv instance use this code:")]),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-merge-patch"')]),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")])])]),a("p",[t._v("Examples.")]),t._v(" "),a("p",[t._v("Using "),a("code",[t._v("$merge")]),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("$merge")]),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("source")]),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("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("p")]),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("}")]),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("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("with")]),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("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("q")]),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",[t._v("Using "),a("code",[t._v("$patch")]),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("$patch")]),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("source")]),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("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("p")]),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("}")]),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("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("with")]),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("op")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"add"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("path")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"/properties/q"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("value")]),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 punctuation"}},[t._v("}")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])]),a("p",[t._v("The schemas above are equivalent to this schema:")]),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("p")]),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("q")]),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",[t._v("The properties "),a("code",[t._v("source")]),t._v(" and "),a("code",[t._v("with")]),t._v(" in the keywords "),a("code",[t._v("$merge")]),t._v(" and "),a("code",[t._v("$patch")]),t._v(" can use absolute or relative "),a("code",[t._v("$ref")]),t._v(" to point to other schemas previously added to the Ajv instance or to the fragments of the current schema.")]),t._v(" "),a("p",[t._v("See the package "),a("a",{attrs:{href:"https://github.com/ajv-validator/ajv-merge-patch",target:"_blank",rel:"noopener noreferrer"}},[t._v("ajv-merge-patch"),a("OutboundLink")],1),t._v(" for more information.")])])}),[],!1,null,null,null);a.default=r.exports}}]); \ No newline at end of file diff --git a/assets/js/53.7a8b1064.js b/assets/js/53.7a8b1064.js new file mode 100644 index 000000000..d241036f3 --- /dev/null +++ b/assets/js/53.7a8b1064.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[53],{483:function(t,a,s){"use strict";s.r(a);var e=s(14),n=Object(e.a)({},(function(){var t=this,a=t._self._c;return a("ContentSlotsDistributor",{attrs:{"slot-key":t.$parent.slotKey}},[a("h1",{attrs:{id:"execution-environments"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#execution-environments"}},[t._v("#")]),t._v(" Execution environments")]),t._v(" "),a("p"),a("div",{staticClass:"table-of-contents"},[a("ul",[a("li",[a("a",{attrs:{href:"#server-side-node-js"}},[t._v("Server-side Node.js")])]),a("li",[a("a",{attrs:{href:"#short-lived-environments"}},[t._v("Short-lived environments")])]),a("li",[a("a",{attrs:{href:"#browsers"}},[t._v("Browsers")])]),a("li",[a("a",{attrs:{href:"#es5-environments"}},[t._v("ES5 environments")])]),a("li",[a("a",{attrs:{href:"#cjs-vs-esm-exports"}},[t._v("CJS vs ESM exports")])]),a("li",[a("a",{attrs:{href:"#other-javascript-environments"}},[t._v("Other JavaScript environments")])]),a("li",[a("a",{attrs:{href:"#command-line-interface"}},[t._v("Command line interface")])])])]),a("p"),t._v(" "),a("h2",{attrs:{id:"server-side-node-js"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#server-side-node-js"}},[t._v("#")]),t._v(" Server-side Node.js")]),t._v(" "),a("p",[t._v("The main consideration for using Ajv server-side is to "),a("a",{attrs:{href:"./managing-schemas"}},[t._v("manage compiled schemas")]),t._v(" correctly, ensuring that the same schema is not compiled more than once.")]),t._v(" "),a("h2",{attrs:{id:"short-lived-environments"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#short-lived-environments"}},[t._v("#")]),t._v(" Short-lived environments")]),t._v(" "),a("p",[t._v('Depending on the life-time of the environments, the benefits from "compile once - validate many times" model can be limited - you can consider using '),a("a",{attrs:{href:"../standalone"}},[t._v("standalone validation code")]),t._v(".")]),t._v(" "),a("p",[t._v("If you have a pre-defined set of schemas, you can:")]),t._v(" "),a("ol",[a("li",[t._v("compile all schemas in the build step - you can either write your own script or use "),a("a",{attrs:{href:"https://github.com/ajv-validator/ajv",target:"_blank",rel:"noopener noreferrer"}},[t._v("ajv-cli"),a("OutboundLink")],1),t._v(".")]),t._v(" "),a("li",[t._v("generate and beautify standalone validation code - you can have all your schemas exported from one file.")]),t._v(" "),a("li",[t._v("additionally, you can inline all dependencies on Ajv or ajv-formats using any bundling tools.")]),t._v(" "),a("li",[t._v("deploy compiled schemas as part of your application or library (with or without dependency on Ajv, depending on whether you did step 3 and which validation keywords are used in the schemas)")])]),t._v(" "),a("p",[t._v("Please see "),a("a",{attrs:{href:"https://github.com/gajus/table",target:"_blank",rel:"noopener noreferrer"}},[t._v("gajus/table"),a("OutboundLink")],1),t._v(" package that pre-compiles schemas in this way.")]),t._v(" "),a("p",[t._v("Even if your schemas need to be stored in the database, you can still compile schemas once and store your validation functions alongside schemas in the database as well, loading them on demand.")]),t._v(" "),a("h2",{attrs:{id:"browsers"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#browsers"}},[t._v("#")]),t._v(" Browsers")]),t._v(" "),a("p",[t._v("See "),a("RouterLink",{attrs:{to:"/security.html#content-security-policy"}},[t._v("Content Security Policy")]),t._v(" to decide how best to use Ajv in the browser for your use case.")],1),t._v(" "),a("p",[t._v("Whether you compile schemas in the browser or use "),a("a",{attrs:{href:"../standalone"}},[t._v("standalone validation code")]),t._v(", it is recommended that you bundle them together with your application code.")]),t._v(" "),a("p",[t._v("If you need to use Ajv in several application bundles you can create a separate UMD bundles of Ajv using "),a("code",[t._v("npm run bundle")]),t._v(" script.")]),t._v(" "),a("p",[t._v("In this case you need to load Ajv using the correct bundle, depending on which schema language and which version you need to use:")]),t._v(" "),a("code-group",[a("code-block",{attrs:{title:"JSON Schema (draft-07)"}},[a("div",{staticClass:"language-html extra-class"},[a("pre",{pre:!0,attrs:{class:"language-html"}},[a("code",[a("span",{pre:!0,attrs:{class:"token tag"}},[a("span",{pre:!0,attrs:{class:"token tag"}},[a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("<")]),t._v("script")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token attr-name"}},[t._v("src")]),a("span",{pre:!0,attrs:{class:"token attr-value"}},[a("span",{pre:!0,attrs:{class:"token punctuation attr-equals"}},[t._v("=")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v('"')]),t._v("bundle/ajv7.min.js"),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 script"}}),a("span",{pre:!0,attrs:{class:"token tag"}},[a("span",{pre:!0,attrs:{class:"token tag"}},[a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("")])]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token tag"}},[a("span",{pre:!0,attrs:{class:"token tag"}},[a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("<")]),t._v("script")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(">")])]),a("span",{pre:!0,attrs:{class:"token script"}},[a("span",{pre:!0,attrs:{class:"token language-javascript"}},[t._v("\n "),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 keyword"}},[t._v("function")]),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 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(" window"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("ajv7\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 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 tag"}},[a("span",{pre:!0,attrs:{class:"token tag"}},[a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("")])]),t._v("\n")])])])]),t._v(" "),a("code-block",{attrs:{title:"JSON Schema (draft-2019-09)"}},[a("div",{staticClass:"language-html extra-class"},[a("pre",{pre:!0,attrs:{class:"language-html"}},[a("code",[a("span",{pre:!0,attrs:{class:"token tag"}},[a("span",{pre:!0,attrs:{class:"token tag"}},[a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("<")]),t._v("script")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token attr-name"}},[t._v("src")]),a("span",{pre:!0,attrs:{class:"token attr-value"}},[a("span",{pre:!0,attrs:{class:"token punctuation attr-equals"}},[t._v("=")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v('"')]),t._v("bundle/ajv2019.min.js"),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 script"}}),a("span",{pre:!0,attrs:{class:"token tag"}},[a("span",{pre:!0,attrs:{class:"token tag"}},[a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("")])]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token tag"}},[a("span",{pre:!0,attrs:{class:"token tag"}},[a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("<")]),t._v("script")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(">")])]),a("span",{pre:!0,attrs:{class:"token script"}},[a("span",{pre:!0,attrs:{class:"token language-javascript"}},[t._v("\n "),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 keyword"}},[t._v("function")]),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 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(" window"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("ajv2019\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 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 tag"}},[a("span",{pre:!0,attrs:{class:"token tag"}},[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-html extra-class"},[a("pre",{pre:!0,attrs:{class:"language-html"}},[a("code",[a("span",{pre:!0,attrs:{class:"token tag"}},[a("span",{pre:!0,attrs:{class:"token tag"}},[a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("<")]),t._v("script")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token attr-name"}},[t._v("src")]),a("span",{pre:!0,attrs:{class:"token attr-value"}},[a("span",{pre:!0,attrs:{class:"token punctuation attr-equals"}},[t._v("=")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v('"')]),t._v("bundle/ajvJTD.min.js"),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 script"}}),a("span",{pre:!0,attrs:{class:"token tag"}},[a("span",{pre:!0,attrs:{class:"token tag"}},[a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("")])]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token tag"}},[a("span",{pre:!0,attrs:{class:"token tag"}},[a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("<")]),t._v("script")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(">")])]),a("span",{pre:!0,attrs:{class:"token script"}},[a("span",{pre:!0,attrs:{class:"token language-javascript"}},[t._v("\n "),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 keyword"}},[t._v("function")]),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 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(" window"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("ajvJTD\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 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 tag"}},[a("span",{pre:!0,attrs:{class:"token tag"}},[a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("")])]),t._v("\n")])])])])],1),t._v(" "),a("p",[t._v("This bundle can be used with different module systems; it creates global "),a("code",[t._v("ajv")]),t._v("/"),a("code",[t._v("ajv2019")]),t._v("/"),a("code",[t._v("ajvJTD")]),t._v(" if no module system is found.")]),t._v(" "),a("p",[t._v("The browser bundles are available on "),a("a",{attrs:{href:"https://cdnjs.com/libraries/ajv",target:"_blank",rel:"noopener noreferrer"}},[t._v("cdnjs"),a("OutboundLink")],1),t._v(".")]),t._v(" "),a("div",{staticClass:"custom-block warning"},[a("p",{staticClass:"custom-block-title"},[t._v("Some frameworks re-define require")]),t._v(" "),a("p",[t._v("Some frameworks, e.g. Dojo, may redefine global require in a way that is not compatible with CommonJS module format. In this case Ajv bundle has to be loaded before the framework and then you can use global "),a("code",[t._v("ajv")]),t._v(" (see issue "),a("a",{attrs:{href:"https://github.com/ajv-validator/ajv/issues/234",target:"_blank",rel:"noopener noreferrer"}},[t._v("#234"),a("OutboundLink")],1),t._v(").")])]),t._v(" "),a("div",{staticClass:"custom-block warning"},[a("p",{staticClass:"custom-block-title"},[t._v("Internet Explorer 11")]),t._v(" "),a("p",[t._v("Ajv v8 in IE 11 will not work straight out of the box. To use it either "),a("RouterLink",{attrs:{to:"/standalone.html"}},[t._v("recompile it")]),t._v(", or set the options "),a("RouterLink",{attrs:{to:"/options.html#unicoderegexp"}},[t._v("unicodeRegExp")]),t._v(" to "),a("code",[t._v("false")]),t._v(" and "),a("code",[t._v("code: { es5: true }")]),t._v(", and transpile the Ajv node module (see issue "),a("a",{attrs:{href:"https://github.com/ajv-validator/ajv/issues/1585#issuecomment-832486204",target:"_blank",rel:"noopener noreferrer"}},[t._v("#1585"),a("OutboundLink")],1),t._v(").")],1)]),t._v(" "),a("h2",{attrs:{id:"es5-environments"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#es5-environments"}},[t._v("#")]),t._v(" ES5 environments")]),t._v(" "),a("p",[t._v("You need to:")]),t._v(" "),a("ul",[a("li",[t._v("recompile Typescript to ES5 target - it is set to 2018 in the bundled compiled code.")]),t._v(" "),a("li",[t._v("generate ES5 validation code:")])]),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("code")]),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("es5")]),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("\n")])])]),a("p",[t._v("See "),a("a",{attrs:{href:"https://github.com/ajv-validator/ajv/blob/master/docs/api.md#advanced-options",target:"_blank",rel:"noopener noreferrer"}},[t._v("Advanced options"),a("OutboundLink")],1),t._v(".")]),t._v(" "),a("h2",{attrs:{id:"cjs-vs-esm-exports"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#cjs-vs-esm-exports"}},[t._v("#")]),t._v(" CJS vs ESM exports")]),t._v(" "),a("p",[t._v("The default configuration of AJV is to generate code in ES6 with Common JS (CJS) exports. This can be changed by setting\nthe ES Modules(ESM) flag.")]),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("code")]),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("esm")]),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("\n")])])]),a("h2",{attrs:{id:"other-javascript-environments"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#other-javascript-environments"}},[t._v("#")]),t._v(" Other JavaScript environments")]),t._v(" "),a("p",[t._v("Ajv is used in other JavaScript environments, including Electron apps, WeChat mini-apps and many others, where the same considerations apply as above:")]),t._v(" "),a("ul",[a("li",[t._v("compilation performance")]),t._v(" "),a("li",[t._v("restrictive content security policy")]),t._v(" "),a("li",[t._v("bundle size")])]),t._v(" "),a("p",[t._v("If any of this is important, you may have better results with pre-compiled "),a("a",{attrs:{href:"../standalone"}},[t._v("standalone validation code")]),t._v(".")]),t._v(" "),a("h2",{attrs:{id:"command-line-interface"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#command-line-interface"}},[t._v("#")]),t._v(" Command line interface")]),t._v(" "),a("p",[t._v("Ajv can be used from the terminal in any operating system supported by Node.js")]),t._v(" "),a("p",[t._v("CLI is available as a separate npm package "),a("a",{attrs:{href:"https://github.com/ajv-validator/ajv-cli",target:"_blank",rel:"noopener noreferrer"}},[t._v("ajv-cli"),a("OutboundLink")],1),t._v(".")]),t._v(" "),a("p",[t._v("It supports:")]),t._v(" "),a("ul",[a("li",[t._v("compiling JSON Schemas to test their validity")]),t._v(" "),a("li",[t._v("generating "),a("RouterLink",{attrs:{to:"/guide/docs/standalone.html"}},[t._v("standalone validation code")]),t._v(" that exports validation function(s)")],1),t._v(" "),a("li",[t._v("migrating schemas to draft-07 and draft-2019-09 (using "),a("a",{attrs:{href:"https://github.com/epoberezkin/json-schema-migrate",target:"_blank",rel:"noopener noreferrer"}},[t._v("json-schema-migrate"),a("OutboundLink")],1),t._v(")")]),t._v(" "),a("li",[t._v("validating data file(s) against JSON Schema")]),t._v(" "),a("li",[t._v("testing expected validity of data against JSON Schema")]),t._v(" "),a("li",[t._v("referenced schemas")]),t._v(" "),a("li",[t._v("user-defined meta-schemas, validation keywords and formats")]),t._v(" "),a("li",[t._v("files in JSON, JSON5, YAML, and JavaScript format")]),t._v(" "),a("li",[t._v("all Ajv options")]),t._v(" "),a("li",[t._v("reporting changes in data after validation in "),a("a",{attrs:{href:"https://datatracker.ietf.org/doc/rfc6902/",target:"_blank",rel:"noopener noreferrer"}},[t._v("JSON-patch"),a("OutboundLink")],1),t._v(" format")])])],1)}),[],!1,null,null,null);a.default=n.exports}}]); \ No newline at end of file diff --git a/assets/js/54.7aafc746.js b/assets/js/54.7aafc746.js new file mode 100644 index 000000000..d52890dfa --- /dev/null +++ b/assets/js/54.7aafc746.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[54],{484:function(t,a,s){"use strict";s.r(a);var e=s(14),r=Object(e.a)({},(function(){var t=this,a=t._self._c;return a("ContentSlotsDistributor",{attrs:{"slot-key":t.$parent.slotKey}},[a("h1",{attrs:{id:"format-validation"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#format-validation"}},[t._v("#")]),t._v(" Format validation")]),t._v(" "),a("h2",{attrs:{id:"string-formats"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#string-formats"}},[t._v("#")]),t._v(" String formats")]),t._v(" "),a("p",[t._v("From version 7 Ajv does not include formats defined by JSON Schema specification - these and several other formats are provided by "),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",[t._v("To add all formats from this plugin:")]),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(" 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")])])])]),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(" 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\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")])])])])],1),t._v(" "),a("p",[t._v("See "),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(" documentation for further details.")]),t._v(" "),a("p",[t._v('It is recommended NOT to use "format" keyword implementations with untrusted data, as they may use potentially unsafe regular expressions (even though known issues are fixed) - see '),a("RouterLink",{attrs:{to:"/security.html#redos-attack"}},[t._v("ReDoS attack")]),t._v(".")],1),t._v(" "),a("div",{staticClass:"custom-block danger"},[a("p",{staticClass:"custom-block-title"},[t._v("Format validation of untrusted data")]),t._v(" "),a("p",[t._v('If you need to use "format" keyword to validate untrusted data, you MUST assess their suitability and safety for your validation scenarios.')])]),t._v(" "),a("p",[t._v("The following formats are defined in "),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(' for string validation with "format" keyword:')]),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 with optional time-zone.")]),t._v(" "),a("li",[a("em",[t._v("date-time")]),t._v(": date-time from the same source (time-zone is mandatory).")]),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://datatracker.ietf.org/doc/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:"https://datatracker.ietf.org/doc/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://datatracker.ietf.org/doc/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("div",{staticClass:"custom-block warning"},[a("p",{staticClass:"custom-block-title"},[t._v("Additional formats in ajv-formats-draft2019")]),t._v(" "),a("p",[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:"user-defined-formats"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#user-defined-formats"}},[t._v("#")]),t._v(" User-defined formats")]),t._v(" "),a("p",[t._v("You can add and replace any formats using "),a("RouterLink",{attrs:{to:"/api.html#ajv-addformat-name-string-format-format-ajv"}},[t._v("addFormat")]),t._v(" method:")],1),t._v(" "),a("div",{staticClass:"language-javascript extra-class"},[a("pre",{pre:!0,attrs:{class:"language-javascript"}},[a("code",[t._v("ajv"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("addFormat")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"identifier"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token regex"}},[a("span",{pre:!0,attrs:{class:"token regex-delimiter"}},[t._v("/")]),a("span",{pre:!0,attrs:{class:"token regex-source language-regex"}},[t._v("^a-z\\$_[a-zA-Z$_0-9]*$")]),a("span",{pre:!0,attrs:{class:"token regex-delimiter"}},[t._v("/")])]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n")])])]),a("p",[t._v("Ajv also allows defining the formats that would be applied to numbers only:")]),t._v(" "),a("div",{staticClass:"language-javascript extra-class"},[a("pre",{pre:!0,attrs:{class:"language-javascript"}},[a("code",[t._v("ajv"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("addFormat")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"byte"')]),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 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 function-variable function"}},[t._v("validate")]),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 parameter"}},[t._v("x")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=>")]),t._v(" x "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(">=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("0")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("&&")]),t._v(" x "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("255")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("&&")]),t._v(" x "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("%")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("1")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("==")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("0")]),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("h2",{attrs:{id:"formats-and-standalone-validation-code"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#formats-and-standalone-validation-code"}},[t._v("#")]),t._v(" Formats and standalone validation code")]),t._v(" "),a("p",[t._v("If you use formats 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(" package, "),a("a",{attrs:{href:"../standalone"}},[t._v("standalone validation code")]),t._v(" will be supported out of the box.")]),t._v(" "),a("div",{staticClass:"custom-block warning"},[a("p",{staticClass:"custom-block-title"},[t._v("Standalone code and Ajv versions")]),t._v(" "),a("p",[t._v("You need to make sure that ajv-formats imports the same version and the same code of ajv as the one you use in your application for standalone validation code to work (because of "),a("code",[t._v("instanceof")]),t._v(" check that is currently used).")]),t._v(" "),a("p",[a("code",[t._v("npm")]),t._v(" and other package managers may not update the version of ajv dependency of ajv-formats when you update version of ajv in your application - the workaround is to use clean npm installation.")])]),t._v(" "),a("p",[t._v("If you define your own formats, for standalone code generation to work you need to pass the code snippet that evaluates to an object with all defined formats to the option "),a("code",[t._v("code.formats")]),t._v(":")]),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(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("default")]),a("span",{pre:!0,attrs:{class:"token operator"}},[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("}")]),t._v(" "),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("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("code")]),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("formats")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" _"),a("span",{pre:!0,attrs:{class:"token template-string"}},[a("span",{pre:!0,attrs:{class:"token template-punctuation string"}},[t._v("`")]),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('require("./my_formats")')]),a("span",{pre:!0,attrs:{class:"token template-punctuation string"}},[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")])])])]),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 punctuation"}},[t._v(",")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("_"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v(" "),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("code"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("formats"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" _"),a("span",{pre:!0,attrs:{class:"token template-string"}},[a("span",{pre:!0,attrs:{class:"token template-punctuation string"}},[t._v("`")]),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('require("./my_formats")')]),a("span",{pre:!0,attrs:{class:"token template-punctuation string"}},[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")])])])])],1)],1)}),[],!1,null,null,null);a.default=r.exports}}]); \ No newline at end of file diff --git a/assets/js/55.983d0393.js b/assets/js/55.983d0393.js new file mode 100644 index 000000000..9e9f2882f --- /dev/null +++ b/assets/js/55.983d0393.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[55],{485: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/56.696507a0.js b/assets/js/56.696507a0.js new file mode 100644 index 000000000..7c41d887e --- /dev/null +++ b/assets/js/56.696507a0.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[56],{486: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:"managing-schemas"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#managing-schemas"}},[t._v("#")]),t._v(" Managing schemas")]),t._v(" "),s("p"),s("div",{staticClass:"table-of-contents"},[s("ul",[s("li",[s("a",{attrs:{href:"#re-using-validation-functions"}},[t._v("Re-using validation functions")])]),s("li",[s("a",{attrs:{href:"#standalone-validation-code"}},[t._v("Standalone validation code")])]),s("li",[s("a",{attrs:{href:"#compiling-during-initialization"}},[t._v("Compiling during initialization")])]),s("li",[s("a",{attrs:{href:"#using-ajv-instance-cache"}},[t._v("Using Ajv instance cache")]),s("ul",[s("li",[s("a",{attrs:{href:"#cache-key-schema-vs-key-vs-id"}},[t._v("Cache key: schema vs key vs $id")])]),s("li",[s("a",{attrs:{href:"#pre-adding-all-schemas-vs-adding-on-demand"}},[t._v("Pre-adding all schemas vs adding on demand")])]),s("li",[s("a",{attrs:{href:"#asynchronous-schema-loading"}},[t._v("Asynchronous schema loading")])])])]),s("li",[s("a",{attrs:{href:"#caching-schemas-in-your-code"}},[t._v("Caching schemas in your code")])])])]),s("p"),t._v(" "),s("h2",{attrs:{id:"re-using-validation-functions"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#re-using-validation-functions"}},[t._v("#")]),t._v(" Re-using validation functions")]),t._v(" "),s("p",[t._v("Ajv validation model is optimized for server side execution, when schema compilation happens only once and validation happens multiple times - this has a substantial performance benefit comparing with validators that interpret the schema in the process of validation.")]),t._v(" "),s("p",[t._v("Transition from template-based code generation in Ajv v6 to the tree-based in v7 brought:")]),t._v(" "),s("ul",[s("li",[t._v("type-level safety against code injection via untrusted schemas")]),t._v(" "),s("li",[t._v("more efficient validation code (via "),s("RouterLink",{attrs:{to:"/codegen.html#code-optimization"}},[t._v("tree optimizations")]),t._v(")")],1),t._v(" "),s("li",[t._v("smaller memory footprint of compiled functions (schemas are no longer serialized)")]),t._v(" "),s("li",[t._v("smaller bundle size")]),t._v(" "),s("li",[t._v("more maintainable code")])]),t._v(" "),s("p",[t._v("These improvements cost slower schema compilation, and increased chance of re-compilation in case you pass a different schema object (see "),s("a",{attrs:{href:"https://github.com/ajv-validator/ajv/issues/1413",target:"_blank",rel:"noopener noreferrer"}},[t._v("#1413"),s("OutboundLink")],1),t._v("), so it is very important to manage schemas correctly, so they are only compiled once.")]),t._v(" "),s("p",[t._v("There are several approaches to manage compiled schemas.")]),t._v(" "),s("h2",{attrs:{id:"standalone-validation-code"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#standalone-validation-code"}},[t._v("#")]),t._v(" Standalone validation code")]),t._v(" "),s("p",[t._v("The motivation to pre-compile schemas:")]),t._v(" "),s("ul",[s("li",[t._v("faster startup times")]),t._v(" "),s("li",[t._v("lower memory footprint/bundle size")]),t._v(" "),s("li",[t._v("compatible with strict content security policies")]),t._v(" "),s("li",[t._v("almost no risk to compile schema more than once")]),t._v(" "),s("li",[t._v("better for short-lived environments")])]),t._v(" "),s("p",[t._v("See "),s("a",{attrs:{href:"../standalone"}},[t._v("Standalone validation code")]),t._v(" for the details.")]),t._v(" "),s("p",[t._v("There are scenarios when it can be not possible or difficult:")]),t._v(" "),s("ul",[s("li",[t._v("dynamic or user-provided schemas - while you can do caching, it can be either difficult to implement or inefficient.")]),t._v(" "),s("li",[t._v("user-defined keywords that use closures that are difficult to serialize as code.")])]),t._v(" "),s("h2",{attrs:{id:"compiling-during-initialization"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#compiling-during-initialization"}},[t._v("#")]),t._v(" Compiling during initialization")]),t._v(" "),s("p",[t._v("The simplest approach is to compile all your schemas when the application starts, outside of the code that handles requests. It can be done simply in the module scope:")]),t._v(" "),s("code-group",[s("code-block",{attrs:{title:"JavaScript"}},[s("div",{staticClass:"language-javascript extra-class"},[s("pre",{pre:!0,attrs:{class:"language-javascript"}},[s("code",[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 function"}},[t._v("require")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token string"}},[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("default\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" schema_user "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("require")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"./schema_user.json"')]),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(" 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"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" validate_user "),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_user"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n\n\n\n\n\n"),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// this is just some abstract API framework")]),t._v("\napp"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("post")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"/user"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("async")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token parameter"}},[t._v("cxt")]),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 punctuation"}},[t._v("{")]),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("(")]),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("validate_user")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("cxt"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("body"),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("// create user")]),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("// report error")]),t._v("\n cxt"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("status")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("400")]),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("}")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n")])])])]),t._v(" "),s("code-block",{attrs:{title:"TypeScript"}},[s("div",{staticClass:"language-javascript extra-class"},[s("pre",{pre:!0,attrs:{class:"language-javascript"}},[s("code",[s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("import")]),t._v(" Ajv "),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("import")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("*")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("as")]),t._v(" schema_user "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("from")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"./schema_user.json"')]),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"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" validate_user "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" ajv"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("compile"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<")]),t._v("User"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(">")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("schema_user"),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("User")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("username")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" string\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("// this is just some abstract API framework")]),t._v("\napp"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("post")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"/user"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("async")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token parameter"}},[t._v("cxt")]),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 punctuation"}},[t._v("{")]),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("(")]),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("validate_user")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("cxt"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("body"),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("// create user")]),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("// report error")]),t._v("\n cxt"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("status")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("400")]),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("}")]),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("Use single Ajv instance")]),t._v(" "),s("p",[t._v("It recommended to use a single Ajv instance for the whole application, so if you use validation in more than one module, you should:")]),t._v(" "),s("ul",[s("li",[t._v("require Ajv in a separate module responsible for validation")]),t._v(" "),s("li",[t._v("compile all validators there")]),t._v(" "),s("li",[t._v("export them to be used in multiple modules of your application")])])]),t._v(" "),s("h2",{attrs:{id:"using-ajv-instance-cache"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#using-ajv-instance-cache"}},[t._v("#")]),t._v(" Using Ajv instance cache")]),t._v(" "),s("p",[t._v("Another, more effective approach, is to use Ajv instance cache to have all compiled validators available anywhere in your application from a single import.")]),t._v(" "),s("p",[t._v("In this case you would have a separate module where you instantiate Ajv and use this instance in your application.")]),t._v(" "),s("p",[t._v("You can load all schemas and add them to Ajv instance in a single "),s("code",[t._v("validation")]),t._v(" module:")]),t._v(" "),s("code-group",[s("code-block",{attrs:{title:"validation.js"}},[s("div",{staticClass:"language-javascript extra-class"},[s("pre",{pre:!0,attrs:{class:"language-javascript"}},[s("code",[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 function"}},[t._v("require")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"ajv"')]),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(" schema_user "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("require")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"./schema_user.json"')]),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(" schema_document "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("require")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"./schema_document.json"')]),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(" ajv "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" exports"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),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("\najv"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("addSchema")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("schema_user"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"user"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\najv"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("addSchema")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("schema_document"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"document"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n")])])])]),t._v(" "),s("code-block",{attrs:{title:"validation.ts"}},[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 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("import")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("*")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("as")]),t._v(" schema_user "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("from")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"./schema_user.json"')]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("import")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("*")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("as")]),t._v(" schema_document "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("from")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"./schema_document.json"')]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("export")]),t._v(" "),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("\najv"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("addSchema")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("schema_user"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"user"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\najv"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("addSchema")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("schema_document"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"document"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n")])])])])],1),t._v(" "),s("p",[t._v("And then you can import Ajv instance and access any schema in any application module, for example "),s("code",[t._v("user")]),t._v(" module:")]),t._v(" "),s("code-group",[s("code-block",{attrs:{title:"user.js"}},[s("div",{staticClass:"language-javascript extra-class"},[s("pre",{pre:!0,attrs:{class:"language-javascript"}},[s("code",[s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("ajv"),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 function"}},[t._v("require")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"./validation"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n\n\n\n\n\n"),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// this is just some abstract API framework")]),t._v("\napp"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("post")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"/user"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("async")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token parameter"}},[t._v("cxt")]),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 punctuation"}},[t._v("{")]),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("getSchema")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"user"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),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("(")]),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("validate")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("cxt"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("body"),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("// create user")]),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("// report error")]),t._v("\n cxt"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("status")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("400")]),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("}")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n")])])])]),t._v(" "),s("code-block",{attrs:{title:"users.ts"}},[s("div",{staticClass:"language-javascript extra-class"},[s("pre",{pre:!0,attrs:{class:"language-javascript"}},[s("code",[s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("import")]),t._v(" ajv "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("from")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"./validation"')]),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("User")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("username")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" string\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("// this is just some abstract API framework")]),t._v("\napp"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("post")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"/user"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("async")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token parameter"}},[t._v("cxt")]),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 punctuation"}},[t._v("{")]),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(".")]),t._v("getSchema"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<")]),t._v("User"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(">")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"user"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),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("(")]),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("validate")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("cxt"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("body"),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("// create user")]),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("// report error")]),t._v("\n cxt"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("status")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("400")]),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("}")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n")])])])])],1),t._v(" "),s("div",{staticClass:"custom-block tip"},[s("p",{staticClass:"custom-block-title"},[t._v("On-demand vs preliminary compilation")]),t._v(" "),s("p",[t._v("In the example above, schema compilation happens only once, on the first API call, not at the application start-up time. It means that the application would start a bit faster, but the first API call would be a bit slower. If this is undesirable, you could, for example, call "),s("code",[t._v("getSchema")]),t._v(" for all added schemas after they are added, then when "),s("code",[t._v("getSchema")]),t._v(" is called inside route handler it would simply get compiled validation function from the instance cache.")])]),t._v(" "),s("h3",{attrs:{id:"cache-key-schema-vs-key-vs-id"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#cache-key-schema-vs-key-vs-id"}},[t._v("#")]),t._v(" Cache key: schema vs key vs $id")]),t._v(" "),s("p",[t._v("In the example above, the key passed to the "),s("code",[t._v("addSchema")]),t._v(" method was used to retrieve schemas from the cache. Other options are:")]),t._v(" "),s("ul",[s("li",[t._v("use schema root $id attribute. While it usually looks like URI, it does not mean Ajv downloads it from this URI - this is simply $id used to identify and access the schema. You can though configure Ajv to download schemas on demand - see "),s("a",{attrs:{href:"#asynchronous-schema-loading"}},[t._v("Asynchronous schema loading")])]),t._v(" "),s("li",[t._v("use schema object itself as a key to the cache (it is possible, because Ajv uses Map). This approach is not recommended, because it would only work if you pass the same instance of the schema object that was passed to "),s("code",[t._v("addSchema")]),t._v(" method - it is easy to make a mistake that would result in schema being compiled every time it is used.")])]),t._v(" "),s("h3",{attrs:{id:"pre-adding-all-schemas-vs-adding-on-demand"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#pre-adding-all-schemas-vs-adding-on-demand"}},[t._v("#")]),t._v(" Pre-adding all schemas vs adding on demand")]),t._v(" "),s("p",[t._v("In the example above all schemas were added in advance. It is also possible, to add schemas as they are used - it can be helpful if there are many schemas. In this case, you need to check first whether the schema is already added by calling "),s("code",[t._v("getSchema")]),t._v(" method - it would return "),s("code",[t._v("undefined")]),t._v(" if not:")]),t._v(" "),s("div",{staticClass:"language-javascript extra-class"},[s("pre",{pre:!0,attrs:{class:"language-javascript"}},[s("code",[s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" schema_user "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("require")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"./schema_user.json"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("let")]),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("getSchema")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"user"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),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("(")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("!")]),t._v("validate"),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 ajv"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("addSchema")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("schema_user"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"user"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n 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("getSchema")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"user"')]),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("p",[t._v("If your schema has "),s("code",[t._v("$id")]),t._v(" attribute, for example:")]),t._v(" "),s("code-group",[s("code-block",{attrs:{title:"schema_user.json"}},[s("div",{staticClass:"language-json extra-class"},[s("pre",{pre:!0,attrs:{class:"language-json"}},[s("code",[s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token property"}},[t._v('"$id"')]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"https://example.com/user.json"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token property"}},[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('"object"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token property"}},[t._v('"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 "),s("span",{pre:!0,attrs:{class:"token property"}},[t._v('"username"')]),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 property"}},[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("}")]),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('"username"')]),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("then the above logic can be simpler:")]),t._v(" "),s("div",{staticClass:"language-javascript extra-class"},[s("pre",{pre:!0,attrs:{class:"language-javascript"}},[s("code",[s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" schema_user "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("require")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"./schema_user.json"')]),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(" 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("getSchema")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"https://example.com/user.json"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n "),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_user"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n")])])]),s("p",[t._v("The above is possible because when the schema has "),s("code",[t._v("$id")]),t._v(" attribute "),s("code",[t._v("compile")]),t._v(" method both compiles the schema (returning the validation function) and adds it to the Ajv instance cache at the same time.")]),t._v(" "),s("h3",{attrs:{id:"asynchronous-schema-loading"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#asynchronous-schema-loading"}},[t._v("#")]),t._v(" Asynchronous schema loading")]),t._v(" "),s("p",[t._v("There are cases when you need to have a large collection of schemas stored in some database or on the remote server. In this case you are likely to use schema "),s("code",[t._v("$id")]),t._v(" as some resource identifier to retrieve it - either network URI or database ID.")]),t._v(" "),s("p",[t._v("You can use "),s("code",[t._v("compileAsync")]),t._v(" "),s("RouterLink",{attrs:{to:"/guide/api.html#api-compileAsync"}},[t._v("method")]),t._v(" to asynchronously load the schemas as they are compiled, loading the schemas that are referenced from compiled schemas on demand. Ajv itself does not do any IO operations, it uses the function you supply via "),s("code",[t._v("loadSchema")]),t._v(" "),s("RouterLink",{attrs:{to:"/guide/api.html#options"}},[t._v("option")]),t._v(" to load schema from the passed ID. This function should return "),s("code",[t._v("Promise")]),t._v(" that resolves to the schema (you can use async function, as in the example).")],1),t._v(" "),s("p",[t._v("Example:")]),t._v(" "),s("div",{staticClass:"language-javascript extra-class"},[s("pre",{pre:!0,attrs:{class:"language-javascript"}},[s("code",[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("{")]),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("loadSchema")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" loadSchema"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n\najv"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("compileAsync")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("schema"),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 function"}},[t._v("then")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("function")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token parameter"}},[t._v("validate")]),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("const")]),t._v(" valid "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),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(")")]),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("}")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("async")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("function")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("loadSchema")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token parameter"}},[t._v("uri")]),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("const")]),t._v(" res "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("await")]),t._v(" request"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("json")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("uri"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),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("res"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("statusCode "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(">=")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("400")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("throw")]),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("Error")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"Loading error: "')]),t._v(" "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("+")]),t._v(" res"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("statusCode"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("return")]),t._v(" res"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("body\n"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])]),s("h2",{attrs:{id:"caching-schemas-in-your-code"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#caching-schemas-in-your-code"}},[t._v("#")]),t._v(" Caching schemas in your code")]),t._v(" "),s("p",[t._v("You can maintain cache of compiled schemas in your application independently from Ajv. It can be helpful in cases when you have multiple Ajv instances because, for example:")]),t._v(" "),s("ul",[s("li",[t._v("you need to compile different schemas with different options")]),t._v(" "),s("li",[t._v("you use both JSON Schema and JSON Type Definition schemas in one application")]),t._v(" "),s("li",[t._v("you have $id conflicts between different third party schemas you do not control")])]),t._v(" "),s("p",[t._v("Whatever approach you use, you need to ensure that each schema is compiled only once.")])],1)}),[],!1,null,null,null);s.default=e.exports}}]); \ No newline at end of file diff --git a/assets/js/57.fd777ac5.js b/assets/js/57.fd777ac5.js new file mode 100644 index 000000000..1590dc0aa --- /dev/null +++ b/assets/js/57.fd777ac5.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[57],{487:function(t,a,s){"use strict";s.r(a);var e=s(14),r=Object(e.a)({},(function(){var t=this,a=t._self._c;return a("ContentSlotsDistributor",{attrs:{"slot-key":t.$parent.slotKey}},[a("h1",{attrs:{id:"modifying-data-during-validation"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#modifying-data-during-validation"}},[t._v("#")]),t._v(" Modifying data during validation")]),t._v(" "),a("p"),a("div",{staticClass:"table-of-contents"},[a("ul",[a("li",[a("a",{attrs:{href:"#general-considerations"}},[t._v("General considerations")])]),a("li",[a("a",{attrs:{href:"#removing-additional-properties"}},[t._v("Removing additional properties")])]),a("li",[a("a",{attrs:{href:"#assigning-defaults"}},[t._v("Assigning defaults")])]),a("li",[a("a",{attrs:{href:"#coercing-data-types"}},[t._v("Coercing data types")])])])]),a("p"),t._v(" "),a("h2",{attrs:{id:"general-considerations"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#general-considerations"}},[t._v("#")]),t._v(" General considerations")]),t._v(" "),a("p",[t._v("Ajv has several options that allow to modify data during validation:")]),t._v(" "),a("ul",[a("li",[t._v("removeAdditional - to remove properties not defined in the schema object.")]),t._v(" "),a("li",[t._v("useDefaults - to assign defaults from the schema to the validated data properties.")]),t._v(" "),a("li",[t._v("coerceTypes - to change data type, when possible, to match the type(s) in the schema.")])]),t._v(" "),a("p",[t._v("You can also define keywords that modify data.")]),t._v(" "),a("div",{staticClass:"custom-block tip"},[a("p",{staticClass:"custom-block-title"},[t._v("NOT possible to modify root data")]),t._v(" "),a("p",[t._v("It is not possible to modify the root data instance passed to the validation function, only data properties can be modified. This is related to how JavaScript passes parameters, and not a limitation of Ajv.")])]),t._v(" "),a("div",{staticClass:"custom-block warning"},[a("p",{staticClass:"custom-block-title"},[t._v("Non-portable functionality")]),t._v(" "),a("p",[t._v("This functionality is non-standard - this is likely to be unsupported in other JSON Schema validator implementations.")])]),t._v(" "),a("div",{staticClass:"custom-block danger"},[a("p",{staticClass:"custom-block-title"},[t._v("Unexpected results when modifying data")]),t._v(" "),a("p",[t._v("While pure schema validation produces the results independent of the keywords and subschema order, enabling any feature that may modify the data makes validation impure and its results are likely to depend on the order of evaluation of keywords and subschemas.")]),t._v(" "),a("p",[t._v("The order of evaluation of subschemas in keywords like "),a("code",[t._v("allOf")]),t._v(" is always the same as the order of subschemas in the array.")]),t._v(" "),a("p",[t._v("On another hand, the order of evaluation of keywords, while consistent between validations and not dependent on how schema object is created, is neither documented nor guaranteed, so it can change in the future major versions (and, in rare cases, it can change in minor version - e.g. when there is bug that needs to be fixed).")]),t._v(" "),a("p",[t._v("It is strongly recommended to always put user-defined keywords that can mutate data in separate subschemas inside "),a("code",[t._v("allOf")]),t._v(" keyword to make the order of evaluation unambiguous. The exceptions to this recommendation are pre-defined "),a("code",[t._v("default")]),t._v(" and "),a("code",[t._v("type")]),t._v(" keywords - they must remain in the same schema as other keywords.")])]),t._v(" "),a("h2",{attrs:{id:"removing-additional-properties"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#removing-additional-properties"}},[t._v("#")]),t._v(" Removing additional properties")]),t._v(" "),a("p",[t._v("With "),a("RouterLink",{attrs:{to:"/guide/api.html#options"}},[t._v("option "),a("code",[t._v("removeAdditional")])]),t._v(" (added by "),a("a",{attrs:{href:"https://github.com/andyscott",target:"_blank",rel:"noopener noreferrer"}},[t._v("andyscott"),a("OutboundLink")],1),t._v(") you can filter data during the validation.")],1),t._v(" "),a("p",[t._v("This option modifies original data.")]),t._v(" "),a("p",[t._v("Example:")]),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("removeAdditional")]),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("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("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("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("{")]),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('"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("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('"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 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\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("0")]),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("additional1")]),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(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// will be removed; `additionalProperties` == false")]),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("baz")]),a("span",{pre:!0,attrs:{class:"token operator"}},[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("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("additional2")]),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(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// will NOT be removed; `additionalProperties` != false")]),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\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\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("validate")]),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(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// true")]),t._v("\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("(")]),t._v("data"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v('// { "foo": 0, "bar": { "baz": "abc", "additional2": 2 }')]),t._v("\n")])])]),a("p",[t._v("If "),a("code",[t._v("removeAdditional")]),t._v(" option in the example above were "),a("code",[t._v('"all"')]),t._v(" then both "),a("code",[t._v("additional1")]),t._v(" and "),a("code",[t._v("additional2")]),t._v(" properties would have been removed.")]),t._v(" "),a("p",[t._v("If the option were "),a("code",[t._v('"failing"')]),t._v(" then property "),a("code",[t._v("additional1")]),t._v(" would have been removed regardless of its value and property "),a("code",[t._v("additional2")]),t._v(" would have been removed only if its value were failing the schema in the inner "),a("code",[t._v("additionalProperties")]),t._v(" (so in the example above it would have stayed because it passes the schema, but any non-number would have been removed).")]),t._v(" "),a("div",{staticClass:"custom-block warning"},[a("p",{staticClass:"custom-block-title"},[t._v("Unexpected results when using removeAdditional with anyOf/oneOf")]),t._v(" "),a("p",[t._v("If you use "),a("code",[t._v("removeAdditional")]),t._v(" option with "),a("code",[t._v("additionalProperties")]),t._v(" keyword inside "),a("code",[t._v("anyOf")]),t._v("/"),a("code",[t._v("oneOf")]),t._v(" keywords your validation can fail with this schema. To make it work as you expect, you have to use discriminated union with "),a("RouterLink",{attrs:{to:"/json-schema.html#discriminator"}},[t._v("discriminator")]),t._v(" keyword (requires "),a("code",[t._v("discriminator")]),t._v(" option).")],1)]),t._v(" "),a("p",[t._v("For example, with this non-discriminated union you will have unexpected results:")]),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("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 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("}")]),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('"integer"')]),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('"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("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("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",[t._v('The intention of the schema above is to allow objects with either the string property "foo" or the integer property "bar", but not with both and not with any other properties.')]),t._v(" "),a("p",[t._v("With the option "),a("code",[t._v("removeAdditional: true")]),t._v(" the validation will pass for the object "),a("code",[t._v('{ "foo": "abc"}')]),t._v(" but will fail for the object "),a("code",[t._v('{"bar": 1}')]),t._v(". It happens because while the first subschema in "),a("code",[t._v("oneOf")]),t._v(" is validated, the property "),a("code",[t._v("bar")]),t._v(" is removed because it is an additional property according to the standard (because it is not included in "),a("code",[t._v("properties")]),t._v(" keyword in the same schema).")]),t._v(" "),a("p",[t._v("While this behaviour is unexpected (issues "),a("a",{attrs:{href:"https://github.com/ajv-validator/ajv/issues/129",target:"_blank",rel:"noopener noreferrer"}},[t._v("#129"),a("OutboundLink")],1),t._v(", "),a("a",{attrs:{href:"https://github.com/ajv-validator/ajv/issues/134",target:"_blank",rel:"noopener noreferrer"}},[t._v("#134"),a("OutboundLink")],1),t._v("), it is correct. To have the expected behaviour (both objects are allowed and additional properties are removed) the schema has to be refactored in this way:")]),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("{")]),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 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("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("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("}")]),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("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 punctuation"}},[t._v("}")]),t._v("\n")])])]),a("p",[t._v("The schema above is also more efficient - it will compile into a faster function.")]),t._v(" "),a("p",[t._v("For discriminated unions you could schemas with "),a("RouterLink",{attrs:{to:"/json-schema.html#discriminator"}},[t._v("discriminator")]),t._v(" keyword (it requires "),a("code",[t._v("discriminator: true")]),t._v(" option):")],1),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('"tag"')]),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('"tag"')]),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("tag")]),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('"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("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("}")]),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("}")]),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("tag")]),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('"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("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('"integer"')]),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('"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("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("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",[t._v("With this schema, only one subschema in "),a("code",[t._v("oneOf")]),t._v(" will be evaluated, so "),a("code",[t._v("removeAdditional")]),t._v(" option will work as expected.")]),t._v(" "),a("p",[t._v("See "),a("RouterLink",{attrs:{to:"/json-schema.html#discriminator"}},[t._v("discriminator")]),t._v(" keyword.")],1),t._v(" "),a("h2",{attrs:{id:"assigning-defaults"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#assigning-defaults"}},[t._v("#")]),t._v(" Assigning defaults")]),t._v(" "),a("p",[t._v("With "),a("RouterLink",{attrs:{to:"/guide/options.html#options"}},[t._v("option "),a("code",[t._v("useDefaults")])]),t._v(" Ajv will assign values from "),a("code",[t._v("default")]),t._v(" keyword in the schemas of "),a("code",[t._v("properties")]),t._v(" and "),a("code",[t._v("items")]),t._v(" (when it is the array of schemas) to the missing properties and items.")],1),t._v(" "),a("p",[t._v("With the option value "),a("code",[t._v('"empty"')]),t._v(" properties and items equal to "),a("code",[t._v("null")]),t._v(" or "),a("code",[t._v('""')]),t._v(" (empty string) will be considered missing and assigned defaults.")]),t._v(" "),a("p",[t._v("This option modifies original data.")]),t._v(" "),a("div",{staticClass:"custom-block warning"},[a("p",{staticClass:"custom-block-title"},[t._v("Defaults are deep-cloned")]),t._v(" "),a("p",[t._v("The default value is inserted in the generated validation code as a literal, so the value inserted in the data will be the deep clone of the default in the schema.")])]),t._v(" "),a("p",[t._v("Example 1 ("),a("code",[t._v("default")]),t._v(" in "),a("code",[t._v("properties")]),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 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("useDefaults")]),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("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('"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 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(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("default")]),a("span",{pre:!0,attrs:{class:"token operator"}},[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("}")]),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(",")]),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 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("{")]),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\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\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("validate")]),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(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// true")]),t._v("\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("(")]),t._v("data"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v('// { "foo": 1, "bar": "baz" }')]),t._v("\n")])])]),a("p",[t._v("Example 2 ("),a("code",[t._v("default")]),t._v(" in "),a("code",[t._v("items")]),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 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('"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('"number"')]),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(",")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("default")]),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("]")]),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(" data "),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 number"}},[t._v("1")]),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\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("validate")]),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(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// true")]),t._v("\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("(")]),t._v("data"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v('// [ 1, "foo" ]')]),t._v("\n")])])]),a("p",[t._v("With "),a("code",[t._v("useDefaults")]),t._v(" option "),a("code",[t._v("default")]),t._v(" keywords throws exception during schema compilation when used in:")]),t._v(" "),a("ul",[a("li",[t._v("not in "),a("code",[t._v("properties")]),t._v(" or "),a("code",[t._v("items")]),t._v(" subschemas")]),t._v(" "),a("li",[t._v("in schemas inside "),a("code",[t._v("anyOf")]),t._v(", "),a("code",[t._v("oneOf")]),t._v(" and "),a("code",[t._v("not")]),t._v(" (see "),a("a",{attrs:{href:"https://github.com/ajv-validator/ajv/issues/42",target:"_blank",rel:"noopener noreferrer"}},[t._v("#42"),a("OutboundLink")],1),t._v(")")]),t._v(" "),a("li",[t._v("in "),a("code",[t._v("if")]),t._v(" schema")]),t._v(" "),a("li",[t._v("in schemas generated by user-defined "),a("em",[t._v("macro")]),t._v(" keywords")])]),t._v(" "),a("p",[t._v("The strict mode option can change the behaviour for these unsupported defaults ("),a("code",[t._v("strict: false")]),t._v(" to ignore them, "),a("code",[t._v('"log"')]),t._v(" to log a warning).")]),t._v(" "),a("p",[t._v("See "),a("RouterLink",{attrs:{to:"/strict-mode.html"}},[t._v("Strict mode")]),t._v(".")],1),t._v(" "),a("div",{staticClass:"custom-block tip"},[a("p",{staticClass:"custom-block-title"},[t._v("Default with discriminator keyword")]),t._v(" "),a("p",[t._v("Defaults will be assigned in schemas inside "),a("code",[t._v("oneOf")]),t._v(" in case "),a("RouterLink",{attrs:{to:"/json-schema.html#discriminator"}},[t._v("discriminator")]),t._v(" keyword is used.")],1)]),t._v(" "),a("h2",{attrs:{id:"coercing-data-types"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#coercing-data-types"}},[t._v("#")]),t._v(" Coercing data types")]),t._v(" "),a("p",[t._v("When you are validating user inputs all your data properties are usually strings. The option "),a("code",[t._v("coerceTypes")]),t._v(" allows you to have your data types coerced to the types specified in your schema "),a("code",[t._v("type")]),t._v(" keywords, both to pass the validation and to use the correctly typed data afterwards.")]),t._v(" "),a("p",[t._v("This option modifies original data.")]),t._v(" "),a("div",{staticClass:"custom-block warning"},[a("p",{staticClass:"custom-block-title"},[t._v("Type coercion with scalar values")]),t._v(" "),a("p",[t._v("If you pass a scalar value to the validating function its type will be coerced and it will pass the validation, but the value of the variable you pass won't be updated because scalars are passed by value.")])]),t._v(" "),a("p",[t._v("Example 1:")]),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("coerceTypes")]),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("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('"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 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(",")]),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(",")]),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 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("{")]),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 string"}},[t._v('"1"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),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 string"}},[t._v('"false"')]),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\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("validate")]),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(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// true")]),t._v("\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("(")]),t._v("data"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v('// { "foo": 1, "bar": false }')]),t._v("\n")])])]),a("p",[t._v("Example 2 (array coercions):")]),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("coerceTypes")]),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("}")]),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(" 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('"array"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),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 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("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('"boolean"')]),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\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("{")]),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 string"}},[t._v('"1"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),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 string"}},[t._v('"false"')]),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(" 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\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("validate")]),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(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// true")]),t._v("\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("(")]),t._v("data"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v('// { "foo": [1], "bar": false }')]),t._v("\n")])])]),a("p",[t._v('The coercion rules, as you can see from the example, are different from JavaScript both to validate user input as expected and to have the coercion reversible (to correctly validate cases where different types are defined in subschemas of "anyOf" and other compound keywords).')]),t._v(" "),a("p",[t._v("See "),a("RouterLink",{attrs:{to:"/coercion.html"}},[t._v("Type coercion rules")]),t._v(" for details.")],1)])}),[],!1,null,null,null);a.default=r.exports}}]); \ No newline at end of file diff --git a/assets/js/58.6986242f.js b/assets/js/58.6986242f.js new file mode 100644 index 000000000..d696e0081 --- /dev/null +++ b/assets/js/58.6986242f.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[58],{491: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.2814cdef.js b/assets/js/59.2814cdef.js new file mode 100644 index 000000000..7318c6189 --- /dev/null +++ b/assets/js/59.2814cdef.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[59],{489: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/6.cb658ff0.js b/assets/js/6.cb658ff0.js new file mode 100644 index 000000000..432e641b1 --- /dev/null +++ b/assets/js/6.cb658ff0.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[6],{286:function(e,t,a){},324:function(e,t,a){"use strict";a(286)},456:function(e,t,a){"use strict";a.r(t);var o={name:"CodeGroup",data:()=>({codeTabs:[],activeCodeTabIndex:-1}),watch:{activeCodeTabIndex(e){this.activateCodeTab(e)}},mounted(){this.loadTabs()},methods:{changeCodeTab(e){this.activeCodeTabIndex=e},loadTabs(){this.codeTabs=(this.$slots.default||[]).filter(e=>Boolean(e.componentOptions)).map((e,t)=>(""===e.componentOptions.propsData.active&&(this.activeCodeTabIndex=t),{title:e.componentOptions.propsData.title,elm:e.elm})),-1===this.activeCodeTabIndex&&this.codeTabs.length>0&&(this.activeCodeTabIndex=0),this.activateCodeTab(0)},activateCodeTab(e){this.codeTabs.forEach(e=>{e.elm&&e.elm.classList.remove("theme-code-block__active")}),this.codeTabs[e].elm&&this.codeTabs[e].elm.classList.add("theme-code-block__active")}}},s=(a(324),a(14)),c=Object(s.a)(o,(function(){var e=this,t=e._self._c;return t("ClientOnly",[t("div",{staticClass:"theme-code-group"},[t("div",{staticClass:"theme-code-group__nav"},[t("ul",{staticClass:"theme-code-group__ul"},e._l(e.codeTabs,(function(a,o){return t("li",{key:a.title,staticClass:"theme-code-group__li"},[t("button",{staticClass:"theme-code-group__nav-tab",class:{"theme-code-group__nav-tab-active":o===e.activeCodeTabIndex},on:{click:function(t){return e.changeCodeTab(o)}}},[e._v("\n "+e._s(a.title)+"\n ")])])})),0)]),e._v(" "),e._t("default"),e._v(" "),e.codeTabs.length<1?t("pre",{staticClass:"pre-blank"},[e._v("// Make sure to add code blocks to your code group")]):e._e()],2)])}),[],!1,null,"5cad0a2e",null);t.default=c.exports}}]); \ No newline at end of file diff --git a/assets/js/60.a4a69ba7.js b/assets/js/60.a4a69ba7.js new file mode 100644 index 000000000..24dc6c3de --- /dev/null +++ b/assets/js/60.a4a69ba7.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[60],{488:function(t,a,s){"use strict";s.r(a);var e=s(14),n=Object(e.a)({},(function(){var t=this,a=t._self._c;return a("ContentSlotsDistributor",{attrs:{"slot-key":t.$parent.slotKey}},[a("h1",{attrs:{id:"user-defined-keywords"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#user-defined-keywords"}},[t._v("#")]),t._v(" User-defined keywords")]),t._v(" "),a("p",[t._v("You can extend keyword available in Ajv by defining your own keywords.")]),t._v(" "),a("p",[t._v("The advantages of defining keywords are:")]),t._v(" "),a("ul",[a("li",[t._v("allow creating validation scenarios that cannot be expressed using pre-defined keywords")]),t._v(" "),a("li",[t._v("simplify your schemas")]),t._v(" "),a("li",[t._v("help bringing a bigger part of the validation logic to your schemas")]),t._v(" "),a("li",[t._v("make your schemas more expressive, less verbose and closer to your application domain")]),t._v(" "),a("li",[t._v("implement data processors that modify your data ("),a("code",[t._v("modifying")]),t._v(" option MUST be used in keyword definition) and/or create side effects while the data is being validated")])]),t._v(" "),a("p",[t._v("If a keyword is used only for side-effects and its validation result is pre-defined, use option "),a("code",[t._v("valid: true/false")]),t._v(" in keyword definition to simplify both generated code (no error handling in case of "),a("code",[t._v("valid: true")]),t._v(") and your keyword functions (no need to return any validation result).")]),t._v(" "),a("div",{staticClass:"custom-block warning"},[a("p",{staticClass:"custom-block-title"},[t._v("User-defined keywords make schemas non-portable")]),t._v(" "),a("p",[t._v("When extending JSON Schema standard with additional keywords, you have several potential concerns to be aware of:")]),t._v(" "),a("ul",[a("li",[t._v("portability of your schemas - they would only work with JavaScript or TypeScript applications where you can use Ajv.")]),t._v(" "),a("li",[t._v("additional documentation required to maintain your schemas.")])])]),t._v(" "),a("div",{staticClass:"custom-block danger"},[a("p",{staticClass:"custom-block-title"},[t._v("Avoid using non-standard keywords with JTD schemas")]),t._v(" "),a("p",[t._v("While it is possible to define additional keywords for JSON Type Definition schemas (these keywords can only be used in "),a("code",[t._v("metadata")]),t._v(" member of the schema), it is strongly recommended not to do it - JTD is specifically designed for cross-platform APIs.")])]),t._v(" "),a("p",[t._v("You can define keywords with "),a("RouterLink",{attrs:{to:"/guide/api.html#api-addkeyword"}},[t._v("addKeyword")]),t._v(" method. Keywords are defined on the "),a("code",[t._v("ajv")]),t._v(" instance level - new instances will not have previously defined keywords.")],1),t._v(" "),a("p",[t._v("Ajv allows defining keywords with:")]),t._v(" "),a("ul",[a("li",[t._v("code generation function (used by all pre-defined keywords)")]),t._v(" "),a("li",[t._v("validation function")]),t._v(" "),a("li",[t._v("compilation function")]),t._v(" "),a("li",[t._v("macro function")])]),t._v(" "),a("p",[t._v("Example. "),a("code",[t._v("range")]),t._v(" and "),a("code",[t._v("exclusiveRange")]),t._v(" keywords using compiled schema:")]),t._v(" "),a("div",{staticClass:"language-javascript extra-class"},[a("pre",{pre:!0,attrs:{class:"language-javascript"}},[a("code",[t._v("ajv"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("addKeyword")]),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("keyword")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"range"')]),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("schemaType")]),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 keyword"}},[t._v("implements")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"exclusiveRange"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token function-variable function"}},[t._v("compile")]),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 parameter"}},[a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),t._v("min"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" max"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" parentSchema")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=>")]),t._v("\n parentSchema"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("exclusiveRange "),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 operator"}},[t._v("?")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token parameter"}},[t._v("data")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=>")]),t._v(" data "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(">")]),t._v(" min "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("&&")]),t._v(" data "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token function-variable function"}},[t._v("max")]),t._v("\n "),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 parameter"}},[t._v("data")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=>")]),t._v(" data "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(">=")]),t._v(" min "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("&&")]),t._v(" data "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<=")]),t._v(" max"),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\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("{")]),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("range")]),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 number"}},[t._v("2")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("4")]),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("exclusiveRange")]),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("\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("\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("validate")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("2.01")]),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("// true")]),t._v("\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("validate")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("3.99")]),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("// true")]),t._v("\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("validate")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("2")]),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("// false")]),t._v("\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("validate")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("4")]),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("// false")]),t._v("\n")])])]),a("p",[t._v("Several keywords (typeof, instanceof, range and propertyNames) are defined in "),a("a",{attrs:{href:"https://github.com/ajv-validator/ajv-keywords",target:"_blank",rel:"noopener noreferrer"}},[t._v("ajv-keywords"),a("OutboundLink")],1),t._v(" package - they can be used for your schemas and as a starting point for your own keywords.")]),t._v(" "),a("p",[t._v("See "),a("RouterLink",{attrs:{to:"/keywords.html"}},[t._v("User-defined keywords")]),t._v(" reference for more details.")],1)])}),[],!1,null,null,null);a.default=n.exports}}]); \ No newline at end of file diff --git a/assets/js/61.95fa9b5c.js b/assets/js/61.95fa9b5c.js new file mode 100644 index 000000000..c70273cf9 --- /dev/null +++ b/assets/js/61.95fa9b5c.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[61],{490: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.0acd933a.js b/assets/js/62.0acd933a.js new file mode 100644 index 000000000..b0a9b2445 --- /dev/null +++ b/assets/js/62.0acd933a.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[62],{492: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",[a("code",[t._v("additionalItems")]),t._v(" keyword is ignored if "),a("code",[t._v("items")]),t._v(" keyword is not present or is an object. 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",[a("code",[t._v("additionalItems")]),t._v(" keyword is ignored if "),a("code",[t._v("items")]),t._v(" keyword has more elements than data array.")]),t._v(" "),a("p",[t._v("If the data array has more elements than the "),a("code",[t._v("items")]),t._v(" keyword value then 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/63.e14d0095.js b/assets/js/63.e14d0095.js new file mode 100644 index 000000000..ef687d37b --- /dev/null +++ b/assets/js/63.e14d0095.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[63],{494:function(t,a,s){"use strict";s.r(a);var e=s(14),r=Object(e.a)({},(function(){var t=this,a=t._self._c;return a("ContentSlotsDistributor",{attrs:{"slot-key":t.$parent.slotKey}},[a("h1",{attrs:{id:"json-type-definition"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#json-type-definition"}},[t._v("#")]),t._v(" JSON Type Definition")]),t._v(" "),a("p",[t._v("This document informally describes JSON Type Definition (JTD) specification to help Ajv users to start using it. For formal definition please refer to "),a("a",{attrs:{href:"https://datatracker.ietf.org/doc/rfc8927/",target:"_blank",rel:"noopener noreferrer"}},[t._v("RFC8927"),a("OutboundLink")],1),t._v(". Please report any contradictions in this document with the specification.")]),t._v(" "),a("p",[t._v("To use JTD 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(" 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("\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/dist/jtd"')]),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("p"),a("div",{staticClass:"table-of-contents"},[a("ul",[a("li",[a("a",{attrs:{href:"#jtd-schema-forms"}},[t._v("JTD schema forms")]),a("ul",[a("li",[a("a",{attrs:{href:"#type-form"}},[t._v("Type form "),a("Badge",{attrs:{text:"primitive values"}})],1)]),a("li",[a("a",{attrs:{href:"#enum-form"}},[t._v("Enum form")])]),a("li",[a("a",{attrs:{href:"#elements-form"}},[t._v("Elements form "),a("Badge",{attrs:{text:"arrays"}})],1)]),a("li",[a("a",{attrs:{href:"#properties-form"}},[t._v("Properties form "),a("Badge",{attrs:{text:"objects"}})],1)]),a("li",[a("a",{attrs:{href:"#discriminator-form"}},[t._v("Discriminator form "),a("Badge",{attrs:{text:"tagged union"}})],1)]),a("li",[a("a",{attrs:{href:"#values-form"}},[t._v("Values form "),a("Badge",{attrs:{text:"dictionary"}})],1)]),a("li",[a("a",{attrs:{href:"#ref-form"}},[t._v("Ref form "),a("Badge",{attrs:{text:"reference definitions"}})],1)]),a("li",[a("a",{attrs:{href:"#empty-form"}},[t._v("Empty form "),a("Badge",{attrs:{text:"any data"}})],1)])])]),a("li",[a("a",{attrs:{href:"#jtdschematype"}},[t._v("JTDSchemaType")]),a("ul",[a("li",[a("a",{attrs:{href:"#most-schemas"}},[t._v("Most Schemas")])]),a("li",[a("a",{attrs:{href:"#ref-schemas"}},[t._v("Ref Schemas")])]),a("li",[a("a",{attrs:{href:"#notable-omissions"}},[t._v("Notable Omissions")])])])]),a("li",[a("a",{attrs:{href:"#extending-jtd"}},[t._v("Extending JTD")]),a("ul",[a("li",[a("a",{attrs:{href:"#metadata-schema-member"}},[t._v("Metadata schema member")])]),a("li",[a("a",{attrs:{href:"#union-keyword"}},[t._v("Union keyword")])]),a("li",[a("a",{attrs:{href:"#user-defined-keywords"}},[t._v("User-defined keywords")])])])]),a("li",[a("a",{attrs:{href:"#validation-errors"}},[t._v("Validation errors")])])])]),a("p"),t._v(" "),a("h2",{attrs:{id:"jtd-schema-forms"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#jtd-schema-forms"}},[t._v("#")]),t._v(" JTD schema forms")]),t._v(" "),a("p",[t._v("JTD specification defines 8 different forms that the schema for JSON can take for one of most widely used data types in JSON messages (API requests and responses).")]),t._v(" "),a("p",[t._v("All forms require that:")]),t._v(" "),a("ul",[a("li",[t._v("schema is an object with different members, depending on the form")]),t._v(" "),a("li",[t._v("each form can have:\n"),a("ul",[a("li",[t._v("an optional member "),a("code",[t._v("nullable")]),t._v(" with a boolean value that allows data instance to be JSON "),a("code",[t._v("null")]),t._v(".")]),t._v(" "),a("li",[t._v("an optional member "),a("code",[t._v("metadata")]),t._v(' with an object value that allows to pass any additional information or extend the specification (Ajv defines keyword "union" that can be used inside '),a("code",[t._v("metadata")]),t._v(")")])])])]),t._v(" "),a("p",[t._v("Root schema can have member "),a("code",[t._v("definitions")]),t._v(" that has a dictionary of schemas that can be references from any other schemas using form "),a("code",[t._v("ref")])]),t._v(" "),a("h3",{attrs:{id:"type-form"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#type-form"}},[t._v("#")]),t._v(" Type form "),a("Badge",{attrs:{text:"primitive values"}})],1),t._v(" "),a("p",[t._v("This form defines a primitive value.")]),t._v(" "),a("p",[t._v("It has a required member "),a("code",[t._v("type")]),t._v(" and an optional members "),a("code",[t._v("nullable")]),t._v(" and "),a("code",[t._v("metadata")]),t._v(", no other members are allowed.")]),t._v(" "),a("p",[a("code",[t._v("type")]),t._v(" can have one of the following values:")]),t._v(" "),a("ul",[a("li",[a("code",[t._v('"string"')]),t._v(" - defines a string")]),t._v(" "),a("li",[a("code",[t._v('"boolean"')]),t._v(" - defines boolean value "),a("code",[t._v("true")]),t._v(" or "),a("code",[t._v("false")])]),t._v(" "),a("li",[a("code",[t._v('"timestamp"')]),t._v(" - defines timestamp ( accepting either an "),a("a",{attrs:{href:"https://datatracker.ietf.org/doc/rfc3339/",target:"_blank",rel:"noopener noreferrer"}},[t._v("RFC3339"),a("OutboundLink")],1),t._v(" JSON string or a Date object, configurable via the "),a("code",[t._v("timestamp")]),t._v(" Ajv option)")]),t._v(" "),a("li",[a("code",[t._v("type")]),t._v(" values that define integer numbers:\n"),a("ul",[a("li",[a("code",[t._v('"int8"')]),t._v(" - signed byte value (-128 .. 127)")]),t._v(" "),a("li",[a("code",[t._v('"uint8"')]),t._v(" - unsigned byte value (0 .. 255)")]),t._v(" "),a("li",[a("code",[t._v('"int16"')]),t._v(" - signed word value (-32768 .. 32767),")]),t._v(" "),a("li",[a("code",[t._v('"uint16"')]),t._v(" - unsigned word value (0 .. 65535)")]),t._v(" "),a("li",[a("code",[t._v('"int32"')]),t._v(" - signed 32-bit integer value")]),t._v(" "),a("li",[a("code",[t._v('"uint32"')]),t._v(" - unsigned 32-bit integer value")])])]),t._v(" "),a("li",[a("code",[t._v("type")]),t._v(" values that define floating point numbers:\n"),a("ul",[a("li",[a("code",[t._v('"float32"')]),t._v(" - 32-bit real number")]),t._v(" "),a("li",[a("code",[t._v('"float64"')]),t._v(" - 64-bit real number")])])])]),t._v(" "),a("p",[t._v("Unlike JSON Schema, JTD does not allow defining values that can take one of several types, but they can be defined as "),a("code",[t._v("nullable")]),t._v(".")]),t._v(" "),a("p",[a("strong",[t._v("Example")])]),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('"string"')]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])]),a("h3",{attrs:{id:"enum-form"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#enum-form"}},[t._v("#")]),t._v(" Enum form")]),t._v(" "),a("p",[t._v("This form defines a string that can take one of the values from the list (the values in the list must be unique).")]),t._v(" "),a("p",[t._v("It has a required member "),a("code",[t._v("enum")]),t._v(" and optional members "),a("code",[t._v("nullable")]),t._v(" and "),a("code",[t._v("metadata")]),t._v(", no other members are allowed.")]),t._v(" "),a("p",[t._v("Unlike JSON Schema, JTD does not allow defining "),a("code",[t._v("enum")]),t._v(" with values of any other type than string.")]),t._v(" "),a("p",[a("strong",[t._v("Example")])]),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 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('"foo"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),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("\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])]),a("h3",{attrs:{id:"elements-form"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#elements-form"}},[t._v("#")]),t._v(" Elements form "),a("Badge",{attrs:{text:"arrays"}})],1),t._v(" "),a("p",[t._v("This form defines a homogenous array of any size (possibly empty) with the elements that satisfy a given schema.")]),t._v(" "),a("p",[t._v("It has a required member "),a("code",[t._v("elements")]),t._v(" (schema that elements should satisfy) and optional members "),a("code",[t._v("nullable")]),t._v(" and "),a("code",[t._v("metadata")]),t._v(", no other members are allowed.")]),t._v(" "),a("p",[t._v("Unlike JSON Schema, the data instance must be JSON array (without using additional "),a("code",[t._v("type")]),t._v(" keyword), and there is no way to enforce the restrictions that cannot be present on type level of most languages, such as array size and uniqueness of items.")]),t._v(" "),a("p",[a("strong",[t._v("Example")])]),t._v(" "),a("p",[t._v("Schema:")]),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("elements")]),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"')]),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",[t._v("Valid data: "),a("code",[t._v("[]")]),t._v(", "),a("code",[t._v('["foo"]')]),t._v(", "),a("code",[t._v('["foo", "bar"]')])]),t._v(" "),a("p",[t._v("Invalid data: "),a("code",[t._v('["foo", 1]')]),t._v(", any type other than array")]),t._v(" "),a("h3",{attrs:{id:"properties-form"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#properties-form"}},[t._v("#")]),t._v(" Properties form "),a("Badge",{attrs:{text:"objects"}})],1),t._v(" "),a("p",[t._v("This form defines record (JSON object) that has defined required and optional properties.")]),t._v(" "),a("p",[t._v("It is required that this form has either "),a("code",[t._v("properties")]),t._v(" member, or "),a("code",[t._v("optionalProperties")]),t._v(", or both, in which case the cannot have overlapping properties. Additional properties can be allowed by adding an optional boolean member "),a("code",[t._v("additionalProperties")]),t._v(" with a value "),a("code",[t._v("true")]),t._v(". This form, as all other, can have optional "),a("code",[t._v("nullable")]),t._v(" and "),a("code",[t._v("metadata")]),t._v(" members.")]),t._v(" "),a("p",[t._v("Unlike JSON Schema, all properties defined in "),a("code",[t._v("properties")]),t._v(" schema member are required, the data instance must be JSON object (without using additional "),a("code",[t._v("type")]),t._v(" keyword) and by default additional properties are not allowed (with the exception of discriminator tag - see the next section). This strictness minimises user mistakes.")]),t._v(" "),a("p",[a("strong",[t._v("Example 1.")])]),t._v(" "),a("p",[t._v("Schema:")]),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("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("{")]),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"')]),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",[t._v("Valid data: "),a("code",[t._v('{foo: "bar"}')])]),t._v(" "),a("p",[t._v("Invalid data: "),a("code",[t._v("{}")]),t._v(", "),a("code",[t._v("{foo: 1}")]),t._v(", "),a("code",[t._v('{foo: "bar", bar: 1}')]),t._v(", any type other than object")]),t._v(" "),a("p",[a("strong",[t._v("Example 2.")])]),t._v(" "),a("p",[t._v("Schema:")]),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("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("}")]),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 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('"1"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"2"')]),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("additionalProperties")]),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("Valid data: "),a("code",[t._v('{foo: "bar"}')]),t._v(", "),a("code",[t._v('{foo: "bar", bar: "1"}')]),t._v(", "),a("code",[t._v('{foo: "bar", additional: 1}')])]),t._v(" "),a("p",[t._v("Invalid data: "),a("code",[t._v("{}")]),t._v(", "),a("code",[t._v("{foo: 1}")]),t._v(", "),a("code",[t._v('{foo: "bar", bar: "3"}')]),t._v(", any type other than object")]),t._v(" "),a("p",[a("strong",[t._v("Example 3: invalid schema (overlapping required and optional properties)")])]),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("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("}")]),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("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("}")]),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("h3",{attrs:{id:"discriminator-form"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#discriminator-form"}},[t._v("#")]),t._v(" Discriminator form "),a("Badge",{attrs:{text:"tagged union"}})],1),t._v(" "),a("p",[t._v("This form defines discriminated (tagged) union of different record types.")]),t._v(" "),a("p",[t._v("It has required members "),a("code",[t._v("discriminator")]),t._v(" and "),a("code",[t._v("mapping")]),t._v(" and optional members "),a("code",[t._v("nullable")]),t._v(" and "),a("code",[t._v("metadata")]),t._v(", no other members are allowed.")]),t._v(" "),a("p",[t._v("The string value of "),a("code",[t._v("discriminator")]),t._v(" schema member contains the name of the data member that is the tag of the union. "),a("code",[t._v("mapping")]),t._v(" schema member contains the dictionary of schemas that are applied according to the value of the tag member in the data. Schemas inside "),a("code",[t._v("mapping")]),t._v(' must have "properties" form.')]),t._v(" "),a("p",[t._v("Properties forms inside "),a("code",[t._v("mapping")]),t._v(" cannot be "),a("code",[t._v("nullable")]),t._v(" and cannot define the same property as discriminator tag.")]),t._v(" "),a("p",[a("strong",[t._v("Example 1.")])]),t._v(" "),a("p",[t._v("Schema:")]),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("discriminator")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"version"')]),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("mapping")]),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('"1"')]),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('"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("}")]),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('"2"')]),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('"uint8"')]),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",[t._v("Valid data: "),a("code",[t._v('{version: "1", foo: "1"}')]),t._v(", "),a("code",[t._v('{version: "2", foo: 1}')])]),t._v(" "),a("p",[t._v("Invalid data: "),a("code",[t._v("{}")]),t._v(", "),a("code",[t._v('{foo: "1"}')]),t._v(", "),a("code",[t._v('{version: 1, foo: "1"}')]),t._v(", any type other than object")]),t._v(" "),a("p",[a("strong",[t._v("Example 3: invalid schema (discriminator tag member defined in mapping)")])]),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("discriminator")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"version"')]),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("mapping")]),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('"1"')]),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("version")]),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('"1"')]),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("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("}")]),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 string-property property"}},[t._v('"2"')]),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("version")]),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('"2"')]),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("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('"uint8"')]),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("h3",{attrs:{id:"values-form"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#values-form"}},[t._v("#")]),t._v(" Values form "),a("Badge",{attrs:{text:"dictionary"}})],1),t._v(" "),a("p",[t._v("This form defines a homogenous dictionary where the values of members satisfy a given schema.")]),t._v(" "),a("p",[t._v("It has a required member "),a("code",[t._v("values")]),t._v(" (schema that member values should satisfy) and optional members "),a("code",[t._v("nullable")]),t._v(" and "),a("code",[t._v("metadata")]),t._v(", no other members are allowed.")]),t._v(" "),a("p",[t._v("Unlike JSON Schema, the data instance must be JSON object (without using additional "),a("code",[t._v("type")]),t._v(" keyword), and there is no way to enforce size restrictions.")]),t._v(" "),a("p",[a("strong",[t._v("Example")])]),t._v(" "),a("p",[t._v("Schema:")]),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("values")]),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('"uint8"')]),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",[t._v("Valid data: "),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",[t._v("Invalid data: "),a("code",[t._v('{"foo": "bar"}')]),t._v(", any type other than object")]),t._v(" "),a("h3",{attrs:{id:"ref-form"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#ref-form"}},[t._v("#")]),t._v(" Ref form "),a("Badge",{attrs:{text:"reference definitions"}})],1),t._v(" "),a("p",[t._v("This form defines a reference to the schema that is present in the corresponding key in the "),a("code",[t._v("definitions")]),t._v(" member of the root schema.")]),t._v(" "),a("p",[t._v("It has a required member "),a("code",[t._v("ref")]),t._v(" (member of "),a("code",[t._v("definitions")]),t._v(" object in the root schema) and optional members "),a("code",[t._v("nullable")]),t._v(" and "),a("code",[t._v("metadata")]),t._v(", no other members are allowed.")]),t._v(" "),a("p",[t._v("Unlike JSON Schema, JTD does not allow to reference:")]),t._v(" "),a("ul",[a("li",[t._v("any schema fragment other than root level "),a("code",[t._v("definitions")]),t._v(" member")]),t._v(" "),a("li",[t._v("root of the schema - there is another way to define a self-recursive schema (see Example 2)")]),t._v(" "),a("li",[t._v("another schema file (but you can still combine schemas from multiple files using JavaScript).")])]),t._v(" "),a("p",[a("strong",[t._v("Example 1.")])]),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("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("propFoo")]),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("ref")]),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(",")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token literal-property 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")]),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("definitions")]),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("}")]),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("strong",[t._v("Example 2: self-referencing schema for binary tree")])]),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("ref")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"tree"')]),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("definitions")]),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("tree")]),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("value")]),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("left")]),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("ref")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"tree"')]),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("right")]),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("ref")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"tree"')]),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("strong",[t._v("Example 3: invalid schema (missing reference)")])]),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("ref")]),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(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("definitions")]),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")])])]),a("h3",{attrs:{id:"empty-form"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#empty-form"}},[t._v("#")]),t._v(" Empty form "),a("Badge",{attrs:{text:"any data"}})],1),t._v(" "),a("p",[t._v("Empty JTD schema defines the data instance that can be of any type, including JSON "),a("code",[t._v("null")]),t._v(" (even if "),a("code",[t._v("nullable")]),t._v(" member is not present). It cannot have any member other than "),a("code",[t._v("nullable")]),t._v(" and "),a("code",[t._v("metadata")]),t._v(".")]),t._v(" "),a("h2",{attrs:{id:"jtdschematype"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#jtdschematype"}},[t._v("#")]),t._v(" JTDSchemaType")]),t._v(" "),a("p",[t._v("The type "),a("code",[t._v("JTDSchemaType")]),t._v(" can be used to validate that the written schema matches the type you expect to validate. This type is strict such that if typescript compiles, you should require no further type guards. The downside of this is that the types that "),a("code",[t._v("JTDSchemaType")]),t._v(" can verify are limited to the types that JTD can verify. If a type doesn't verify, "),a("code",[t._v("JTDSchemaType")]),t._v(" should resolve to "),a("code",[t._v("never")]),t._v(", throwing an error when you try to assign to it. This means that types like "),a("code",[t._v("1 | 2 | 3")]),t._v(", or general untagged unions (outside of unions of string literals) cannot be used with "),a("code",[t._v("JTDSchemaType")]),t._v(".")]),t._v(" "),a("h3",{attrs:{id:"most-schemas"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#most-schemas"}},[t._v("#")]),t._v(" Most Schemas")]),t._v(" "),a("p",[t._v("Most straightforward types should work with "),a("code",[t._v("JTDSchemaType")]),t._v(", e.g.")]),t._v(" "),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("interface")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("MyType")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n num"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("number")]),t._v("\n optionalStr"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("string")]),t._v("\n nullableEnum"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"v1.0"')]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("|")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"v1.2"')]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("|")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("null")]),t._v("\n values"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" Record"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<")]),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("string")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("number")]),a("span",{pre:!0,attrs:{class:"token operator"}},[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(" schema"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" JTDSchemaType"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<")]),t._v("MyType"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(">")]),t._v(" "),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 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 num"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),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('"float64"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n nullableEnum"),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('"v1.0"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"v1.2"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),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")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n values"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("values"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),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("}")]),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 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 optionalStr"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),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 punctuation"}},[t._v("}")]),t._v("\n")])])]),a("p",[t._v("will compile. Using "),a("code",[t._v("schema")]),t._v(" with AJV will guarantee type safety.")]),t._v(" "),a("h3",{attrs:{id:"ref-schemas"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#ref-schemas"}},[t._v("#")]),t._v(" Ref Schemas")]),t._v(" "),a("p",[t._v("Ref schemas are a little more advanced, because the types of every definition must be specified in advance.\nA simple ref schema is relatively straightforward:")]),t._v(" "),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("const")]),t._v(" schema"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" JTDSchemaType"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("val"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[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(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("num"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("number")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(">")]),t._v(" "),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 definitions"),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 num"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),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('"float64"')]),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 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 val"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("ref"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"num"')]),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",[t._v("note that the type of all definitions was included as a second argument to "),a("code",[t._v("JTDSchemaType")]),t._v(".")]),t._v(" "),a("p",[t._v("This also works for recursive schemas:")]),t._v(" "),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("type")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("LinkedList")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("val"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("number")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v(" next"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" LinkedList"),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(" schema"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" JTDSchemaType"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<")]),t._v("LinkedList"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("node"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" LinkedList"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(">")]),t._v(" "),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 definitions"),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 node"),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 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 val"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),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('"float64"')]),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 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 next"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("ref"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"node"')]),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("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n ref"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"node"')]),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("h3",{attrs:{id:"notable-omissions"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#notable-omissions"}},[t._v("#")]),t._v(" Notable Omissions")]),t._v(" "),a("p",[a("code",[t._v("JTDSchemaType")]),t._v(" currently validates that if the schema compiles it will verify an accurate type, but there are a few places with potentially unexpected behavior.\n"),a("code",[t._v("JTDSchemaType")]),t._v(" doesn't verify the schema is correct. It won't reject schemas that definitions anywhere by the root, and it won't reject discriminator schemas that still define the descriminator in mapping properties. It also won't verify that enum schemas have every enum member as this isn't generally feasible in typescript yet.")]),t._v(" "),a("h2",{attrs:{id:"extending-jtd"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#extending-jtd"}},[t._v("#")]),t._v(" Extending JTD")]),t._v(" "),a("h3",{attrs:{id:"metadata-schema-member"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#metadata-schema-member"}},[t._v("#")]),t._v(" Metadata schema member")]),t._v(" "),a("p",[t._v("Each schema form may have an optional member "),a("code",[t._v("metadata")]),t._v(" that JTD reserves for implementation/application specific extensions. Ajv uses this member as a location where any non-standard keywords can be used, such as:")]),t._v(" "),a("ul",[a("li",[a("code",[t._v("union")]),t._v(" keyword included in Ajv")]),t._v(" "),a("li",[t._v("any user-defined keywords, for example keywords defined in "),a("a",{attrs:{href:"https://github.com/ajv-validator/ajv-keywords",target:"_blank",rel:"noopener noreferrer"}},[t._v("ajv-keywords"),a("OutboundLink")],1),t._v(" package")]),t._v(" "),a("li",[t._v("JSON Schema keywords, as long as their names are different from standard JTD keywords. It can be used to enable a gradual migration from JSON Schema to JTD, should it be required.")])]),t._v(" "),a("div",{staticClass:"custom-block warning"},[a("p",{staticClass:"custom-block-title"},[t._v("Extensions are non-portable")]),t._v(" "),a("p",[t._v("Ajv-specific extension to JTD are likely to be unsupported by other tools, so while it may simplify adoption, it undermines the cross-platform objective of using JTD. While it is ok to put some human readable information in "),a("code",[t._v("metadata")]),t._v(" member, it is recommended not to add any validation logic there (even if it is supported by Ajv).")])]),t._v(" "),a("p",[t._v("Additional restrictions that Ajv enforces on "),a("code",[t._v("metadata")]),t._v(" schema member:")]),t._v(" "),a("ul",[a("li",[t._v("you cannot use standard JTD keywords there. While strictly speaking it is allowed by the specification, these keywords should be ignored inside "),a("code",[t._v("metadata")]),t._v(" - the general approach of Ajv is to avoid anything that is ignored.")]),t._v(" "),a("li",[t._v("you need to define all members used in "),a("code",[t._v("metadata")]),t._v(" as keywords. If they are no-op it can be done with "),a("code",[t._v('ajv.addKeyword("my-metadata-keyword")')]),t._v(". This restriction can be removed by disabling "),a("a",{attrs:{href:"https://github.com/ajv-validator/ajv/blob/master/docs/strict-mode.md",target:"_blank",rel:"noopener noreferrer"}},[t._v("strict mode"),a("OutboundLink")],1),t._v(", without affecting the strictness of JTD - unknown keywords would still be prohibited in the schema itself.")])]),t._v(" "),a("h3",{attrs:{id:"union-keyword"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#union-keyword"}},[t._v("#")]),t._v(" Union keyword")]),t._v(" "),a("p",[t._v("Ajv defines "),a("code",[t._v("union")]),t._v(" keyword that is used in the schema that validates JTD schemas ("),a("a",{attrs:{href:"https://github.com/ajv-validator/ajv/blob/master/lib/refs/jtd-schema.ts",target:"_blank",rel:"noopener noreferrer"}},[t._v("meta-schema"),a("OutboundLink")],1),t._v(").")]),t._v(" "),a("p",[t._v("This keyword can be used only inside "),a("code",[t._v("metadata")]),t._v(" schema member.")]),t._v(" "),a("div",{staticClass:"custom-block warning"},[a("p",{staticClass:"custom-block-title"},[t._v("Union keyword is non-portable")]),t._v(" "),a("p",[t._v("This keyword is non-standard and it is not supported in other JTD tools, so it is recommended NOT to use this keyword in schemas for your data if you want them to be cross-platform.")])]),t._v(" "),a("h3",{attrs:{id:"user-defined-keywords"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#user-defined-keywords"}},[t._v("#")]),t._v(" User-defined keywords")]),t._v(" "),a("p",[t._v("Any user-defined keywords that can be used in JSON Schema schemas can also be used in JTD schemas, including the keywords in "),a("a",{attrs:{href:"https://github.com/ajv-validator/ajv-keywords",target:"_blank",rel:"noopener noreferrer"}},[t._v("ajv-keywords"),a("OutboundLink")],1),t._v(" package.")]),t._v(" "),a("div",{staticClass:"custom-block warning"},[a("p",{staticClass:"custom-block-title"},[t._v("User-defined keywords are non-portable")]),t._v(" "),a("p",[t._v("It is strongly recommended to only use it to simplify migration from JSON Schema to JTD and not to use non-standard keywords in the new schemas, as these keywords are not supported by any other tools.")])]),t._v(" "),a("div",{staticClass:"custom-block warning"},[a("p",{staticClass:"custom-block-title"},[t._v("Parsing does NOT support non-standard JTD keywords")]),t._v(" "),a("p",[t._v("compileParser method does not support non-standard JTD keywords, you will have to use JSON.parse and then validates.")])]),t._v(" "),a("h2",{attrs:{id:"validation-errors"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#validation-errors"}},[t._v("#")]),t._v(" Validation errors")]),t._v(" "),a("p",[t._v("TODO")])],1)}),[],!1,null,null,null);a.default=r.exports}}]); \ No newline at end of file diff --git a/assets/js/64.f236cd14.js b/assets/js/64.f236cd14.js new file mode 100644 index 000000000..f1be76a4b --- /dev/null +++ b/assets/js/64.f236cd14.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[64],{493: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:"user-defined-keywords"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#user-defined-keywords"}},[t._v("#")]),t._v(" User defined keywords")]),t._v(" "),a("p"),a("div",{staticClass:"table-of-contents"},[a("ul",[a("li",[a("a",{attrs:{href:"#common-attributes-of-keyword-definitions"}},[t._v("Common attributes of keyword definitions")]),a("ul",[a("li",[a("a",{attrs:{href:"#define-keyword-with-code-generation-function"}},[t._v("Define keyword with code generation function "),a("Badge",{attrs:{text:"recommended"}})],1)]),a("li",[a("a",{attrs:{href:"#define-keyword-with-validate-function"}},[t._v('Define keyword with "validate" function')])]),a("li",[a("a",{attrs:{href:"#define-keyword-with-compile-function"}},[t._v('Define keyword with "compile" function')])]),a("li",[a("a",{attrs:{href:"#define-keyword-with-macro-function"}},[t._v('Define keyword with "macro" function')])])])]),a("li",[a("a",{attrs:{href:"#schema-compilation-context"}},[t._v("Schema compilation context")])]),a("li",[a("a",{attrs:{href:"#validation-time-variables"}},[t._v("Validation time variables")])]),a("li",[a("a",{attrs:{href:"#reporting-errors"}},[t._v("Reporting errors")])])])]),a("p"),t._v(" "),a("h2",{attrs:{id:"common-attributes-of-keyword-definitions"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#common-attributes-of-keyword-definitions"}},[t._v("#")]),t._v(" Common attributes of keyword definitions")]),t._v(" "),a("p",[t._v("The usual interface to define all keywords has these properties:")]),t._v(" "),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("interface")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("_KeywordDef")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n keyword"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("string")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("|")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[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 type"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" JSONType "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("|")]),t._v(" JSONType"),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("// data type(s) that keyword applies to,")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v('// if defined, it is usually "string", "number", "object" or "array"')]),t._v("\n schemaType"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" JSONType "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("|")]),t._v(" JSONType"),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("// the allowed type(s) of value that keyword must have in the schema")]),t._v("\n error"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),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 message"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("string")]),t._v(" "),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("(")]),t._v("cxt"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" KeywordCxt"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=>")]),t._v(" Code"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n params"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("cxt"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" KeywordCxt"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=>")]),t._v(" Code\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",[t._v("Keyword definitions may have additional optional properties - see "),a("a",{attrs:{href:"https://github.com/ajv-validator/ajv/blob/master/lib/types/index.ts",target:"_blank",rel:"noopener noreferrer"}},[t._v("types"),a("OutboundLink")],1),t._v(" and "),a("a",{attrs:{href:"https://github.com/ajv-validator/ajv/blob/master/lib/compile/validate/index.ts",target:"_blank",rel:"noopener noreferrer"}},[t._v("KeywordCxt"),a("OutboundLink")],1),t._v(".")]),t._v(" "),a("h3",{attrs:{id:"define-keyword-with-code-generation-function"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#define-keyword-with-code-generation-function"}},[t._v("#")]),t._v(" Define keyword with code generation function "),a("Badge",{attrs:{text:"recommended"}})],1),t._v(" "),a("p",[t._v("Starting from v7 Ajv uses "),a("a",{attrs:{href:"https://github.com/ajv-validator/ajv/blob/master/lib/compile/codegen/index.ts",target:"_blank",rel:"noopener noreferrer"}},[t._v("CodeGen module"),a("OutboundLink")],1),t._v(" for all pre-defined keywords - see "),a("RouterLink",{attrs:{to:"/codegen.html"}},[t._v("codegen.md")]),t._v(" for details.")],1),t._v(" "),a("p",[t._v("This is the best approach for user defined keywords:")]),t._v(" "),a("ul",[a("li",[t._v("safe against code injection")]),t._v(" "),a("li",[t._v("best performance")]),t._v(" "),a("li",[t._v("the precise control over validation process")]),t._v(" "),a("li",[t._v("access to the parent data and the path to the currently validated data")])]),t._v(" "),a("p",[t._v("While Ajv can be safely used with plain JavaScript, it is strongly recommended to use Typescript for user-defined keywords that generate code - the prevention against code injection via untrusted schemas is partially based on the type system, not only on runtime checks.")]),t._v(" "),a("p",[t._v('The usual keyword definition for keywords generating code extends common interface with "code" function:')]),t._v(" "),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("interface")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("CodeKeywordDefinition")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("extends")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("_KeywordDef")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token function-variable function"}},[t._v("code")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("cxt"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" KeywordCxt"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" ruleType"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("string")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=>")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("void")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// code generation function")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])]),a("p",[t._v("Example "),a("code",[t._v("even")]),t._v(" keyword:")]),t._v(" "),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 punctuation"}},[t._v("{")]),t._v("_"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" KeywordCxt"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v(" from Ajv\n\najv"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("addKeyword")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n keyword"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"even"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n 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 schemaType"),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(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// $data: true // to support [$data reference](./guide/combining-schemas.md#data-reference), ...")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("code")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("cxt"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" KeywordCxt"),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(" "),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(" schema"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" cxt\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" op "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" schema "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),t._v(" _"),a("span",{pre:!0,attrs:{class:"token template-string"}},[a("span",{pre:!0,attrs:{class:"token template-punctuation string"}},[t._v("`")]),a("span",{pre:!0,attrs:{class:"token string"}},[t._v("!==")]),a("span",{pre:!0,attrs:{class:"token template-punctuation string"}},[t._v("`")])]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" _"),a("span",{pre:!0,attrs:{class:"token template-string"}},[a("span",{pre:!0,attrs:{class:"token template-punctuation string"}},[t._v("`")]),a("span",{pre:!0,attrs:{class:"token string"}},[t._v("===")]),a("span",{pre:!0,attrs:{class:"token template-punctuation string"}},[t._v("`")])]),t._v("\n cxt"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("fail")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("_"),a("span",{pre:!0,attrs:{class:"token template-string"}},[a("span",{pre:!0,attrs:{class:"token template-punctuation string"}},[t._v("`")]),a("span",{pre:!0,attrs:{class:"token interpolation"}},[a("span",{pre:!0,attrs:{class:"token interpolation-punctuation punctuation"}},[t._v("${")]),t._v("data"),a("span",{pre:!0,attrs:{class:"token interpolation-punctuation punctuation"}},[t._v("}")])]),a("span",{pre:!0,attrs:{class:"token string"}},[t._v(" %2 ")]),a("span",{pre:!0,attrs:{class:"token interpolation"}},[a("span",{pre:!0,attrs:{class:"token interpolation-punctuation punctuation"}},[t._v("${")]),t._v("op"),a("span",{pre:!0,attrs:{class:"token interpolation-punctuation punctuation"}},[t._v("}")])]),a("span",{pre:!0,attrs:{class:"token string"}},[t._v(" 0")]),a("span",{pre:!0,attrs:{class:"token template-punctuation string"}},[t._v("`")])]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// ... the only code change needed is to use `cxt.fail$data` here")]),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\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("even"),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("\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"),a("span",{pre:!0,attrs:{class:"token builtin"}},[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("(")]),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("validate")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("2")]),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("// true")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token builtin"}},[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("(")]),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("validate")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[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 comment"}},[t._v("// false")]),t._v("\n")])])]),a("p",[t._v("Example "),a("code",[t._v("range")]),t._v(" keyword:")]),t._v(" "),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 punctuation"}},[t._v("{")]),t._v("_"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" nil"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" KeywordCxt"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v(" from Ajv\n\najv"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("addKeyword")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n keyword"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"range"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n 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 function"}},[t._v("code")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("cxt"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" KeywordCxt"),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(" "),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(" parentSchema"),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(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" cxt\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),t._v("min"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" max"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" schema\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" eq"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" Code "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" parentSchema"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("exclusiveRange "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),t._v(" _"),a("span",{pre:!0,attrs:{class:"token template-string"}},[a("span",{pre:!0,attrs:{class:"token template-punctuation string"}},[t._v("`")]),a("span",{pre:!0,attrs:{class:"token string"}},[t._v("=")]),a("span",{pre:!0,attrs:{class:"token template-punctuation string"}},[t._v("`")])]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" nil\n cxt"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("fail")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("_"),a("span",{pre:!0,attrs:{class:"token template-string"}},[a("span",{pre:!0,attrs:{class:"token template-punctuation string"}},[t._v("`")]),a("span",{pre:!0,attrs:{class:"token interpolation"}},[a("span",{pre:!0,attrs:{class:"token interpolation-punctuation punctuation"}},[t._v("${")]),t._v("data"),a("span",{pre:!0,attrs:{class:"token interpolation-punctuation punctuation"}},[t._v("}")])]),a("span",{pre:!0,attrs:{class:"token string"}},[t._v(" <")]),a("span",{pre:!0,attrs:{class:"token interpolation"}},[a("span",{pre:!0,attrs:{class:"token interpolation-punctuation punctuation"}},[t._v("${")]),t._v("eq"),a("span",{pre:!0,attrs:{class:"token interpolation-punctuation punctuation"}},[t._v("}")])]),a("span",{pre:!0,attrs:{class:"token string"}},[t._v(" ")]),a("span",{pre:!0,attrs:{class:"token interpolation"}},[a("span",{pre:!0,attrs:{class:"token interpolation-punctuation punctuation"}},[t._v("${")]),t._v("min"),a("span",{pre:!0,attrs:{class:"token interpolation-punctuation punctuation"}},[t._v("}")])]),a("span",{pre:!0,attrs:{class:"token string"}},[t._v(" || ")]),a("span",{pre:!0,attrs:{class:"token interpolation"}},[a("span",{pre:!0,attrs:{class:"token interpolation-punctuation punctuation"}},[t._v("${")]),t._v("data"),a("span",{pre:!0,attrs:{class:"token interpolation-punctuation punctuation"}},[t._v("}")])]),a("span",{pre:!0,attrs:{class:"token string"}},[t._v(" >")]),a("span",{pre:!0,attrs:{class:"token interpolation"}},[a("span",{pre:!0,attrs:{class:"token interpolation-punctuation punctuation"}},[t._v("${")]),t._v("eq"),a("span",{pre:!0,attrs:{class:"token interpolation-punctuation punctuation"}},[t._v("}")])]),a("span",{pre:!0,attrs:{class:"token string"}},[t._v(" ")]),a("span",{pre:!0,attrs:{class:"token interpolation"}},[a("span",{pre:!0,attrs:{class:"token interpolation-punctuation punctuation"}},[t._v("${")]),t._v("max"),a("span",{pre:!0,attrs:{class:"token interpolation-punctuation punctuation"}},[t._v("}")])]),a("span",{pre:!0,attrs:{class:"token template-punctuation string"}},[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 metaSchema"),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 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 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("{")]),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(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),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 minItems"),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 additionalItems"),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 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("p",[t._v("You can review pre-defined Ajv keywords in "),a("a",{attrs:{href:"https://github.com/ajv-validator/ajv/blob/master/lib/validation",target:"_blank",rel:"noopener noreferrer"}},[t._v("validation"),a("OutboundLink")],1),t._v(" folder for more advanced examples - it is much easier to define code generation keywords than it was in the previous version of Ajv.")]),t._v(" "),a("p",[t._v("See "),a("a",{attrs:{href:"https://github.com/ajv-validator/ajv/blob/master/lib/compile/validate/index.ts",target:"_blank",rel:"noopener noreferrer"}},[t._v("KeywordCxt"),a("OutboundLink")],1),t._v(" and "),a("a",{attrs:{href:"https://github.com/ajv-validator/ajv/blob/master/lib/compile/index.ts",target:"_blank",rel:"noopener noreferrer"}},[t._v("SchemaCxt"),a("OutboundLink")],1),t._v(" type definitions for more information about properties you can use in your keywords.")]),t._v(" "),a("h3",{attrs:{id:"define-keyword-with-validate-function"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#define-keyword-with-validate-function"}},[t._v("#")]),t._v(' Define keyword with "validate" function')]),t._v(" "),a("p",[t._v("Usual keyword definition for validation keywords:")]),t._v(" "),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("interface")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("FuncKeywordDefinition")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("extends")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("_KeywordDef")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n validate"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" SchemaValidateFunction "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("|")]),t._v(" DataValidateFunction "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// DataValidateFunction requires `schema: false` option")]),t._v("\n schema"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("boolean")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// schema: false makes validate not to expect schema (DataValidateFunction)")]),t._v("\n modifying"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("boolean")]),t._v("\n async"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("boolean")]),t._v("\n valid"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("boolean")]),t._v("\n errors"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("boolean")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("|")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"full"')]),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("interface")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("SchemaValidateFunction")]),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("schema"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("any")]),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 builtin"}},[t._v("any")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" parentSchema"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" AnySchemaObject"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" dataCxt"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" DataValidationCxt"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("|")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("boolean")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("|")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("Promise")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<")]),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("any")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(">")]),t._v("\n errors"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" Partial"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<")]),t._v("ErrorObject"),a("span",{pre:!0,attrs:{class:"token operator"}},[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\n"),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("interface")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("DataValidateFunction")]),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 keyword"}},[t._v("this")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" Ajv "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("|")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("any")]),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 builtin"}},[t._v("any")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" dataCxt"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" DataValidationCxt"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("boolean")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("|")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("Promise")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<")]),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("any")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(">")]),t._v("\n errors"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" Partial"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<")]),t._v("ErrorObject"),a("span",{pre:!0,attrs:{class:"token operator"}},[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("p",[t._v("The function should return validation result as boolean. It can return an array of validation errors via "),a("code",[t._v(".errors")]),t._v(" property of itself (otherwise a standard error will be used).")]),t._v(" "),a("p",[a("code",[t._v("validate")]),t._v(" keywords are suitable for:")]),t._v(" "),a("ul",[a("li",[t._v("testing your keywords before converting them to compiled/code keywords")]),t._v(" "),a("li",[t._v("defining keywords that do not depend on the schema value (e.g., when the value is always "),a("code",[t._v("true")]),t._v("). In this case you can add option "),a("code",[t._v("schema: false")]),t._v(" to the keyword definition and the schemas won't be passed to the validation function, it will only receive the same parameters as compiled validation function.")]),t._v(" "),a("li",[t._v("defining keywords where the schema is a value used in some expression.")]),t._v(" "),a("li",[t._v("defining keywords that support "),a("RouterLink",{attrs:{to:"/guide/combining-schemas.html#data-reference"}},[t._v("$data reference")]),t._v(" - in this case "),a("code",[t._v("validate")]),t._v(" or "),a("code",[t._v("code")]),t._v(" function is required, either as the only option or in addition to "),a("code",[t._v("compile")]),t._v(" or "),a("code",[t._v("macro")]),t._v(".")],1)]),t._v(" "),a("p",[t._v("Example: "),a("code",[t._v("constant")]),t._v(" keyword (a synonym for draft-06 keyword "),a("code",[t._v("const")]),t._v(", it is equivalent to "),a("code",[t._v("enum")]),t._v(" keyword with one item):")]),t._v(" "),a("div",{staticClass:"language-javascript extra-class"},[a("pre",{pre:!0,attrs:{class:"language-javascript"}},[a("code",[t._v("ajv"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("addKeyword")]),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("keyword")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"constant"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token function-variable function"}},[t._v("validate")]),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 parameter"}},[t._v("schema"),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(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=>")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("typeof")]),t._v(" schema "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("==")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"object"')]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("&&")]),t._v(" schema "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("!==")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("null")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("deepEqual")]),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(" data"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" schema "),a("span",{pre:!0,attrs:{class:"token operator"}},[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 literal-property property"}},[t._v("errors")]),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 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(" 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("constant")]),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 punctuation"}},[t._v("}")]),t._v("\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("\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("validate")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("2")]),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("// true")]),t._v("\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("validate")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[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 comment"}},[t._v("// false")]),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("constant")]),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 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 punctuation"}},[t._v("}")]),t._v("\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("\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("validate")]),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("foo")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),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(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// true")]),t._v("\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("validate")]),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("foo")]),a("span",{pre:!0,attrs:{class:"token operator"}},[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("}")]),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("// false")]),t._v("\n")])])]),a("p",[a("code",[t._v("const")]),t._v(" keyword is already available in Ajv.")]),t._v(" "),a("div",{staticClass:"custom-block tip"},[a("p",{staticClass:"custom-block-title"},[t._v("Keywords that do not define errors")]),t._v(" "),a("p",[t._v("If the keyword does not define errors (see "),a("RouterLink",{attrs:{to:"/api.html#reporting-errors"}},[t._v("Reporting errors")]),t._v(") pass "),a("code",[t._v("errors: false")]),t._v(" in its definition; it will make generated code more efficient.")],1)]),t._v(" "),a("p",[t._v("To add asynchronous keyword pass "),a("code",[t._v("async: true")]),t._v(" in its definition.")]),t._v(" "),a("h3",{attrs:{id:"define-keyword-with-compile-function"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#define-keyword-with-compile-function"}},[t._v("#")]),t._v(' Define keyword with "compile" function')]),t._v(" "),a("p",[t._v('The keyword is similar to "validate", with the difference that "compile" property has function that will be called during schema compilation and should return validation function:')]),t._v(" "),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("interface")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("FuncKeywordDefinition")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("extends")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("_KeywordDef")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n compile"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("schema"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("any")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" parentSchema"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" AnySchemaObject"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" it"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" SchemaObjCxt"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=>")]),t._v(" DataValidateFunction\n schema"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("boolean")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// schema: false makes validate not to expect schema (DataValidateFunction)")]),t._v("\n modifying"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("boolean")]),t._v("\n async"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("boolean")]),t._v("\n valid"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("boolean")]),t._v("\n errors"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("boolean")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("|")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"full"')]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])]),a("p",[t._v("In some cases it is the best approach to define keywords, but it has the performance cost of an extra function call during validation. If keyword logic can be expressed via some other JSON Schema then "),a("code",[t._v("macro")]),t._v(" keyword definition is more efficient (see below).")]),t._v(" "),a("p",[t._v("Example. "),a("code",[t._v("range")]),t._v(" and "),a("code",[t._v("exclusiveRange")]),t._v(" keywords using compiled schema:")]),t._v(" "),a("div",{staticClass:"language-javascript extra-class"},[a("pre",{pre:!0,attrs:{class:"language-javascript"}},[a("code",[t._v("ajv"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("addKeyword")]),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("keyword")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"range"')]),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 function"}},[t._v("compile")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token parameter"}},[a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),t._v("min"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" max"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" parentSchema")]),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("return")]),t._v(" parentSchema"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("exclusiveRange "),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 operator"}},[t._v("?")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token parameter"}},[t._v("data")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=>")]),t._v(" data "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(">")]),t._v(" min "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("&&")]),t._v(" data "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token function-variable function"}},[t._v("max")]),t._v("\n "),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 parameter"}},[t._v("data")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=>")]),t._v(" data "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(">=")]),t._v(" min "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("&&")]),t._v(" data "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<=")]),t._v(" max\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("errors")]),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("metaSchema")]),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 comment"}},[t._v("// schema to validate keyword value")]),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('"number"')]),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('"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("minItems")]),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("additionalItems")]),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 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\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("range")]),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 number"}},[t._v("2")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("4")]),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("exclusiveRange")]),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("\n"),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(" 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("\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("validate")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("2.01")]),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("// true")]),t._v("\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("validate")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("3.99")]),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("// true")]),t._v("\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("validate")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("2")]),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("// false")]),t._v("\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("validate")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("4")]),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("// false")]),t._v("\n")])])]),a("p",[t._v("See note on errors and asynchronous keywords in the previous section.")]),t._v(" "),a("h3",{attrs:{id:"define-keyword-with-macro-function"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#define-keyword-with-macro-function"}},[t._v("#")]),t._v(' Define keyword with "macro" function')]),t._v(" "),a("p",[t._v("Keyword definition:")]),t._v(" "),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("interface")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("MacroKeywordDefinition")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("extends")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("FuncKeywordDefinition")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token function-variable function"}},[t._v("macro")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("schema"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("any")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" parentSchema"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" AnySchemaObject"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" it"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" SchemaCxt"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=>")]),t._v(" AnySchema\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])]),a("p",[t._v('"Macro" function is called during schema compilation. It is passed schema, parent schema and '),a("a",{attrs:{href:"#schema-compilation-context"}},[t._v("schema compilation context")]),t._v(" and it should return another schema that will be applied to the data in addition to the original schema.")]),t._v(" "),a("p",[t._v("It is an efficient approach (in cases when the keyword logic can be expressed with another JSON Schema), because it is usually easy to implement and there is no extra function call during validation.")]),t._v(" "),a("p",[t._v("In addition to the errors from the expanded schema macro keyword will add its own error in case validation fails.")]),t._v(" "),a("p",[t._v("Example. "),a("code",[t._v("range")]),t._v(" and "),a("code",[t._v("exclusiveRange")]),t._v(" keywords from the previous example defined with macro:")]),t._v(" "),a("div",{staticClass:"language-javascript extra-class"},[a("pre",{pre:!0,attrs:{class:"language-javascript"}},[a("code",[t._v("ajv"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("addKeyword")]),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("keyword")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"range"')]),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 function-variable function"}},[t._v("macro")]),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 parameter"}},[a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),t._v("minimum"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" maximum"),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 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("{")]),t._v("minimum"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" maximum"),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("// schema with keywords minimum and maximum")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// metaSchema: the same as in the example above")]),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("p",[t._v("Macro keywords can be recursive - i.e. return schemas containing the same keyword. See the example of defining a recursive macro keyword "),a("code",[t._v("deepProperties")]),t._v(" in the "),a("a",{attrs:{href:"https://github.com/ajv-validator/ajv/blob/master/spec/keyword.spec.ts#L316",target:"_blank",rel:"noopener noreferrer"}},[t._v("test"),a("OutboundLink")],1),t._v(".")]),t._v(" "),a("h2",{attrs:{id:"schema-compilation-context"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#schema-compilation-context"}},[t._v("#")]),t._v(" Schema compilation context")]),t._v(" "),a("p",[t._v("Schema compilation context "),a("a",{attrs:{href:"https://github.com/ajv-validator/ajv/blob/master/lib/compile/index.ts",target:"_blank",rel:"noopener noreferrer"}},[t._v("SchemaCxt"),a("OutboundLink")],1),t._v(" is available in property "),a("code",[t._v("it")]),t._v(" of "),a("a",{attrs:{href:"https://github.com/ajv-validator/ajv/blob/master/lib/compile/validate/index.ts",target:"_blank",rel:"noopener noreferrer"}},[t._v("KeywordCxt"),a("OutboundLink")],1),t._v(" (and it is also the 3rd parameter of "),a("code",[t._v("compile")]),t._v(" and "),a("code",[t._v("macro")]),t._v(" keyword functions). See types in the source code on the properties you can use in this object.")]),t._v(" "),a("h2",{attrs:{id:"validation-time-variables"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#validation-time-variables"}},[t._v("#")]),t._v(" Validation time variables")]),t._v(" "),a("p",[t._v("All function scoped variables available during validation are defined in "),a("a",{attrs:{href:"https://github.com/ajv-validator/ajv/blob/master/lib/compile/names.ts",target:"_blank",rel:"noopener noreferrer"}},[t._v("names"),a("OutboundLink")],1),t._v(".")]),t._v(" "),a("h2",{attrs:{id:"reporting-errors"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#reporting-errors"}},[t._v("#")]),t._v(" Reporting errors")]),t._v(" "),a("p",[t._v("All keywords can define error messages with "),a("code",[t._v("KeywordErrorDefinition")]),t._v(" object passed as "),a("code",[t._v("error")]),t._v(" property of keyword definition:")]),t._v(" "),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("interface")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("KeywordErrorDefinition")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n message"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("string")]),t._v(" "),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("(")]),t._v("cxt"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" KeywordErrorCxt"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=>")]),t._v(" Code"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n params"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("cxt"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" KeywordErrorCxt"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=>")]),t._v(" Code\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])]),a("p",[a("code",[t._v("code")]),t._v(" keywords can pass parameters to these functions via "),a("code",[t._v("cxt.setParams")]),t._v(" (see implementations of pre-defined keywords), other keywords can only set a string message this way.")]),t._v(" "),a("p",[t._v("Another approach for reporting errors can be used for "),a("code",[t._v("validate")]),t._v(" and "),a("code",[t._v("compile")]),t._v(" keyword - they can define errors by assigning them to "),a("code",[t._v(".errors")]),t._v(" property of the validation function. Asynchronous keywords can return promise that rejects with "),a("code",[t._v("new Ajv.ValidationError(errors)")]),t._v(", where "),a("code",[t._v("errors")]),t._v(" is an array of validation errors (if you don't want to create errors in asynchronous keyword, its validation function can return the promise that resolves with "),a("code",[t._v("false")]),t._v(").")]),t._v(" "),a("p",[t._v("Each error object in "),a("code",[t._v("errors")]),t._v(" array should at least have properties "),a("code",[t._v("keyword")]),t._v(", "),a("code",[t._v("message")]),t._v(" and "),a("code",[t._v("params")]),t._v(", other properties will be added.")]),t._v(" "),a("p",[t._v("If keyword doesn't define or return errors, the default error will be created in case the keyword fails validation.")])])}),[],!1,null,null,null);a.default=e.exports}}]); \ No newline at end of file diff --git a/assets/js/65.ca25ca57.js b/assets/js/65.ca25ca57.js new file mode 100644 index 000000000..733c34aec --- /dev/null +++ b/assets/js/65.ca25ca57.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[65],{496:function(t,e,o){"use strict";o.r(e);var n=o(14),i=Object(n.a)({},(function(){var t=this,e=t._self._c;return e("ContentSlotsDistributor",{attrs:{"slot-key":t.$parent.slotKey}},[e("p",[t._v("The MIT License (MIT)")]),t._v(" "),e("p",[t._v("Copyright (c) 2015-2021 Evgeny Poberezkin")]),t._v(" "),e("p",[t._v('Permission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the "Software"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:')]),t._v(" "),e("p",[t._v("The above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.")]),t._v(" "),e("p",[t._v('THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.')])])}),[],!1,null,null,null);e.default=i.exports}}]); \ No newline at end of file diff --git a/assets/js/66.5f3b80bf.js b/assets/js/66.5f3b80bf.js new file mode 100644 index 000000000..84cd41bf0 --- /dev/null +++ b/assets/js/66.5f3b80bf.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[66],{495: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/67.dc019e94.js b/assets/js/67.dc019e94.js new file mode 100644 index 000000000..fca80720f --- /dev/null +++ b/assets/js/67.dc019e94.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[67],{498:function(e,t,a){"use strict";a.r(t);var s=a(14),r=Object(s.a)({},(function(){var e=this,t=e._self._c;return t("ContentSlotsDistributor",{attrs:{"slot-key":e.$parent.slotKey}},[t("p",[e._v("Ajv version 7 has these new features:")]),e._v(" "),t("ul",[t("li",[e._v("support of JSON Schema draft-2019-09 features: "),t("a",{attrs:{href:"/json-schema.html#keywords-for-objects"}},[e._v("unevaluatedProperties")]),e._v(" and "),t("a",{attrs:{href:"/json-schema.html#unevaluateditems"}},[e._v("unevaluatedItems")]),e._v(", "),t("a",{attrs:{href:"/guide/combining-schemas.html#extending-recursive-schemas"}},[e._v("dynamic recursive references")]),e._v(" and other "),t("a",{attrs:{href:"/json-schema.html#json-schema-draft-2019-09"}},[e._v("additional keywords")]),e._v(".")]),e._v(" "),t("li",[e._v("to reduce the mistakes in JSON schemas and unexpected validation results, "),t("a",{attrs:{href:"/strict-mode.html"}},[e._v("strict mode")]),e._v(" is added - it prohibits ignored or ambiguous JSON Schema elements.")]),e._v(" "),t("li",[e._v("to make code injection from untrusted schemas impossible, "),t("a",{attrs:{href:"/codegen.html"}},[e._v("code generation")]),e._v(" is fully re-written to be safe and to allow code optimization (compiled schema code size is reduced by more than 10%).\n")]),e._v(" "),t("li",[e._v("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. "),t("a",{attrs:{href:"https://github.com/ajv-validator/ajv-keywords",target:"_blank",rel:"noopener noreferrer"}},[e._v("ajv-keywords"),t("OutboundLink")],1),e._v(" package was updated to use the new API (in "),t("a",{attrs:{href:"https://github.com/ajv-validator/ajv-keywords/releases/tag/v4.0.0",target:"_blank",rel:"noopener noreferrer"}},[e._v("v4.0.0"),t("OutboundLink")],1),e._v(")")]),e._v(" "),t("li",[e._v("schemas are compiled to ES6 code (ES5 code generation is also supported with an option).")]),e._v(" "),t("li",[e._v("to improve reliability and maintainability the code is migrated to TypeScript.")])]),e._v(" "),t("p",[t("strong",[e._v("Please note")]),e._v(":")]),e._v(" "),t("ul",[t("li",[e._v('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 '),t("a",{attrs:{href:"https://github.com/ajv-validator/ajv/tree/v6",target:"_blank",rel:"noopener noreferrer"}},[e._v("Ajv v6"),t("OutboundLink")],1),e._v(" that will be supported until 02/28/2021).")]),e._v(" "),t("li",[e._v("all formats are separated to ajv-formats package - they have to be explicitly added if you use them.")])]),e._v(" "),t("p",[e._v("See "),t("a",{attrs:{href:"https://github.com/ajv-validator/ajv/releases/tag/v7.0.0",target:"_blank",rel:"noopener noreferrer"}},[e._v("release notes"),t("OutboundLink")],1),e._v(" for the details.")]),e._v(" "),t("p",[e._v("To install the new version:")]),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\n")])])]),t("p",[e._v("See "),t("RouterLink",{attrs:{to:"/guide/getting-started.html"}},[e._v("Getting started")]),e._v(" for code examples.")],1)])}),[],!1,null,null,null);t.default=r.exports}}]); \ No newline at end of file diff --git a/assets/js/68.7a055b60.js b/assets/js/68.7a055b60.js new file mode 100644 index 000000000..6dc0a2e3d --- /dev/null +++ b/assets/js/68.7a055b60.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[68],{497:function(t,e,i){"use strict";i.r(e);var a=i(14),n=Object(a.a)({},(function(){var t=this,e=t._self._c;return e("ContentSlotsDistributor",{attrs:{"slot-key":t.$parent.slotKey}},[e("p",[t._v("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 "),e("a",{attrs:{href:"https://datatracker.ietf.org/doc/rfc8927/",target:"_blank",rel:"noopener noreferrer"}},[t._v("RFC8927"),e("OutboundLink")],1),t._v(".")]),t._v(" "),e("p",[t._v("See "),e("a",{attrs:{href:"/guide/schema-language.html"}},[t._v("Choosing schema language")]),t._v(" for a detailed comparison between JSON Schema and JSON Type definition and "),e("a",{attrs:{href:"/json-type-definition.html"}},[t._v("informal specification")]),t._v(".")]),t._v(" "),e("p",[t._v("In addition to validation, Ajv also supports:")]),t._v(" "),e("ul",[e("li",[t._v("generation of "),e("RouterLink",{attrs:{to:"/api.html#jtd-serialize"}},[t._v("serializers")]),t._v(" and "),e("RouterLink",{attrs:{to:"/api.html#jtd-parse"}},[t._v("parsers")]),t._v(" from JTD schemas/ This is more efficient than native JSON serialization/parsing - you can combine JSON string parsing and validation in one function call.")],1),t._v(" "),e("li",[t._v("utility type "),e("RouterLink",{attrs:{to:"/guide/typescript.html#utility-types-for-schemas"}},[t._v("JTDSchemaType")]),t._v(" to convert your data type to the type of JTD schema and "),e("RouterLink",{attrs:{to:"/guide/typescript.html#utility-type-for-jtd-data-type"}},[t._v("JTDDataType")]),t._v(" to convert the type of schema to the type of data.")],1)])])}),[],!1,null,null,null);e.default=n.exports}}]); \ No newline at end of file diff --git a/assets/js/69.65b3ac15.js b/assets/js/69.65b3ac15.js new file mode 100644 index 000000000..4e9fac2ac --- /dev/null +++ b/assets/js/69.65b3ac15.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[69],{499:function(e,t,s){"use strict";s.r(t);var r=s(14),a=Object(r.a)({},(function(){var e=this,t=e._self._c;return t("ContentSlotsDistributor",{attrs:{"slot-key":e.$parent.slotKey}},[t("p",[e._v("Ajv version 8 has these new features:")]),e._v(" "),t("ul",[t("li",[e._v("support of JSON Schema draft-2020-12: "),t("a",{attrs:{href:"/json-schema.html#prefixitems"}},[e._v("prefixItems")]),e._v(" keyword and changed semantics of "),t("a",{attrs:{href:"/json-schema.html#items-in-draft-2020-12"}},[e._v("items")]),e._v(" keyword, "),t("a",{attrs:{href:"/guide/combining-schemas.html#extending-recursive-schemas"}},[e._v("dynamic recursive references")]),e._v(".")]),e._v(" "),t("li",[e._v("OpenAPI "),t("a",{attrs:{href:"/json-schema.html#discriminator"}},[e._v("discriminator")]),e._v(" keyword.")]),e._v(" "),t("li",[e._v("improved JSON Type Definition support:\n"),e._v(" "),t("ul",[t("li",[e._v("errors consistent with JTD specification.")]),e._v(" "),t("li",[e._v("error objects with additional properties to simplify error handling")]),e._v(" "),t("li",[e._v("internationalized error messages with "),t("a",{attrs:{href:"/packages/ajv-i18n"}},[e._v("ajv-i18n")])])])]),e._v(" "),t("li",[e._v("TypeScript: support type unions in "),t("RouterLink",{attrs:{to:"/guide/typescript.html#type-safe-unions"}},[e._v("JSONSchemaType")])],1)]),e._v(" "),t("p",[e._v("See "),t("a",{attrs:{href:"https://github.com/ajv-validator/ajv/releases/tag/v8.0.0",target:"_blank",rel:"noopener noreferrer"}},[e._v("release notes"),t("OutboundLink")],1),e._v(" for the details.")]),e._v(" "),t("p",[e._v("To install the new version:")]),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\n")])])]),t("p",[e._v("See "),t("RouterLink",{attrs:{to:"/guide/getting-started.html"}},[e._v("Getting started")]),e._v(" for code examples.")],1)])}),[],!1,null,null,null);t.default=a.exports}}]); \ No newline at end of file diff --git a/assets/js/7.e43ed0ea.js b/assets/js/7.e43ed0ea.js new file mode 100644 index 000000000..f0fe83c35 --- /dev/null +++ b/assets/js/7.e43ed0ea.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[7],{457:function(t,e,s){"use strict";s.r(e);const o=["There's nothing here.","How did we get here?","That's a Four-Oh-Four.","Looks like we've got some broken links."];var n={methods:{getMsg:()=>o[Math.floor(Math.random()*o.length)]}},h=s(14),i=Object(h.a)(n,(function(){var t=this._self._c;return t("div",{staticClass:"theme-container"},[t("div",{staticClass:"theme-default-content"},[t("h1",[this._v("404")]),this._v(" "),t("blockquote",[this._v(this._s(this.getMsg()))]),this._v(" "),t("RouterLink",{attrs:{to:"/"}},[this._v("\n Take me home.\n ")])],1)])}),[],!1,null,null,null);e.default=i.exports}}]); \ No newline at end of file diff --git a/assets/js/70.baeb253d.js b/assets/js/70.baeb253d.js new file mode 100644 index 000000000..3197968c0 --- /dev/null +++ b/assets/js/70.baeb253d.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[70],{500:function(e,t,r){"use strict";r.r(t);var n=r(14),o=Object(n.a)({},(function(){var e=this,t=e._self._c;return t("ContentSlotsDistributor",{attrs:{"slot-key":e.$parent.slotKey}},[t("p",[e._v("We will talk about:")]),e._v(" "),t("ul",[t("li",[e._v("new features of Ajv version 8.")]),e._v(" "),t("li",[e._v("the improvements sponsored by Mozilla's MOSS grant.")]),e._v(" "),t("li",[e._v("how Ajv is used in JavaScript applications.")])]),e._v(" "),t("p",[e._v("Speakers:")]),e._v(" "),t("ul",[t("li",[t("a",{attrs:{href:"https://github.com/epoberezkin",target:"_blank",rel:"noopener noreferrer"}},[e._v("Evgeny Poberezkin"),t("OutboundLink")],1),e._v(", the creator of Ajv.")]),e._v(" "),t("li",[t("a",{attrs:{href:"https://github.com/mehan",target:"_blank",rel:"noopener noreferrer"}},[e._v("Mehan Jayasuriya"),t("OutboundLink")],1),e._v(", Program Officer at Mozilla Foundation, leading the "),t("a",{attrs:{href:"https://www.mozilla.org/en-US/moss/",target:"_blank",rel:"noopener noreferrer"}},[e._v("MOSS"),t("OutboundLink")],1),e._v(" and other programs investing in the open source and community ecosystems.")]),e._v(" "),t("li",[t("a",{attrs:{href:"https://github.com/mcollina",target:"_blank",rel:"noopener noreferrer"}},[e._v("Matteo Collina"),t("OutboundLink")],1),e._v(", Technical Director at NearForm and Node.js Technical Steering Committee member, creator of Fastify web framework.")]),e._v(" "),t("li",[t("a",{attrs:{href:"https://github.com/kinlane",target:"_blank",rel:"noopener noreferrer"}},[e._v("Kin Lane"),t("OutboundLink")],1),e._v(", Chief Evangelist at Postman. Studying the tech, business & politics of APIs since 2010. Presidential Innovation Fellow during the Obama administration.")]),e._v(" "),t("li",[t("a",{attrs:{href:"https://github.com/ucarion",target:"_blank",rel:"noopener noreferrer"}},[e._v("Ulysse Carion"),t("OutboundLink")],1),e._v(", the creator of JSON Type Definition specification.")])]),e._v(" "),t("p",[t("a",{attrs:{href:"https://github.com/gajus",target:"_blank",rel:"noopener noreferrer"}},[e._v("Gajus Kuizinas"),t("OutboundLink")],1),e._v(" will host the event.")]),e._v(" "),t("p",[e._v("Please "),t("a",{attrs:{href:"https://us02web.zoom.us/webinar/register/4216192074976/WN_erJ_t4ICTHOnGC1SOybNnw",target:"_blank",rel:"noopener noreferrer"}},[e._v("register here"),t("OutboundLink")],1),e._v(".")])])}),[],!1,null,null,null);t.default=o.exports}}]); \ No newline at end of file diff --git a/assets/js/71.eba39e57.js b/assets/js/71.eba39e57.js new file mode 100644 index 000000000..2cc000106 --- /dev/null +++ b/assets/js/71.eba39e57.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[71],{501:function(t,e,o){"use strict";o.r(e);var n=o(14),s=Object(n.a)({},(function(){var t=this._self._c;return t("ContentSlotsDistributor",{attrs:{"slot-key":this.$parent.slotKey}},[t("p",[this._v("Huge thanks to everybody who joined, and to the speakers! The video of the event is "),t("a",{attrs:{href:"https://www.youtube.com/watch?v=KxSKqXEBB7A",target:"_blank",rel:"noopener noreferrer"}},[this._v("available on YouTube"),t("OutboundLink")],1),this._v(".")])])}),[],!1,null,null,null);e.default=s.exports}}]); \ No newline at end of file diff --git a/assets/js/72.46adb510.js b/assets/js/72.46adb510.js new file mode 100644 index 000000000..7d72b8033 --- /dev/null +++ b/assets/js/72.46adb510.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[72],{502:function(t,o,n){"use strict";n.r(o);var e=n(14),s=Object(e.a)({},(function(){var t=this._self._c;return t("ContentSlotsDistributor",{attrs:{"slot-key":this.$parent.slotKey}},[t("p",[this._v("Ajv was awarded a sponsorship from "),t("a",{attrs:{href:"https://github.com/microsoft/foss-fund/blob/main/README.md#2021",target:"_blank",rel:"noopener noreferrer"}},[this._v("Microsoft FOSS fund"),t("OutboundLink")],1),this._v(" - huge thanks to Microsoft and the engineers who voted to support Ajv development.")]),this._v(" "),t("p",[this._v("This award will contribute to a long term maintenance of Ajv.")])])}),[],!1,null,null,null);o.default=s.exports}}]); \ No newline at end of file diff --git a/assets/js/73.c64ada47.js b/assets/js/73.c64ada47.js new file mode 100644 index 000000000..cd4de8616 --- /dev/null +++ b/assets/js/73.c64ada47.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[73],{504:function(t,s,e){"use strict";e.r(s);var n=e(14),a=Object(n.a)({},(function(){var t=this._self._c;return t("ContentSlotsDistributor",{attrs:{"slot-key":this.$parent.slotKey}},[t("h1",{attrs:{id:"ajv-news"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#ajv-news"}},[this._v("#")]),this._v(" Ajv News")]),this._v(" "),t("NewsIndex")],1)}),[],!1,null,null,null);s.default=a.exports}}]); \ No newline at end of file diff --git a/assets/js/74.975b10f9.js b/assets/js/74.975b10f9.js new file mode 100644 index 000000000..3ea6f90c4 --- /dev/null +++ b/assets/js/74.975b10f9.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[74],{503:function(t,e,a){"use strict";a.r(e);var s=a(14),r=Object(s.a)({},(function(){var t=this,e=t._self._c;return e("ContentSlotsDistributor",{attrs:{"slot-key":t.$parent.slotKey}},[e("h1",{attrs:{id:"ajv-options"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#ajv-options"}},[t._v("#")]),t._v(" Ajv options")]),t._v(" "),e("p"),e("div",{staticClass:"table-of-contents"},[e("ul",[e("li",[e("a",{attrs:{href:"#usage"}},[t._v("Usage")])]),e("li",[e("a",{attrs:{href:"#option-defaults"}},[t._v("Option defaults")])]),e("li",[e("a",{attrs:{href:"#strict-mode-options"}},[t._v("Strict mode options "),e("Badge",{attrs:{text:"v7"}})],1),e("ul",[e("li",[e("a",{attrs:{href:"#strict"}},[t._v("strict")])]),e("li",[e("a",{attrs:{href:"#strictschema"}},[t._v("strictSchema")])]),e("li",[e("a",{attrs:{href:"#strictnumbers"}},[t._v("strictNumbers")])]),e("li",[e("a",{attrs:{href:"#stricttypes"}},[t._v("strictTypes")])]),e("li",[e("a",{attrs:{href:"#stricttuples"}},[t._v("strictTuples")])]),e("li",[e("a",{attrs:{href:"#strictrequired"}},[t._v("strictRequired")])]),e("li",[e("a",{attrs:{href:"#allowuniontypes"}},[t._v("allowUnionTypes")])]),e("li",[e("a",{attrs:{href:"#allowmatchingproperties"}},[t._v("allowMatchingProperties")])]),e("li",[e("a",{attrs:{href:"#validateformats"}},[t._v("validateFormats")])])])]),e("li",[e("a",{attrs:{href:"#validation-and-reporting-options"}},[t._v("Validation and reporting options")]),e("ul",[e("li",[e("a",{attrs:{href:"#data"}},[t._v("$data")])]),e("li",[e("a",{attrs:{href:"#allerrors"}},[t._v("allErrors")])]),e("li",[e("a",{attrs:{href:"#verbose"}},[t._v("verbose")])]),e("li",[e("a",{attrs:{href:"#discriminator"}},[t._v("discriminator")])]),e("li",[e("a",{attrs:{href:"#unicoderegexp"}},[t._v("unicodeRegExp")])]),e("li",[e("a",{attrs:{href:"#timestamp"}},[t._v("timestamp "),e("Badge",{attrs:{text:"JTD only"}})],1)]),e("li",[e("a",{attrs:{href:"#parsedate"}},[t._v("parseDate "),e("Badge",{attrs:{text:"JTD only"}})],1)]),e("li",[e("a",{attrs:{href:"#allowdate"}},[t._v("allowDate "),e("Badge",{attrs:{text:"JTD only"}})],1)]),e("li",[e("a",{attrs:{href:"#int32range"}},[t._v("int32range "),e("Badge",{attrs:{text:"JTD only"}})],1)]),e("li",[e("a",{attrs:{href:"#comment"}},[t._v("$comment")])]),e("li",[e("a",{attrs:{href:"#formats"}},[t._v("formats")])]),e("li",[e("a",{attrs:{href:"#keywords"}},[t._v("keywords")])]),e("li",[e("a",{attrs:{href:"#schemas"}},[t._v("schemas")])]),e("li",[e("a",{attrs:{href:"#logger"}},[t._v("logger")])]),e("li",[e("a",{attrs:{href:"#loadschema"}},[t._v("loadSchema")])])])]),e("li",[e("a",{attrs:{href:"#options-to-modify-validated-data"}},[t._v("Options to modify validated data")]),e("ul",[e("li",[e("a",{attrs:{href:"#removeadditional"}},[t._v("removeAdditional")])]),e("li",[e("a",{attrs:{href:"#usedefaults"}},[t._v("useDefaults")])]),e("li",[e("a",{attrs:{href:"#coercetypes"}},[t._v("coerceTypes")])])])]),e("li",[e("a",{attrs:{href:"#advanced-options"}},[t._v("Advanced options")]),e("ul",[e("li",[e("a",{attrs:{href:"#meta"}},[t._v("meta")])]),e("li",[e("a",{attrs:{href:"#validateschema"}},[t._v("validateSchema")])]),e("li",[e("a",{attrs:{href:"#addusedschema"}},[t._v("addUsedSchema")])]),e("li",[e("a",{attrs:{href:"#inlinerefs"}},[t._v("inlineRefs")])]),e("li",[e("a",{attrs:{href:"#passcontext"}},[t._v("passContext")])]),e("li",[e("a",{attrs:{href:"#looprequired"}},[t._v("loopRequired")])]),e("li",[e("a",{attrs:{href:"#loopenum"}},[t._v("loopEnum "),e("Badge",{attrs:{text:"v7"}})],1)]),e("li",[e("a",{attrs:{href:"#ownproperties"}},[t._v("ownProperties")])]),e("li",[e("a",{attrs:{href:"#multipleofprecision"}},[t._v("multipleOfPrecision")])]),e("li",[e("a",{attrs:{href:"#messages"}},[t._v("messages")])]),e("li",[e("a",{attrs:{href:"#uriresolver"}},[t._v("uriResolver")])]),e("li",[e("a",{attrs:{href:"#code"}},[t._v("code "),e("Badge",{attrs:{text:"v7"}})],1)])])])])]),e("p"),t._v(" "),e("h2",{attrs:{id:"usage"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#usage"}},[t._v("#")]),t._v(" Usage")]),t._v(" "),e("p",[t._v("This page describes properties of the options object that can be passed to Ajv constructor.")]),t._v(" "),e("p",[t._v("For example, to report all validation errors (rather than failing on the first errors) you should pass "),e("code",[t._v("allErrors")]),t._v(" option to constructor:")]),t._v(" "),e("div",{staticClass:"language-javascript extra-class"},[e("pre",{pre:!0,attrs:{class:"language-javascript"}},[e("code",[e("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" ajv "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("new")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("Ajv")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),e("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("allErrors")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token boolean"}},[t._v("true")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n")])])]),e("h2",{attrs:{id:"option-defaults"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#option-defaults"}},[t._v("#")]),t._v(" Option defaults")]),t._v(" "),e("div",{staticClass:"custom-block tip"},[e("p",{staticClass:"custom-block-title"},[t._v("Do NOT pass default options")]),t._v(" "),e("p",[t._v("Passing the value below for some of the options is equivalent to not passing this option at all. There is no need to pass default option values - it is recommended to only pass option values that are different from defaults.")])]),t._v(" "),e("div",{staticClass:"language-javascript extra-class"},[e("pre",{pre:!0,attrs:{class:"language-javascript"}},[e("code",[e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// see types/index.ts for actual types")]),t._v("\n"),e("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" defaultOptions "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// strict mode options (NEW)")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("strict")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("undefined")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// *")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("strictSchema")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token boolean"}},[t._v("true")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// *")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("strictNumbers")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token boolean"}},[t._v("true")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// *")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("strictTypes")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token string"}},[t._v('"log"')]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// *")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("strictTuples")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token string"}},[t._v('"log"')]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// *")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("strictRequired")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token boolean"}},[t._v("false")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// *")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("allowUnionTypes")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token boolean"}},[t._v("false")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// *")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("allowMatchingProperties")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token boolean"}},[t._v("false")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// *")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("validateFormats")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token boolean"}},[t._v("true")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// *")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// validation and reporting options:")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("$data")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token boolean"}},[t._v("false")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// *")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("allErrors")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token boolean"}},[t._v("false")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("verbose")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token boolean"}},[t._v("false")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("discriminator")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token boolean"}},[t._v("false")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// *")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("unicodeRegExp")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token boolean"}},[t._v("true")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// *")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("timestamp")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("undefined")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// **")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("parseDate")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token boolean"}},[t._v("false")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// **")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("allowDate")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token boolean"}},[t._v("false")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// **")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("int32range")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token boolean"}},[t._v("true")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// **")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("$comment")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token boolean"}},[t._v("false")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// *")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("formats")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("keywords")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("schemas")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("logger")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("undefined")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("loadSchema")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("undefined")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// *, function(uri: string): Promise {}")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// options to modify validated data:")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("removeAdditional")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token boolean"}},[t._v("false")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("useDefaults")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token boolean"}},[t._v("false")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// *")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("coerceTypes")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token boolean"}},[t._v("false")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// *")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// advanced options:")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("meta")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token boolean"}},[t._v("true")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("validateSchema")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token boolean"}},[t._v("true")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("addUsedSchema")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token boolean"}},[t._v("true")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("inlineRefs")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token boolean"}},[t._v("true")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("passContext")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token boolean"}},[t._v("false")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("loopRequired")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token number"}},[t._v("200")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// *")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("loopEnum")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token number"}},[t._v("200")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// NEW")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("ownProperties")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token boolean"}},[t._v("false")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("multipleOfPrecision")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("undefined")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// *")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("messages")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token boolean"}},[t._v("true")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// false with JTD")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("uriResolver")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("undefined")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("code")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// NEW")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("es5")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token boolean"}},[t._v("false")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("esm")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token boolean"}},[t._v("false")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("lines")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token boolean"}},[t._v("false")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("source")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token boolean"}},[t._v("false")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("process")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("undefined")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// (code: string) => string")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("optimize")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token boolean"}},[t._v("true")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("regExp")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" RegExp\n "),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])]),e("p",[e("sup",[t._v("*")]),t._v(" only with JSON Schema")]),t._v(" "),e("p",[e("sup",[t._v("**")]),t._v(" only with JSON Type Definition")]),t._v(" "),e("h2",{attrs:{id:"strict-mode-options"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#strict-mode-options"}},[t._v("#")]),t._v(" Strict mode options "),e("Badge",{attrs:{text:"v7"}})],1),t._v(" "),e("h3",{attrs:{id:"strict"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#strict"}},[t._v("#")]),t._v(" strict")]),t._v(" "),e("p",[t._v("By default Ajv executes in strict mode, that is designed to prevent any unexpected behaviours or silently ignored mistakes in schemas (see "),e("RouterLink",{attrs:{to:"/strict-mode.html"}},[t._v("Strict Mode")]),t._v(" for more details). It does not change any validation results, but it makes some schemas invalid that would be otherwise valid according to JSON Schema specification.")],1),t._v(" "),e("p",[t._v("Option values:")]),t._v(" "),e("ul",[e("li",[e("code",[t._v("true")]),t._v(" - throw an exception when any strict mode restriction is violated.")]),t._v(" "),e("li",[e("code",[t._v('"log"')]),t._v(" - log warning when any strict mode restriction is violated.")]),t._v(" "),e("li",[e("code",[t._v("false")]),t._v(" - ignore all strict mode violations.")]),t._v(" "),e("li",[e("code",[t._v("undefined")]),t._v(" (default) - use defaults for options strictSchema, strictNumbers, strictTypes, strictTuples and strictRequired.")])]),t._v(" "),e("h3",{attrs:{id:"strictschema"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#strictschema"}},[t._v("#")]),t._v(" strictSchema")]),t._v(" "),e("p",[t._v("Prevent unknown keywords, formats etc. (see "),e("RouterLink",{attrs:{to:"/strict-mode.html#strict-schema"}},[t._v("Strict schema")]),t._v(")")],1),t._v(" "),e("p",[t._v("Option values:")]),t._v(" "),e("ul",[e("li",[e("code",[t._v("true")]),t._v(" (default) - throw an exception when any strict schema restriction is violated.")]),t._v(" "),e("li",[e("code",[t._v('"log"')]),t._v(" - log warning when any strict schema restriction is violated.")]),t._v(" "),e("li",[e("code",[t._v("false")]),t._v(" - ignore all strict schema violations.")])]),t._v(" "),e("h3",{attrs:{id:"strictnumbers"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#strictnumbers"}},[t._v("#")]),t._v(" strictNumbers")]),t._v(" "),e("p",[t._v("Whether to accept "),e("code",[t._v("NaN")]),t._v(" and "),e("code",[t._v("Infinity")]),t._v(" as number types during validation.")]),t._v(" "),e("p",[t._v("Option values:")]),t._v(" "),e("ul",[e("li",[e("code",[t._v("true")]),t._v(" (default) - fail validation if "),e("code",[t._v("NaN")]),t._v(" or "),e("code",[t._v("Infinity")]),t._v(" is passed where number is expected.")]),t._v(" "),e("li",[e("code",[t._v("false")]),t._v(" - allow "),e("code",[t._v("NaN")]),t._v(" and "),e("code",[t._v("Infinity")]),t._v(" as number.")])]),t._v(" "),e("h3",{attrs:{id:"stricttypes"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#stricttypes"}},[t._v("#")]),t._v(" strictTypes")]),t._v(" "),e("p",[t._v("See "),e("RouterLink",{attrs:{to:"/strict-mode.html#strict-types"}},[t._v("Strict types")])],1),t._v(" "),e("p",[t._v("Option values:")]),t._v(" "),e("ul",[e("li",[e("code",[t._v("true")]),t._v(" - throw an exception when any strict types restriction is violated.")]),t._v(" "),e("li",[e("code",[t._v('"log"')]),t._v(" (default) - log warning when any strict types restriction is violated.")]),t._v(" "),e("li",[e("code",[t._v("false")]),t._v(" - ignore all strict types violations.")])]),t._v(" "),e("h3",{attrs:{id:"stricttuples"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#stricttuples"}},[t._v("#")]),t._v(" strictTuples")]),t._v(" "),e("p",[t._v("See "),e("RouterLink",{attrs:{to:"/strict-mode.html#unconstrained-tuples"}},[t._v("Unconstrained tuples")])],1),t._v(" "),e("p",[t._v("Option values:")]),t._v(" "),e("ul",[e("li",[e("code",[t._v("true")]),t._v(" - throw an exception when any strict tuples restriction is violated.")]),t._v(" "),e("li",[e("code",[t._v('"log"')]),t._v(" (default) - log warning when any strict tuples restriction is violated.")]),t._v(" "),e("li",[e("code",[t._v("false")]),t._v(" - ignore all strict tuples violations.")])]),t._v(" "),e("h3",{attrs:{id:"strictrequired"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#strictrequired"}},[t._v("#")]),t._v(" strictRequired")]),t._v(" "),e("p",[t._v("See "),e("RouterLink",{attrs:{to:"/strict-mode.html#defined-required-properties"}},[t._v("Defined required properties")])],1),t._v(" "),e("p",[t._v("Option values:")]),t._v(" "),e("ul",[e("li",[e("code",[t._v("true")]),t._v(" - throw an exception when strict required restriction is violated.")]),t._v(" "),e("li",[e("code",[t._v('"log"')]),t._v(" - log warning when strict required restriction is violated.")]),t._v(" "),e("li",[e("code",[t._v("false")]),t._v(" (default) - ignore strict required violations.")])]),t._v(" "),e("h3",{attrs:{id:"allowuniontypes"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#allowuniontypes"}},[t._v("#")]),t._v(" allowUnionTypes")]),t._v(" "),e("p",[t._v('Pass true to allow using multiple non-null types in "type" keyword (one of '),e("code",[t._v("strictTypes")]),t._v(" restrictions). see "),e("RouterLink",{attrs:{to:"/strict-mode.html#strict-types"}},[t._v("Strict types")])],1),t._v(" "),e("h3",{attrs:{id:"allowmatchingproperties"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#allowmatchingproperties"}},[t._v("#")]),t._v(" allowMatchingProperties")]),t._v(" "),e("p",[t._v('Pass true to allow overlap between "properties" and "patternProperties". Does not affect other strict mode restrictions. See '),e("RouterLink",{attrs:{to:"/strict-mode.html"}},[t._v("Strict Mode")]),t._v(".")],1),t._v(" "),e("h3",{attrs:{id:"validateformats"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#validateformats"}},[t._v("#")]),t._v(" validateFormats")]),t._v(" "),e("p",[t._v("Format validation.")]),t._v(" "),e("p",[t._v("Option values:")]),t._v(" "),e("ul",[e("li",[e("code",[t._v("true")]),t._v(" (default) - validate formats (see "),e("RouterLink",{attrs:{to:"/guide/formats.html"}},[t._v("Formats")]),t._v("). In "),e("RouterLink",{attrs:{to:"/strict-mode.html"}},[t._v("strict mode")]),t._v(" unknown formats will throw exception during schema compilation (and fail validation in case format keyword value is "),e("RouterLink",{attrs:{to:"/guide/combining-schemas.html#data-reference"}},[t._v("$data reference")]),t._v(").")],1),t._v(" "),e("li",[e("code",[t._v("false")]),t._v(" - do not validate any format keywords (TODO they will still collect annotations once supported).")])]),t._v(" "),e("h2",{attrs:{id:"validation-and-reporting-options"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#validation-and-reporting-options"}},[t._v("#")]),t._v(" Validation and reporting options")]),t._v(" "),e("h3",{attrs:{id:"data"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#data"}},[t._v("#")]),t._v(" $data")]),t._v(" "),e("p",[t._v("Support "),e("RouterLink",{attrs:{to:"/guide/combining-schemas.html#data-reference"}},[t._v("$data references")]),t._v(". Draft 6 meta-schema that is added by default will be extended to allow them. If you want to use another meta-schema you need to use $dataMetaSchema method to add support for $data reference. See "),e("a",{attrs:{href:"#ajv-constructor-and-methods"}},[t._v("API")]),t._v(".")],1),t._v(" "),e("h3",{attrs:{id:"allerrors"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#allerrors"}},[t._v("#")]),t._v(" allErrors")]),t._v(" "),e("p",[t._v("Check all rules collecting all errors. Default is to return after the first error.")]),t._v(" "),e("h3",{attrs:{id:"verbose"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#verbose"}},[t._v("#")]),t._v(" verbose")]),t._v(" "),e("p",[t._v("Include the reference to the part of the schema ("),e("code",[t._v("schema")]),t._v(" and "),e("code",[t._v("parentSchema")]),t._v(") and validated data in errors (false by default).")]),t._v(" "),e("h3",{attrs:{id:"discriminator"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#discriminator"}},[t._v("#")]),t._v(" discriminator")]),t._v(" "),e("p",[t._v("Support "),e("RouterLink",{attrs:{to:"/json-schema.html#discriminator"}},[t._v("discriminator keyword")]),t._v(" from "),e("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"),e("OutboundLink")],1),t._v(".")],1),t._v(" "),e("h3",{attrs:{id:"unicoderegexp"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#unicoderegexp"}},[t._v("#")]),t._v(" unicodeRegExp")]),t._v(" "),e("p",[t._v('By default Ajv uses unicode flag "u" with "pattern" and "patternProperties", as per JSON Schema spec. See '),e("a",{attrs:{href:"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/unicode",target:"_blank",rel:"noopener noreferrer"}},[t._v("RegExp.prototype.unicode"),e("OutboundLink")],1),t._v(" .")]),t._v(" "),e("p",[t._v("Option values:")]),t._v(" "),e("ul",[e("li",[e("code",[t._v("true")]),t._v(' (default) - use unicode flag "u".')]),t._v(" "),e("li",[e("code",[t._v("false")]),t._v(' - do not use flag "u".')])]),t._v(" "),e("h3",{attrs:{id:"timestamp"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#timestamp"}},[t._v("#")]),t._v(" timestamp "),e("Badge",{attrs:{text:"JTD only"}})],1),t._v(" "),e("p",[t._v("Defines which Javascript types will be accepted for the "),e("a",{attrs:{href:"./json-type-definition#type-form"}},[t._v("JTD timestamp type")]),t._v(".")]),t._v(" "),e("p",[t._v("By default Ajv will accept both Date objects and "),e("a",{attrs:{href:"https://datatracker.ietf.org/doc/rfc3339/",target:"_blank",rel:"noopener noreferrer"}},[t._v("RFC3339"),e("OutboundLink")],1),t._v(" strings. You can specify allowed values with the option "),e("code",[t._v('timestamp: "date"')]),t._v(" or "),e("code",[t._v('timestamp: "string"')]),t._v(".")]),t._v(" "),e("h3",{attrs:{id:"parsedate"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#parsedate"}},[t._v("#")]),t._v(" parseDate "),e("Badge",{attrs:{text:"JTD only"}})],1),t._v(" "),e("p",[t._v("Defines how date-time strings are parsed by "),e("RouterLink",{attrs:{to:"/api.html#jtd-parse"}},[t._v("JTD parsers")]),t._v(". By default Ajv parses date-time strings as string. Use "),e("code",[t._v("parseDate: true")]),t._v(" to parse them as Date objects.")],1),t._v(" "),e("h3",{attrs:{id:"allowdate"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#allowdate"}},[t._v("#")]),t._v(" allowDate "),e("Badge",{attrs:{text:"JTD only"}})],1),t._v(" "),e("p",[t._v("Defines how date-time strings are parsed and validated. By default Ajv only allows full date-time strings, as required by JTD specification. Use "),e("code",[t._v("allowDate: true")]),t._v(" to allow date strings both for validation and for parsing.")]),t._v(" "),e("div",{staticClass:"custom-block warning"},[e("p",{staticClass:"custom-block-title"},[t._v("Option allowDate is not portable")]),t._v(" "),e("p",[t._v("This option makes JTD validation and parsing more permissive and non-standard. The date strings without time part will be accepted by Ajv, but will be rejected by other JTD validators.")])]),t._v(" "),e("h3",{attrs:{id:"int32range"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#int32range"}},[t._v("#")]),t._v(" int32range "),e("Badge",{attrs:{text:"JTD only"}})],1),t._v(" "),e("p",[t._v("Can be used to disable range checking for "),e("code",[t._v("int32")]),t._v(" and "),e("code",[t._v("uint32")]),t._v(" types.")]),t._v(" "),e("p",[t._v("By default Ajv limits the range of these types to "),e("code",[t._v("[-2**31, 2**31 - 1]")]),t._v(" for "),e("code",[t._v("int32")]),t._v(" and to "),e("code",[t._v("[0, 2**32-1]")]),t._v(" for "),e("code",[t._v("uint32")]),t._v(" when validating and parsing.")]),t._v(" "),e("p",[t._v("With option "),e("code",[t._v("int32range: false")]),t._v(" Ajv only requires that "),e("code",[t._v("uint32")]),t._v(" is non-negative, otherwise does not check the range. Parser will limit the number size to 16 digits (approx. "),e("code",[t._v("2**53")]),t._v(" - safe integer range).")]),t._v(" "),e("div",{staticClass:"custom-block warning"},[e("p",{staticClass:"custom-block-title"},[t._v("Option int32range is not portable")]),t._v(" "),e("p",[t._v("This option makes JTD validation and parsing more permissive and non-standard. The integers within a wider range will be accepted by Ajv, but will be rejected by other JTD validators.")])]),t._v(" "),e("h3",{attrs:{id:"comment"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#comment"}},[t._v("#")]),t._v(" $comment")]),t._v(" "),e("p",[t._v("Log or pass the value of "),e("code",[t._v("$comment")]),t._v(" keyword to a function.")]),t._v(" "),e("p",[t._v("Option values:")]),t._v(" "),e("ul",[e("li",[e("code",[t._v("false")]),t._v(" (default): ignore $comment keyword.")]),t._v(" "),e("li",[e("code",[t._v("true")]),t._v(": log the keyword value to console.")]),t._v(" "),e("li",[t._v("function: pass the keyword value, its schema path and root schema to the specified function")])]),t._v(" "),e("h3",{attrs:{id:"formats"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#formats"}},[t._v("#")]),t._v(" formats")]),t._v(" "),e("p",[t._v("An object with format definitions. Keys and values will be passed to "),e("code",[t._v("addFormat")]),t._v(" method. Pass "),e("code",[t._v("true")]),t._v(" as format definition to ignore some formats.")]),t._v(" "),e("h3",{attrs:{id:"keywords"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#keywords"}},[t._v("#")]),t._v(" keywords")]),t._v(" "),e("p",[t._v("An array of keyword definitions or strings. Values will be passed to "),e("code",[t._v("addKeyword")]),t._v(" method.")]),t._v(" "),e("h3",{attrs:{id:"schemas"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#schemas"}},[t._v("#")]),t._v(" schemas")]),t._v(" "),e("p",[t._v("An array or object of schemas that will be added to the instance. In case you pass the array the schemas must have IDs in them. When the object is passed the method "),e("code",[t._v("addSchema(value, key)")]),t._v(" will be called for each schema in this object.")]),t._v(" "),e("h3",{attrs:{id:"logger"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#logger"}},[t._v("#")]),t._v(" logger")]),t._v(" "),e("p",[t._v("Sets the logging method. Default is the global "),e("code",[t._v("console")]),t._v(" object that should have methods "),e("code",[t._v("log")]),t._v(", "),e("code",[t._v("warn")]),t._v(" and "),e("code",[t._v("error")]),t._v(". See "),e("RouterLink",{attrs:{to:"/api.html#error-logging"}},[t._v("Error logging")]),t._v(".")],1),t._v(" "),e("p",[t._v("Option values:")]),t._v(" "),e("ul",[e("li",[t._v("logger instance - it should have methods "),e("code",[t._v("log")]),t._v(", "),e("code",[t._v("warn")]),t._v(" and "),e("code",[t._v("error")]),t._v(". If any of these methods is missing an exception will be thrown.")]),t._v(" "),e("li",[e("code",[t._v("false")]),t._v(" - logging is disabled.")])]),t._v(" "),e("h3",{attrs:{id:"loadschema"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#loadschema"}},[t._v("#")]),t._v(" loadSchema")]),t._v(" "),e("p",[t._v("Asynchronous function that will be used to load remote schemas when "),e("code",[t._v("compileAsync")]),t._v(" "),e("a",{attrs:{href:"#api-compileAsync"}},[t._v("method")]),t._v(" is used and some reference is missing (option "),e("code",[t._v("missingRefs")]),t._v(" should NOT be 'fail' or 'ignore'). This function should accept remote schema uri as a parameter and return a Promise that resolves to a schema. See example in "),e("RouterLink",{attrs:{to:"/guide/managing-schemas.html#asynchronous-schema-compilation"}},[t._v("Asynchronous compilation")]),t._v(".")],1),t._v(" "),e("h2",{attrs:{id:"options-to-modify-validated-data"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#options-to-modify-validated-data"}},[t._v("#")]),t._v(" Options to modify validated data")]),t._v(" "),e("h3",{attrs:{id:"removeadditional"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#removeadditional"}},[t._v("#")]),t._v(" removeAdditional")]),t._v(" "),e("p",[t._v("Remove additional properties - see example in "),e("RouterLink",{attrs:{to:"/guide/modifying-data.html#removing-additional-properties"}},[t._v("Removing additional properties")]),t._v(".")],1),t._v(" "),e("p",[t._v("This option is not used if schema is added with "),e("code",[t._v("addMetaSchema")]),t._v(" method.")]),t._v(" "),e("p",[t._v("Option values:")]),t._v(" "),e("ul",[e("li",[e("code",[t._v("false")]),t._v(" (default) - not to remove additional properties")]),t._v(" "),e("li",[e("code",[t._v('"all"')]),t._v(" - all additional properties are removed, regardless of "),e("code",[t._v("additionalProperties")]),t._v(" keyword in schema (and no validation is made for them).")]),t._v(" "),e("li",[e("code",[t._v("true")]),t._v(" - only additional properties with "),e("code",[t._v("additionalProperties")]),t._v(" keyword equal to "),e("code",[t._v("false")]),t._v(" are removed.")]),t._v(" "),e("li",[e("code",[t._v('"failing"')]),t._v(" - additional properties that fail schema validation will be removed (where "),e("code",[t._v("additionalProperties")]),t._v(" keyword is "),e("code",[t._v("false")]),t._v(" or schema).")])]),t._v(" "),e("h3",{attrs:{id:"usedefaults"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#usedefaults"}},[t._v("#")]),t._v(" useDefaults")]),t._v(" "),e("p",[t._v("Replace missing or undefined properties and items with the values from corresponding "),e("code",[t._v("default")]),t._v(" keywords. Default behaviour is to ignore "),e("code",[t._v("default")]),t._v(" keywords. This option is not used if schema is added with "),e("code",[t._v("addMetaSchema")]),t._v(" method.")]),t._v(" "),e("p",[t._v("See examples in "),e("RouterLink",{attrs:{to:"/guide/modifying-data.html#assigning-defaults"}},[t._v("Assigning defaults")]),t._v(".")],1),t._v(" "),e("p",[t._v("Option values:")]),t._v(" "),e("ul",[e("li",[e("code",[t._v("false")]),t._v(" (default) - do not use defaults")]),t._v(" "),e("li",[e("code",[t._v("true")]),t._v(" - insert defaults by value (object literal is used).")]),t._v(" "),e("li",[e("code",[t._v('"empty"')]),t._v(" - in addition to missing or undefined, use defaults for properties and items that are equal to "),e("code",[t._v("null")]),t._v(" or "),e("code",[t._v('""')]),t._v(" (an empty string).")])]),t._v(" "),e("h3",{attrs:{id:"coercetypes"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#coercetypes"}},[t._v("#")]),t._v(" coerceTypes")]),t._v(" "),e("p",[t._v("Change data type of data to match "),e("code",[t._v("type")]),t._v(" keyword. See the example in "),e("RouterLink",{attrs:{to:"/guide/modifying-data.html#coercing-data-types"}},[t._v("Coercing data types")]),t._v(" and "),e("RouterLink",{attrs:{to:"/coercion.html"}},[t._v("coercion rules")]),t._v(".")],1),t._v(" "),e("p",[t._v("Option values:")]),t._v(" "),e("ul",[e("li",[e("code",[t._v("false")]),t._v(" (default) - no type coercion.")]),t._v(" "),e("li",[e("code",[t._v("true")]),t._v(" - coerce scalar data types.")]),t._v(" "),e("li",[e("code",[t._v('"array"')]),t._v(" - in addition to coercions between scalar types, coerce scalar data to an array with one element and vice versa (as required by the schema).")])]),t._v(" "),e("h2",{attrs:{id:"advanced-options"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#advanced-options"}},[t._v("#")]),t._v(" Advanced options")]),t._v(" "),e("h3",{attrs:{id:"meta"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#meta"}},[t._v("#")]),t._v(" meta")]),t._v(" "),e("p",[t._v("Add "),e("a",{attrs:{href:"http://json-schema.org/documentation.html",target:"_blank",rel:"noopener noreferrer"}},[t._v("meta-schema"),e("OutboundLink")],1),t._v(" so it can be used by other schemas (true by default). If an object is passed, it will be used as the default meta-schema for schemas that have no "),e("code",[t._v("$schema")]),t._v(" keyword. This default meta-schema MUST have "),e("code",[t._v("$schema")]),t._v(" keyword.")]),t._v(" "),e("h3",{attrs:{id:"validateschema"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#validateschema"}},[t._v("#")]),t._v(" validateSchema")]),t._v(" "),e("p",[t._v("Validate added/compiled schemas against meta-schema (true by default). "),e("code",[t._v("$schema")]),t._v(" property in the schema can be http://json-schema.org/draft-07/schema or absent (draft-07 meta-schema will be used) or can be a reference to the schema previously added with "),e("code",[t._v("addMetaSchema")]),t._v(" method.")]),t._v(" "),e("p",[t._v("Option values:")]),t._v(" "),e("ul",[e("li",[e("code",[t._v("true")]),t._v(" (default) - if the validation fails, throw the exception.")]),t._v(" "),e("li",[e("code",[t._v('"log"')]),t._v(" - if the validation fails, log error.")]),t._v(" "),e("li",[e("code",[t._v("false")]),t._v(" - skip schema validation.")])]),t._v(" "),e("h3",{attrs:{id:"addusedschema"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#addusedschema"}},[t._v("#")]),t._v(" addUsedSchema")]),t._v(" "),e("p",[t._v("By default methods "),e("code",[t._v("compile")]),t._v(" and "),e("code",[t._v("validate")]),t._v(" add schemas to the instance if they have "),e("code",[t._v("$id")]),t._v(" (or "),e("code",[t._v("id")]),t._v(') property that doesn\'t start with "#". If '),e("code",[t._v("$id")]),t._v(" is present and it is not unique the exception will be thrown. Set this option to "),e("code",[t._v("false")]),t._v(" to skip adding schemas to the instance and the "),e("code",[t._v("$id")]),t._v(" uniqueness check when these methods are used. This option does not affect "),e("code",[t._v("addSchema")]),t._v(" method.")]),t._v(" "),e("h3",{attrs:{id:"inlinerefs"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#inlinerefs"}},[t._v("#")]),t._v(" inlineRefs")]),t._v(" "),e("p",[t._v("Affects compilation of referenced schemas.")]),t._v(" "),e("p",[t._v("Option values:")]),t._v(" "),e("ul",[e("li",[e("code",[t._v("true")]),t._v(" (default) - the referenced schemas that don't have refs in them are inlined, regardless of their size - it improves performance.")]),t._v(" "),e("li",[e("code",[t._v("false")]),t._v(" - to not inline referenced schemas (they will always be compiled as separate functions).")]),t._v(" "),e("li",[t._v("integer number - to limit the maximum number of keywords of the schema that will be inlined (to balance the total size of compiled functions and performance).")])]),t._v(" "),e("h3",{attrs:{id:"passcontext"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#passcontext"}},[t._v("#")]),t._v(" passContext")]),t._v(" "),e("p",[t._v("Pass validation context to "),e("em",[t._v("compile")]),t._v(" and "),e("em",[t._v("validate")]),t._v(" keyword functions. If this option is "),e("code",[t._v("true")]),t._v(" and you pass some context to the compiled validation function with "),e("code",[t._v("validate.call(context, data)")]),t._v(", the "),e("code",[t._v("context")]),t._v(" will be available as "),e("code",[t._v("this")]),t._v(" in your keywords. By default "),e("code",[t._v("this")]),t._v(" is Ajv instance.")]),t._v(" "),e("h3",{attrs:{id:"looprequired"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#looprequired"}},[t._v("#")]),t._v(" loopRequired")]),t._v(" "),e("p",[t._v("By default "),e("code",[t._v("required")]),t._v(" keyword is compiled into a single expression (or a sequence of statements in "),e("code",[t._v("allErrors")]),t._v(" mode) up to 200 required properties. Pass integer to set a different number of properties above which "),e("code",[t._v("required")]),t._v(" keyword will be validated in a loop (with a smaller validation function size and worse performance).")]),t._v(" "),e("h3",{attrs:{id:"loopenum"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#loopenum"}},[t._v("#")]),t._v(" loopEnum "),e("Badge",{attrs:{text:"v7"}})],1),t._v(" "),e("p",[t._v("By default "),e("code",[t._v("enum")]),t._v(" keyword is compiled into a single expression with up to 200 allowed values. Pass integer to set the number of values above which "),e("code",[t._v("enum")]),t._v(" keyword will be validated in a loop (with a smaller validation function size and worse performance).")]),t._v(" "),e("h3",{attrs:{id:"ownproperties"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#ownproperties"}},[t._v("#")]),t._v(" ownProperties")]),t._v(" "),e("p",[t._v("By default Ajv iterates over all enumerable object properties; when this option is "),e("code",[t._v("true")]),t._v(" only own enumerable object properties (i.e. found directly on the object rather than on its prototype) are iterated. Contributed by @mbroadst.")]),t._v(" "),e("h3",{attrs:{id:"multipleofprecision"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#multipleofprecision"}},[t._v("#")]),t._v(" multipleOfPrecision")]),t._v(" "),e("p",[t._v("By default "),e("code",[t._v("multipleOf")]),t._v(" keyword is validated by comparing the result of division with "),e("code",[t._v("parseInt()")]),t._v(" of that result. It works for dividers that are bigger than 1. For small dividers such as 0.01 the result of the division is usually not integer (even when it should be integer, see issue "),e("a",{attrs:{href:"https://github.com/ajv-validator/ajv/issues/84",target:"_blank",rel:"noopener noreferrer"}},[t._v("#84"),e("OutboundLink")],1),t._v("). If you need to use fractional dividers set this option to some positive integer N to have "),e("code",[t._v("multipleOf")]),t._v(" validated using this formula: "),e("code",[t._v("Math.abs(Math.round(division) - division) < 1e-N")]),t._v(" (it is slower but allows for float arithmetic deviations).")]),t._v(" "),e("h3",{attrs:{id:"messages"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#messages"}},[t._v("#")]),t._v(" messages")]),t._v(" "),e("p",[t._v("Include human-readable messages in errors. "),e("code",[t._v("true")]),t._v(" by default. "),e("code",[t._v("false")]),t._v(" can be passed when messages are generated outside of Ajv code (e.g. with "),e("a",{attrs:{href:"https://github.com/ajv-validator/ajv-i18n",target:"_blank",rel:"noopener noreferrer"}},[t._v("ajv-i18n"),e("OutboundLink")],1),t._v(").")]),t._v(" "),e("h3",{attrs:{id:"uriresolver"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#uriresolver"}},[t._v("#")]),t._v(" uriResolver")]),t._v(" "),e("p",[t._v("By default "),e("code",[t._v("uriResolver")]),t._v(" is undefined and relies on the embedded uriResolver "),e("a",{attrs:{href:"https://github.com/fastify/fast-uri",target:"_blank",rel:"noopener noreferrer"}},[t._v("fast-uri"),e("OutboundLink")],1),t._v(". Pass an object that satisfies the interface "),e("a",{attrs:{href:"https://github.com/ajv-validator/ajv/blob/master/lib/types/index.ts",target:"_blank",rel:"noopener noreferrer"}},[t._v("UriResolver"),e("OutboundLink")],1),t._v(" to be used in replacement. One alternative is "),e("a",{attrs:{href:"https://github.com/garycourt/uri-js",target:"_blank",rel:"noopener noreferrer"}},[t._v("uri-js"),e("OutboundLink")],1),t._v(".")]),t._v(" "),e("h3",{attrs:{id:"code"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#code"}},[t._v("#")]),t._v(" code "),e("Badge",{attrs:{text:"v7"}})],1),t._v(" "),e("p",[t._v("Code generation options:")]),t._v(" "),e("div",{staticClass:"language-typescript extra-class"},[e("pre",{pre:!0,attrs:{class:"language-typescript"}},[e("code",[e("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("type")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("CodeOptions")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n es5"),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("boolean")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v('// to generate es5 code - by default code is es6, with "for-of" loops, "let" and "const"')]),t._v("\n esm"),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("boolean")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// how functions should be exported - by default CJS is used, so the validate function(s) ")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// file can be `required`. Set this value to true to export the validate function(s) as ES Modules, enabling ")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// bunlers to do their job.")]),t._v("\n lines"),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("boolean")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// add line-breaks to code - to simplify debugging of generated functions")]),t._v("\n source"),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("boolean")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// add `source` property (see Source below) to validating function.")]),t._v("\n process"),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("code"),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("string")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" schema"),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" SchemaEnv"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=>")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("string")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// an optional function to process generated code")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// before it is passed to Function constructor.")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// It can be used to either beautify or to transpile code.")]),t._v("\n optimize"),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("boolean")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("|")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("number")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// code optimization flag or number of passes, 1 pass by default,")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// code optimizations reduce the size of the generated code (bytes, based on the tests) by over 10%,")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// the number of code tree nodes by nearly 17%.")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// You would almost never need more than one optimization pass, unless you have some really complex schemas -")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// the second pass in the tests (it has quite complex schemas) only improves optimization by less than 0.1%.")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// See [Code optimization](./codegen.md#code-optimization) for details.")]),t._v("\n formats"),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" Code\n "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// Code snippet created with `_` tagged template literal that contains all format definitions,")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// it can be the code of actual definitions or `require` call:")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v('// _`require("./my-formats")`')]),t._v("\n regExp"),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" RegExpEngine\n "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// Pass non-standard RegExp engine to mitigate ReDoS, e.g. node-re2.")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// During validation of a schema, code.regExp will be ")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// used to match strings against regular expressions.")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// The supplied function must support the interface:")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// regExp(regex, unicodeFlag).test(string) => boolean")]),t._v("\n"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n\n"),e("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("type")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("Source")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n code"),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("string")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// unlike func.toString() it includes assignments external to function scope")]),t._v("\n scope"),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" Scope "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// see Code generation (TODO)")]),t._v("\n"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])])])}),[],!1,null,null,null);e.default=r.exports}}]); \ No newline at end of file diff --git a/assets/js/75.5af64013.js b/assets/js/75.5af64013.js new file mode 100644 index 000000000..9a8ba8aee --- /dev/null +++ b/assets/js/75.5af64013.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[75],{506:function(t,e,a){"use strict";a.r(e);var r=a(14),n=Object(r.a)({},(function(){var t=this,e=t._self._c;return e("ContentSlotsDistributor",{attrs:{"slot-key":t.$parent.slotKey}},[e("h1",{attrs:{id:"extending-ajv"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#extending-ajv"}},[t._v("#")]),t._v(" Extending Ajv")]),t._v(" "),e("h2",{attrs:{id:"plugins"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#plugins"}},[t._v("#")]),t._v(" Plugins")]),t._v(" "),e("p",[t._v("Ajv can be extended with plugins that add "),e("RouterLink",{attrs:{to:"/guide/user-keywords.html"}},[t._v("user defined schema keywords")]),t._v(", "),e("RouterLink",{attrs:{to:"/guide/formats.html"}},[t._v("validation formats")]),t._v(" or functions to process generated code. When such plugin is published as npm package it is recommended that it follows these conventions:")],1),t._v(" "),e("ul",[e("li",[t._v("it exports a function that accepts ajv instance as the first parameter - it allows using plugins with "),e("RouterLink",{attrs:{to:"/packages/ajv-cli.html"}},[t._v("ajv-cli")]),t._v(".")],1),t._v(" "),e("li",[t._v("this function returns the same instance to allow chaining.")]),t._v(" "),e("li",[t._v("this function can accept an optional configuration as the second parameter.")])]),t._v(" "),e("p",[t._v("You can import "),e("code",[t._v("Plugin")]),t._v(" interface from ajv if you use Typescript.")]),t._v(" "),e("p",[t._v("If you have published a useful plugin please submit a PR to add it to the next section.")]),t._v(" "),e("h2",{attrs:{id:"related-packages"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#related-packages"}},[t._v("#")]),t._v(" Related packages")]),t._v(" "),e("ul",[e("li",[e("a",{attrs:{href:"https://github.com/ajv-validator/ajv-formats",target:"_blank",rel:"noopener noreferrer"}},[t._v("ajv-formats"),e("OutboundLink")],1),t._v(" - formats defined in JSON Schema specification")]),t._v(" "),e("li",[e("a",{attrs:{href:"https://github.com/ajv-validator/ajv-keywords",target:"_blank",rel:"noopener noreferrer"}},[t._v("ajv-keywords"),e("OutboundLink")],1),t._v(" - additional validation keywords (select, typeof, etc.)")]),t._v(" "),e("li",[e("a",{attrs:{href:"https://github.com/ajv-validator/ajv-errors",target:"_blank",rel:"noopener noreferrer"}},[t._v("ajv-errors"),e("OutboundLink")],1),t._v(" - defining error messages in the schema")]),t._v(" "),e("li",[e("a",{attrs:{href:"https://github.com/ajv-validator/ajv-i18n",target:"_blank",rel:"noopener noreferrer"}},[t._v("ajv-i18n"),e("OutboundLink")],1),t._v(" - internationalised error messages")]),t._v(" "),e("li",[e("a",{attrs:{href:"https://github.com/ajv-validator/ajv-cli",target:"_blank",rel:"noopener noreferrer"}},[t._v("ajv-cli"),e("OutboundLink")],1),t._v(" - command line interface")]),t._v(" "),e("li",[e("a",{attrs:{href:"https://github.com/BoLaMN/ajv-bsontype",target:"_blank",rel:"noopener noreferrer"}},[t._v("ajv-bsontype"),e("OutboundLink")],1),t._v(" - MongoDB's bsonType formats")]),t._v(" "),e("li",[e("a",{attrs:{href:"https://github.com/luzlab/ajv-formats-draft2019",target:"_blank",rel:"noopener noreferrer"}},[t._v("ajv-formats-draft2019"),e("OutboundLink")],1),t._v(" - formats for draft-2019-09 that are not included in "),e("RouterLink",{attrs:{to:"/packages/ajv-formats.html"}},[t._v("ajv-formats")]),t._v(" ("),e("code",[t._v("idn-hostname")]),t._v(", "),e("code",[t._v("idn-email")]),t._v(", "),e("code",[t._v("iri")]),t._v(" and "),e("code",[t._v("iri-reference")]),t._v(")")],1),t._v(" "),e("li",[e("a",{attrs:{href:"https://github.com/ajv-validator/ajv-merge-patch",target:"_blank",rel:"noopener noreferrer"}},[t._v("ajv-merge-patch"),e("OutboundLink")],1),t._v(" - keywords $merge and $patch")])])])}),[],!1,null,null,null);e.default=n.exports}}]); \ No newline at end of file diff --git a/assets/js/76.a440d914.js b/assets/js/76.a440d914.js new file mode 100644 index 000000000..7be8e1e61 --- /dev/null +++ b/assets/js/76.a440d914.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[76],{505:function(e,a,t){"use strict";t.r(a);var s=t(14),r=Object(s.a)({},(function(){var e=this,a=e._self._c;return a("ContentSlotsDistributor",{attrs:{"slot-key":e.$parent.slotKey}},[a("p",[a("a",{attrs:{href:"https://github.com/ajv-validator/ajv-cli",target:"_blank",rel:"noopener noreferrer"}},[e._v("ajv-cli repository"),a("OutboundLink")],1)]),e._v(" "),a("h1",{attrs:{id:"ajv-cli"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#ajv-cli"}},[e._v("#")]),e._v(" ajv-cli")]),e._v(" "),a("p",[e._v("Command line interface for "),a("a",{attrs:{href:"https://github.com/epoberezkin/ajv",target:"_blank",rel:"noopener noreferrer"}},[e._v("ajv"),a("OutboundLink")],1),e._v(", one of the "),a("a",{attrs:{href:"https://github.com/ebdrup/json-schema-benchmark",target:"_blank",rel:"noopener noreferrer"}},[e._v("fastest json schema validators"),a("OutboundLink")],1),e._v(".\nSupports "),a("a",{attrs:{href:"http://json.org/",target:"_blank",rel:"noopener noreferrer"}},[e._v("JSON"),a("OutboundLink")],1),e._v(", "),a("a",{attrs:{href:"http://json5.org/",target:"_blank",rel:"noopener noreferrer"}},[e._v("JSON5"),a("OutboundLink")],1),e._v(", and "),a("a",{attrs:{href:"http://yaml.org/",target:"_blank",rel:"noopener noreferrer"}},[e._v("YAML"),a("OutboundLink")],1),e._v(".")]),e._v(" "),a("p",[a("a",{attrs:{href:"https://github.com/ajv-validator/ajv-cli/actions?query=workflow%3Abuild",target:"_blank",rel:"noopener noreferrer"}},[a("img",{attrs:{src:"https://github.com/ajv-validator/ajv-cli/workflows/build/badge.svg",alt:"build"}}),a("OutboundLink")],1),e._v(" "),a("a",{attrs:{href:"https://www.npmjs.com/package/ajv-cli",target:"_blank",rel:"noopener noreferrer"}},[a("img",{attrs:{src:"https://img.shields.io/npm/v/ajv-cli.svg",alt:"npm"}}),a("OutboundLink")],1),e._v(" "),a("a",{attrs:{href:"https://coveralls.io/github/ajv-validator/ajv-cli?branch=master",target:"_blank",rel:"noopener noreferrer"}},[a("img",{attrs:{src:"https://coveralls.io/repos/github/ajv-validator/ajv-cli/badge.svg?branch=master",alt:"coverage"}}),a("OutboundLink")],1),e._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)]),e._v(" "),a("h2",{attrs:{id:"contents"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#contents"}},[e._v("#")]),e._v(" Contents")]),e._v(" "),a("ul",[a("li",[a("a",{attrs:{href:"#installation"}},[e._v("Installation")])]),e._v(" "),a("li",[a("a",{attrs:{href:"#json-schema-version"}},[e._v("JSON schema version")])]),e._v(" "),a("li",[e._v("Commands\n"),a("ul",[a("li",[a("a",{attrs:{href:"#help-command"}},[e._v("Help")])]),e._v(" "),a("li",[a("a",{attrs:{href:"#validate-data"}},[e._v("Validate data")])]),e._v(" "),a("li",[a("a",{attrs:{href:"#compile-schemas"}},[e._v("Compile schemas")])]),e._v(" "),a("li",[a("a",{attrs:{href:"#migrate-schemas"}},[e._v("Migrate schemas")])]),e._v(" "),a("li",[a("a",{attrs:{href:"#test-validation-result"}},[e._v("Test validation result")])])])]),e._v(" "),a("li",[a("a",{attrs:{href:"#ajv-options"}},[e._v("Ajv options")])]),e._v(" "),a("li",[a("a",{attrs:{href:"#version_history"}},[e._v("Version History, License")])])]),e._v(" "),a("h2",{attrs:{id:"installation"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#installation"}},[e._v("#")]),e._v(" Installation")]),e._v(" "),a("div",{staticClass:"language-sh extra-class"},[a("pre",{pre:!0,attrs:{class:"language-sh"}},[a("code",[a("span",{pre:!0,attrs:{class:"token function"}},[e._v("npm")]),e._v(" "),a("span",{pre:!0,attrs:{class:"token function"}},[e._v("install")]),e._v(" "),a("span",{pre:!0,attrs:{class:"token parameter variable"}},[e._v("-g")]),e._v(" ajv-cli\n")])])]),a("h2",{attrs:{id:"json-schema-language-and-version"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#json-schema-language-and-version"}},[e._v("#")]),e._v(" JSON schema language and version")]),e._v(" "),a("p",[e._v("Parameter "),a("code",[e._v("--spec")]),e._v(" can be used with all commands (other than help) to choose JSON schema language:")]),e._v(" "),a("ul",[a("li",[a("code",[e._v("--spec=draft7")]),e._v(" (default) - support JSON Schema draft-07 (uses "),a("code",[e._v('import Ajv from "ajv"')]),e._v(")")]),e._v(" "),a("li",[a("code",[e._v("--spec=draft2019")]),e._v(" - support JSON Schema draft-2019-09 (uses "),a("code",[e._v('import Ajv from "ajv/dist/2019"')]),e._v(")")]),e._v(" "),a("li",[a("code",[e._v("--spec=draft2020")]),e._v(" - support JSON Schema draft-2020-12 (uses "),a("code",[e._v('import Ajv from "ajv/dist/2020"')]),e._v(")")]),e._v(" "),a("li",[a("code",[e._v("--spec=jtd")]),e._v(" - support "),a("a",{attrs:{href:"https://ajv.js.org/json-type-definition.html",target:"_blank",rel:"noopener noreferrer"}},[e._v("JSON Type Definition"),a("OutboundLink")],1),e._v(" (uses "),a("code",[e._v('import Ajv from "ajv/dist/jtd"')]),e._v(")")])]),e._v(" "),a("h2",{attrs:{id:"commands"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#commands"}},[e._v("#")]),e._v(" Commands")]),e._v(" "),a("h3",{attrs:{id:"help-command"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#help-command"}},[e._v("#")]),e._v(" Help command")]),e._v(" "),a("div",{staticClass:"language-sh extra-class"},[a("pre",{pre:!0,attrs:{class:"language-sh"}},[a("code",[e._v("ajv "),a("span",{pre:!0,attrs:{class:"token builtin class-name"}},[e._v("help")]),e._v("\najv "),a("span",{pre:!0,attrs:{class:"token builtin class-name"}},[e._v("help")]),e._v(" validate\najv "),a("span",{pre:!0,attrs:{class:"token builtin class-name"}},[e._v("help")]),e._v(" compile\najv "),a("span",{pre:!0,attrs:{class:"token builtin class-name"}},[e._v("help")]),e._v(" migrate\najv "),a("span",{pre:!0,attrs:{class:"token builtin class-name"}},[e._v("help")]),e._v(" "),a("span",{pre:!0,attrs:{class:"token builtin class-name"}},[e._v("test")]),e._v("\n")])])]),a("h3",{attrs:{id:"validate-data"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#validate-data"}},[e._v("#")]),e._v(" Validate data")]),e._v(" "),a("p",[e._v("This command validates data files against JSON-schema")]),e._v(" "),a("div",{staticClass:"language-sh extra-class"},[a("pre",{pre:!0,attrs:{class:"language-sh"}},[a("code",[e._v("ajv validate "),a("span",{pre:!0,attrs:{class:"token parameter variable"}},[e._v("-s")]),e._v(" test/schema.json "),a("span",{pre:!0,attrs:{class:"token parameter variable"}},[e._v("-d")]),e._v(" test/valid_data.json\najv "),a("span",{pre:!0,attrs:{class:"token parameter variable"}},[e._v("-s")]),e._v(" test/schema.json "),a("span",{pre:!0,attrs:{class:"token parameter variable"}},[e._v("-d")]),e._v(" test/valid_data.json\n")])])]),a("p",[e._v("You can omit "),a("code",[e._v("validate")]),e._v(" command name and "),a("code",[e._v(".json")]),e._v(" from the "),a("a",{attrs:{href:"https://nodejs.org/api/modules.html#modules_file_modules",target:"_blank",rel:"noopener noreferrer"}},[e._v("input file names"),a("OutboundLink")],1),e._v(".")]),e._v(" "),a("h4",{attrs:{id:"parameters"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#parameters"}},[e._v("#")]),e._v(" Parameters")]),e._v(" "),a("h5",{attrs:{id:"s-file-name-of-json-schema"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#s-file-name-of-json-schema"}},[e._v("#")]),e._v(" "),a("code",[e._v("-s")]),e._v(" - file name of JSON-schema")]),e._v(" "),a("p",[e._v("Only one schema can be passed in this parameter")]),e._v(" "),a("h5",{attrs:{id:"d-json-data"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#d-json-data"}},[e._v("#")]),e._v(" "),a("code",[e._v("-d")]),e._v(" - JSON data")]),e._v(" "),a("p",[e._v("Multiple data files can be passed, as in "),a("code",[e._v("-r")]),e._v(" parameter:")]),e._v(" "),a("div",{staticClass:"language-sh extra-class"},[a("pre",{pre:!0,attrs:{class:"language-sh"}},[a("code",[e._v("ajv "),a("span",{pre:!0,attrs:{class:"token parameter variable"}},[e._v("-s")]),e._v(" test/schema.json "),a("span",{pre:!0,attrs:{class:"token parameter variable"}},[e._v("-d")]),e._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[e._v('"test/valid*.json"')]),e._v("\n")])])]),a("p",[e._v("If some file is invalid exit code will be 1.")]),e._v(" "),a("h5",{attrs:{id:"r-referenced-schemas"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#r-referenced-schemas"}},[e._v("#")]),e._v(" "),a("code",[e._v("-r")]),e._v(" - referenced schemas")]),e._v(" "),a("p",[e._v("The schema in "),a("code",[e._v("-s")]),e._v(" parameter can reference any of these schemas with "),a("code",[e._v("$ref")]),e._v(" keyword.")]),e._v(" "),a("p",[e._v("Multiple schemas can be passed both by using this parameter multiple times and with "),a("a",{attrs:{href:"https://github.com/isaacs/node-glob#glob-primer",target:"_blank",rel:"noopener noreferrer"}},[e._v("glob patterns"),a("OutboundLink")],1),e._v(". Glob pattern should be quoted and extensions cannot be omitted.")]),e._v(" "),a("h5",{attrs:{id:"m-meta-schemas"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#m-meta-schemas"}},[e._v("#")]),e._v(" "),a("code",[e._v("-m")]),e._v(" - meta-schemas")]),e._v(" "),a("p",[e._v("Schemas can use any of these schemas as a meta-schema (that is the schema used in "),a("code",[e._v("$schema")]),e._v(" keyword - it is used to validate the schema itself).")]),e._v(" "),a("p",[e._v("Multiple meta-schemas can be passed, as in "),a("code",[e._v("-r")]),e._v(" parameter.")]),e._v(" "),a("h5",{attrs:{id:"c-custom-keywords-formats-definitions"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#c-custom-keywords-formats-definitions"}},[e._v("#")]),e._v(" "),a("code",[e._v("-c")]),e._v(" - custom keywords/formats definitions")]),e._v(" "),a("p",[e._v('You can pass module(s) that define custom keywords/formats. The modules should export a function that accepts Ajv instance as a parameter. The file name should start with ".", it will be resolved relative to the current folder. The package name can also be passed - it will be used in require as is.\nThese modules can be written in TypeScript if you have '),a("code",[e._v("ts-node")]),e._v(" installed.")]),e._v(" "),a("p",[e._v("For example, you can use "),a("code",[e._v("-c ajv-keywords")]),e._v(" to add all keywords from "),a("a",{attrs:{href:"https://github.com/ajv-validator/ajv-keywords",target:"_blank",rel:"noopener noreferrer"}},[e._v("ajv-keywords"),a("OutboundLink")],1),e._v(" package or "),a("code",[e._v("-c ajv-keywords/keywords/typeof")]),e._v(" to add only typeof keyword.")]),e._v(" "),a("h4",{attrs:{id:"options"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#options"}},[e._v("#")]),e._v(" Options")]),e._v(" "),a("ul",[a("li",[a("p",[a("code",[e._v("--errors=")]),e._v(": error reporting format. Possible values:")]),e._v(" "),a("ul",[a("li",[a("code",[e._v("js")]),e._v(" (default): JavaScript object")]),e._v(" "),a("li",[a("code",[e._v("json")]),e._v(": JSON with indentation and line-breaks")]),e._v(" "),a("li",[a("code",[e._v("line")]),e._v(": JSON without indentation/line-breaks (for easy parsing)")]),e._v(" "),a("li",[a("code",[e._v("text")]),e._v(": human readable error messages with data paths")])])]),e._v(" "),a("li",[a("p",[a("code",[e._v("--changes=")]),e._v(": detect changes in data after validation."),a("br"),e._v("\nData can be modified with "),a("a",{attrs:{href:"#ajv-options"}},[e._v("Ajv options")]),e._v(" "),a("code",[e._v("--remove-additional")]),e._v(", "),a("code",[e._v("--use-defaults")]),e._v(" and "),a("code",[e._v("--coerce-types")]),e._v(")."),a("br"),e._v("\nThe changes are reported in JSON-patch format ("),a("a",{attrs:{href:"https://tools.ietf.org/html/rfc6902",target:"_blank",rel:"noopener noreferrer"}},[e._v("RFC6902"),a("OutboundLink")],1),e._v(")."),a("br"),e._v("\nPossible values are "),a("code",[e._v("js")]),e._v(" (default), "),a("code",[e._v("json")]),e._v(" and "),a("code",[e._v("line")]),e._v(" (see "),a("code",[e._v("--errors")]),e._v(" option).")])])]),e._v(" "),a("h3",{attrs:{id:"compile-schemas"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#compile-schemas"}},[e._v("#")]),e._v(" Compile schemas")]),e._v(" "),a("p",[e._v("This command validates and compiles schema without validating any data.")]),e._v(" "),a("p",[e._v("It can be used to check that the schema is valid and to create a standalone module exporting validation function(s).")]),e._v(" "),a("div",{staticClass:"language-sh extra-class"},[a("pre",{pre:!0,attrs:{class:"language-sh"}},[a("code",[e._v("ajv compile "),a("span",{pre:!0,attrs:{class:"token parameter variable"}},[e._v("-s")]),e._v(" schema\n\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[e._v("# compile to module file")]),e._v("\najv compile "),a("span",{pre:!0,attrs:{class:"token parameter variable"}},[e._v("-s")]),e._v(" schema "),a("span",{pre:!0,attrs:{class:"token parameter variable"}},[e._v("-o")]),e._v(" validate.js\n\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[e._v("## compile to stdout, to allow code formatting (js-beautify has to be installed separately)")]),e._v("\najv compile "),a("span",{pre:!0,attrs:{class:"token parameter variable"}},[e._v("-s")]),e._v(" schema "),a("span",{pre:!0,attrs:{class:"token parameter variable"}},[e._v("-o")]),e._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[e._v("|")]),e._v(" js-beautify "),a("span",{pre:!0,attrs:{class:"token operator"}},[e._v(">")]),e._v(" validate.js\n")])])]),a("h4",{attrs:{id:"parameters-2"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#parameters-2"}},[e._v("#")]),e._v(" Parameters")]),e._v(" "),a("h5",{attrs:{id:"s-file-name-s-of-json-schema-s"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#s-file-name-s-of-json-schema-s"}},[e._v("#")]),e._v(" "),a("code",[e._v("-s")]),e._v(" - file name(s) of JSON-schema(s)")]),e._v(" "),a("p",[e._v("Multiple schemas can be passed both by using this parameter multiple times and with "),a("a",{attrs:{href:"https://github.com/isaacs/node-glob#glob-primer",target:"_blank",rel:"noopener noreferrer"}},[e._v("glob patterns"),a("OutboundLink")],1),e._v(".")]),e._v(" "),a("div",{staticClass:"language-sh extra-class"},[a("pre",{pre:!0,attrs:{class:"language-sh"}},[a("code",[e._v("ajv compile "),a("span",{pre:!0,attrs:{class:"token parameter variable"}},[e._v("-s")]),e._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[e._v('"test/schema*.json"')]),e._v("\n")])])]),a("h5",{attrs:{id:"o-output-file-for-compiled-validation-function-module"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#o-output-file-for-compiled-validation-function-module"}},[e._v("#")]),e._v(" "),a("code",[e._v("-o")]),e._v(" - output file for compiled validation function module")]),e._v(" "),a("p",[e._v("If multiple schemas are compiled with this option the module will have multiple exports named as schema $id's or as file names, otherwise the module will export validation function as default export.")]),e._v(" "),a("div",{staticClass:"language-sh extra-class"},[a("pre",{pre:!0,attrs:{class:"language-sh"}},[a("code",[e._v("ajv compile "),a("span",{pre:!0,attrs:{class:"token parameter variable"}},[e._v("-s")]),e._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[e._v('"schema.json"')]),e._v(" "),a("span",{pre:!0,attrs:{class:"token parameter variable"}},[e._v("-o")]),e._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[e._v('"validate_schema.js"')]),e._v("\n")])])]),a("p",[a("code",[e._v("-o")]),e._v(" without parameter should be used to output code to stdout to pass it to some code formatter.")]),e._v(" "),a("p",[e._v("This command also supports parameters "),a("code",[e._v("-r")]),e._v(", "),a("code",[e._v("-m")]),e._v(" and "),a("code",[e._v("-c")]),e._v(" as in "),a("a",{attrs:{href:"#validate-data"}},[e._v("validate")]),e._v(" command.")]),e._v(" "),a("h3",{attrs:{id:"migrate-schemas"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#migrate-schemas"}},[e._v("#")]),e._v(" Migrate schemas")]),e._v(" "),a("p",[e._v("This command validates and migrates schema from JSON Schema draft-04 to draft-07, draft-2019-09 or draft-2020-12 using "),a("a",{attrs:{href:"https://github.com/ajv-validator/json-schema-migrate",target:"_blank",rel:"noopener noreferrer"}},[e._v("json-schema-migrate"),a("OutboundLink")],1),e._v(" package.")]),e._v(" "),a("p",[e._v("The "),a("a",{attrs:{href:"#json-schema-version"}},[e._v("version of JSON Schema")]),e._v(" is determined by "),a("code",[e._v("--spec")]),e._v(" parameter (only "),a("code",[e._v('"draft7"')]),e._v(", "),a("code",[e._v('"draft2019"')]),e._v(" or "),a("code",[e._v('"draft2020"')]),e._v(").")]),e._v(" "),a("div",{staticClass:"language-sh extra-class"},[a("pre",{pre:!0,attrs:{class:"language-sh"}},[a("code",[e._v("ajv migrate "),a("span",{pre:!0,attrs:{class:"token parameter variable"}},[e._v("-s")]),e._v(" schema\n\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[e._v("# compile to specific file name")]),e._v("\najv migrate "),a("span",{pre:!0,attrs:{class:"token parameter variable"}},[e._v("-s")]),e._v(" schema "),a("span",{pre:!0,attrs:{class:"token parameter variable"}},[e._v("-o")]),e._v(" migrated_schema.json\n")])])]),a("h4",{attrs:{id:"parameters-3"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#parameters-3"}},[e._v("#")]),e._v(" Parameters")]),e._v(" "),a("h5",{attrs:{id:"s-file-name-s-of-json-schema-s-2"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#s-file-name-s-of-json-schema-s-2"}},[e._v("#")]),e._v(" "),a("code",[e._v("-s")]),e._v(" - file name(s) of JSON-schema(s)")]),e._v(" "),a("p",[e._v("Multiple schemas can be passed both by using this parameter multiple times and with "),a("a",{attrs:{href:"https://github.com/isaacs/node-glob#glob-primer",target:"_blank",rel:"noopener noreferrer"}},[e._v("glob patterns"),a("OutboundLink")],1),e._v(".")]),e._v(" "),a("div",{staticClass:"language-sh extra-class"},[a("pre",{pre:!0,attrs:{class:"language-sh"}},[a("code",[e._v("ajv migrate "),a("span",{pre:!0,attrs:{class:"token parameter variable"}},[e._v("-s")]),e._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[e._v('"test/schema*.json"')]),e._v("\n")])])]),a("p",[e._v("If parameter "),a("code",[e._v("-o")]),e._v(" is not specified the migrated schema is written to the same file and the original file is preserved with "),a("code",[e._v(".bak")]),e._v(" extension.")]),e._v(" "),a("p",[e._v("If migration doesn't change anything in the schema file no changes in files are made.")]),e._v(" "),a("h5",{attrs:{id:"o-output-file-for-migrated-schema"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#o-output-file-for-migrated-schema"}},[e._v("#")]),e._v(" "),a("code",[e._v("-o")]),e._v(" - output file for migrated schema")]),e._v(" "),a("p",[e._v("Only a single schema can be migrated with this option.")]),e._v(" "),a("div",{staticClass:"language-sh extra-class"},[a("pre",{pre:!0,attrs:{class:"language-sh"}},[a("code",[e._v("ajv compile "),a("span",{pre:!0,attrs:{class:"token parameter variable"}},[e._v("-s")]),e._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[e._v('"schema.json"')]),e._v(" "),a("span",{pre:!0,attrs:{class:"token parameter variable"}},[e._v("-o")]),e._v(" migrated_schema.json\n")])])]),a("h4",{attrs:{id:"options-2"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#options-2"}},[e._v("#")]),e._v(" Options")]),e._v(" "),a("ul",[a("li",[a("code",[e._v("--indent=")]),e._v(": indentation in migrated schema JSON file, 4 by default")]),e._v(" "),a("li",[a("code",[e._v("--validate-schema=false")]),e._v(": skip schema validation")])]),e._v(" "),a("h3",{attrs:{id:"test-validation-result"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#test-validation-result"}},[e._v("#")]),e._v(" Test validation result")]),e._v(" "),a("p",[e._v("This command asserts that the result of the validation is as expected.")]),e._v(" "),a("div",{staticClass:"language-sh extra-class"},[a("pre",{pre:!0,attrs:{class:"language-sh"}},[a("code",[e._v("ajv "),a("span",{pre:!0,attrs:{class:"token builtin class-name"}},[e._v("test")]),e._v(" "),a("span",{pre:!0,attrs:{class:"token parameter variable"}},[e._v("-s")]),e._v(" test/schema.json "),a("span",{pre:!0,attrs:{class:"token parameter variable"}},[e._v("-d")]),e._v(" test/valid_data.json "),a("span",{pre:!0,attrs:{class:"token parameter variable"}},[e._v("--valid")]),e._v("\najv "),a("span",{pre:!0,attrs:{class:"token builtin class-name"}},[e._v("test")]),e._v(" "),a("span",{pre:!0,attrs:{class:"token parameter variable"}},[e._v("-s")]),e._v(" test/schema.json "),a("span",{pre:!0,attrs:{class:"token parameter variable"}},[e._v("-d")]),e._v(" test/invalid_data.json "),a("span",{pre:!0,attrs:{class:"token parameter variable"}},[e._v("--invalid")]),e._v("\n")])])]),a("p",[e._v("If the option "),a("code",[e._v("--valid")]),e._v(" ("),a("code",[e._v("--invalid")]),e._v(") is used for the "),a("code",[e._v("test")]),e._v(" to pass (exit code 0) the data file(s) should be valid (invalid).")]),e._v(" "),a("p",[e._v("This command supports the same options and parameters as "),a("a",{attrs:{href:"#validate-data"}},[e._v("validate")]),e._v(" with the exception of "),a("code",[e._v("--changes")]),e._v(".")]),e._v(" "),a("h2",{attrs:{id:"ajv-options"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#ajv-options"}},[e._v("#")]),e._v(" Ajv options")]),e._v(" "),a("p",[e._v("You can pass the following "),a("a",{attrs:{href:"https://ajv.js.org/options.html",target:"_blank",rel:"noopener noreferrer"}},[e._v("Ajv options"),a("OutboundLink")],1),e._v(":")]),e._v(" "),a("table",[a("thead",[a("tr",[a("th",[e._v("Option")]),e._v(" "),a("th",[e._v("Description")])])]),e._v(" "),a("tbody",[a("tr",[a("td",[e._v("Strict mode")]),e._v(" "),a("td")]),e._v(" "),a("tr",[a("td",[a("code",[e._v("--strict=")])]),e._v(" "),a("td",[a("code",[e._v("true")]),e._v("/"),a("code",[e._v("false")]),e._v("/"),a("code",[e._v("log")]),e._v(" - set all "),a("a",{attrs:{href:"https://ajv.js.org/strict-mode.html",target:"_blank",rel:"noopener noreferrer"}},[e._v("strict mode"),a("OutboundLink")],1),e._v(" restrictions")])]),e._v(" "),a("tr",[a("td",[a("code",[e._v("--strict-schema=")])]),e._v(" "),a("td",[e._v("log on ("),a("code",[e._v("log")]),e._v(") or ignore ("),a("code",[e._v("false")]),e._v(") "),a("a",{attrs:{href:"https://ajv.js.org/strict-mode.html#prohibit-ignored-keywords",target:"_blank",rel:"noopener noreferrer"}},[e._v("strict "),a("OutboundLink")],1),e._v(" restrictions (the default is to log)")])]),e._v(" "),a("tr",[a("td",[a("code",[e._v("--strict-tuples=")])]),e._v(" "),a("td",[e._v("throw on ("),a("code",[e._v("true")]),e._v(") or ignore ("),a("code",[e._v("false")]),e._v(") "),a("a",{attrs:{href:"https://ajv.js.org/strict-mode.html#prohibit-unconstrained-tuples",target:"_blank",rel:"noopener noreferrer"}},[e._v("strict schema"),a("OutboundLink")],1),e._v(" restrictions (the default is to throw)")])]),e._v(" "),a("tr",[a("td",[a("code",[e._v("--strict-types=")])]),e._v(" "),a("td",[e._v("throw on ("),a("code",[e._v("true")]),e._v(") or ignore ("),a("code",[e._v("false")]),e._v(") "),a("a",{attrs:{href:"https://ajv.js.org/strict-mode.html#strict-types",target:"_blank",rel:"noopener noreferrer"}},[e._v("strict types"),a("OutboundLink")],1),e._v(" restrictions (the default is to log)")])]),e._v(" "),a("tr",[a("td",[a("code",[e._v("--strict-required=")])]),e._v(" "),a("td",[e._v("throw on ("),a("code",[e._v("true")]),e._v(") or log ("),a("code",[e._v("log")]),e._v(") "),a("a",{attrs:{href:"https://ajv.js.org/strict-mode.html#defined-required-properties",target:"_blank",rel:"noopener noreferrer"}},[e._v("required properties"),a("OutboundLink")],1),e._v(" restrictions (the default is to ignore)")])]),e._v(" "),a("tr",[a("td",[a("code",[e._v("--allow-matching-properties")])]),e._v(" "),a("td",[e._v("allow "),a("code",[e._v("properties")]),e._v(" "),a("a",{attrs:{href:"https://ajv.js.org/strict-mode.html#overlap-between-properties-and-patternproperties-keywords",target:"_blank",rel:"noopener noreferrer"}},[e._v("matching patterns"),a("OutboundLink")],1),e._v(" in "),a("code",[e._v("patternProperties")])])]),e._v(" "),a("tr",[a("td",[a("code",[e._v("--allow-union-types")])]),e._v(" "),a("td",[e._v("allow "),a("a",{attrs:{href:"https://ajv.js.org/strict-mode.html#union-types",target:"_blank",rel:"noopener noreferrer"}},[e._v("union types"),a("OutboundLink")],1)])]),e._v(" "),a("tr",[a("td",[a("code",[e._v("--validate-formats=false")])]),e._v(" "),a("td",[e._v("disable format validation")])]),e._v(" "),a("tr",[a("td",[e._v("Validation and reporting")]),e._v(" "),a("td")]),e._v(" "),a("tr",[a("td",[a("code",[e._v("--data")])]),e._v(" "),a("td",[e._v("use "),a("a",{attrs:{href:"https://ajv.js.org/guide/combining-schemas.html#data-reference",target:"_blank",rel:"noopener noreferrer"}},[e._v("$data references"),a("OutboundLink")],1)])]),e._v(" "),a("tr",[a("td",[a("code",[e._v("--all-errors")])]),e._v(" "),a("td",[e._v("collect all validation errors")])]),e._v(" "),a("tr",[a("td",[a("code",[e._v("--verbose")])]),e._v(" "),a("td",[e._v("include schema and data in errors")])]),e._v(" "),a("tr",[a("td",[a("code",[e._v("--comment")])]),e._v(" "),a("td",[e._v("log schema "),a("code",[e._v("$comment")]),e._v("s")])]),e._v(" "),a("tr",[a("td",[a("code",[e._v("--inline-refs=")])]),e._v(" "),a("td",[e._v("referenced schemas compilation mode (true/false/)")])]),e._v(" "),a("tr",[a("td",[e._v("Modify validated data")]),e._v(" "),a("td")]),e._v(" "),a("tr",[a("td",[a("code",[e._v("--remove-additional")])]),e._v(" "),a("td",[e._v("remove additional properties (true/all/failing)")])]),e._v(" "),a("tr",[a("td",[a("code",[e._v("--use-defaults")])]),e._v(" "),a("td",[e._v("replace missing properties/items with the values from default keyword")])]),e._v(" "),a("tr",[a("td",[a("code",[e._v("--coerce-types")])]),e._v(" "),a("td",[e._v("change type of data to match type keyword")])]),e._v(" "),a("tr",[a("td",[e._v("Advanced")]),e._v(" "),a("td")]),e._v(" "),a("tr",[a("td",[a("code",[e._v("--multiple-of-precision")])]),e._v(" "),a("td",[e._v("precision of multipleOf, pass integer number")])]),e._v(" "),a("tr",[a("td",[a("code",[e._v("--messages=false")])]),e._v(" "),a("td",[e._v("do not include text messages in errors")])]),e._v(" "),a("tr",[a("td",[a("code",[e._v("--loop-required=")])]),e._v(" "),a("td",[e._v("max size of "),a("code",[e._v("required")]),e._v(" to compile to expression (rather than to loop)")])]),e._v(" "),a("tr",[a("td",[a("code",[e._v("--loop-enum=")])]),e._v(" "),a("td",[e._v("max size of "),a("code",[e._v("enum")]),e._v(" to compile to expression (rather than to loop)")])]),e._v(" "),a("tr",[a("td",[a("code",[e._v("--own-properties")])]),e._v(" "),a("td",[e._v("only validate own properties (not relevant for JSON, but can have effect for JavaScript objects)")])]),e._v(" "),a("tr",[a("td",[e._v("Code generation")]),e._v(" "),a("td")]),e._v(" "),a("tr",[a("td",[a("code",[e._v("--code-es5")])]),e._v(" "),a("td",[e._v("generate ES5 code")])]),e._v(" "),a("tr",[a("td",[a("code",[e._v("--code-lines")])]),e._v(" "),a("td",[e._v("generate multi-line code")])]),e._v(" "),a("tr",[a("td",[a("code",[e._v("--code-optimize=")])]),e._v(" "),a("td",[e._v("disable optimization ("),a("code",[e._v("false")]),e._v(") or number of optimization passes (1 pass by default)")])]),e._v(" "),a("tr",[a("td",[a("code",[e._v("--code-formats=")])]),e._v(" "),a("td",[e._v("code to require formats object (only needed if you generate standalone code and do not use "),a("a",{attrs:{href:"https://github.com/ajv-validator/ajv-formats",target:"_blank",rel:"noopener noreferrer"}},[e._v("ajv-formats"),a("OutboundLink")],1),e._v(")")])])])]),e._v(" "),a("p",[e._v("Options can be passed using either dash-case or camelCase.")]),e._v(" "),a("p",[e._v("See "),a("a",{attrs:{href:"https://ajv.js.org/options.html",target:"_blank",rel:"noopener noreferrer"}},[e._v("Ajv Options"),a("OutboundLink")],1),e._v(" for more information.")]),e._v(" "),a("h2",{attrs:{id:"version-history"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#version-history"}},[e._v("#")]),e._v(" Version History")]),e._v(" "),a("p",[e._v("See https://github.com/ajv-validator/ajv-cli/releases")]),e._v(" "),a("h2",{attrs:{id:"licence"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#licence"}},[e._v("#")]),e._v(" Licence")]),e._v(" "),a("p",[a("a",{attrs:{href:"./LICENSE"}},[e._v("MIT")])])])}),[],!1,null,null,null);a.default=r.exports}}]); \ No newline at end of file diff --git a/assets/js/77.3790b98a.js b/assets/js/77.3790b98a.js new file mode 100644 index 000000000..6038c4dc6 --- /dev/null +++ b/assets/js/77.3790b98a.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[77],{507:function(t,s,a){"use strict";a.r(s);var r=a(14),e=Object(r.a)({},(function(){var t=this,s=t._self._c;return s("ContentSlotsDistributor",{attrs:{"slot-key":t.$parent.slotKey}},[s("p",[s("a",{attrs:{href:"https://github.com/ajv-validator/ajv-errors",target:"_blank",rel:"noopener noreferrer"}},[t._v("ajv-errors repository"),s("OutboundLink")],1)]),t._v(" "),s("h1",{attrs:{id:"ajv-errors"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#ajv-errors"}},[t._v("#")]),t._v(" ajv-errors")]),t._v(" "),s("p",[t._v("Custom error messages in JSON-Schema for Ajv validator")]),t._v(" "),s("p",[s("a",{attrs:{href:"https://github.com/ajv-validator/ajv-errors/actions?query=workflow%3Abuild",target:"_blank",rel:"noopener noreferrer"}},[s("img",{attrs:{src:"https://github.com/ajv-validator/ajv-errors/workflows/build/badge.svg",alt:"build"}}),s("OutboundLink")],1),t._v(" "),s("a",{attrs:{href:"https://www.npmjs.com/package/ajv-errors",target:"_blank",rel:"noopener noreferrer"}},[s("img",{attrs:{src:"https://img.shields.io/npm/v/ajv-errors.svg",alt:"npm"}}),s("OutboundLink")],1),t._v(" "),s("a",{attrs:{href:"https://coveralls.io/github/ajv-validator/ajv-errors?branch=master",target:"_blank",rel:"noopener noreferrer"}},[s("img",{attrs:{src:"https://coveralls.io/repos/github/ajv-validator/ajv-errors/badge.svg?branch=master",alt:"coverage"}}),s("OutboundLink")],1),t._v(" "),s("a",{attrs:{href:"https://gitter.im/ajv-validator/ajv",target:"_blank",rel:"noopener noreferrer"}},[s("img",{attrs:{src:"https://img.shields.io/gitter/room/ajv-validator/ajv.svg",alt:"gitter"}}),s("OutboundLink")],1)]),t._v(" "),s("p",[s("strong",[t._v("Please note")])]),t._v(" "),s("p",[t._v("ajv-errors v3 supports "),s("a",{attrs:{href:"https://github.com/ajv-validator/ajv",target:"_blank",rel:"noopener noreferrer"}},[t._v("ajv v8"),s("OutboundLink")],1),t._v(".")]),t._v(" "),s("p",[t._v("If you are using ajv v6, you should use "),s("a",{attrs:{href:"https://github.com/ajv-validator/ajv-errors/tree/v1",target:"_blank",rel:"noopener noreferrer"}},[t._v("ajv-errors v1"),s("OutboundLink")],1)]),t._v(" "),s("h2",{attrs:{id:"contents"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#contents"}},[t._v("#")]),t._v(" Contents")]),t._v(" "),s("ul",[s("li",[s("a",{attrs:{href:"#install"}},[t._v("Install")])]),t._v(" "),s("li",[s("a",{attrs:{href:"#usage"}},[t._v("Usage")]),t._v(" "),s("ul",[s("li",[s("a",{attrs:{href:"#single-message"}},[t._v("Single message")])]),t._v(" "),s("li",[s("a",{attrs:{href:"#messages-for-keywords"}},[t._v("Messages for keywords")])]),t._v(" "),s("li",[s("a",{attrs:{href:"#messages-for-properties-and-items"}},[t._v("Messages for properties and items")])]),t._v(" "),s("li",[s("a",{attrs:{href:"#default-message"}},[t._v("Default message")])])])]),t._v(" "),s("li",[s("a",{attrs:{href:"#templates"}},[t._v("Templates")])]),t._v(" "),s("li",[s("a",{attrs:{href:"#options"}},[t._v("Options")])]),t._v(" "),s("li",[s("a",{attrs:{href:"#supporters"}},[t._v("Supporters, Enterprise support, Security contact")])]),t._v(" "),s("li",[s("a",{attrs:{href:"#license"}},[t._v("License")])])]),t._v(" "),s("h2",{attrs:{id:"install"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#install"}},[t._v("#")]),t._v(" Install")]),t._v(" "),s("div",{staticClass:"language- extra-class"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[t._v("npm install ajv-errors\n")])])]),s("h2",{attrs:{id:"usage"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#usage"}},[t._v("#")]),t._v(" Usage")]),t._v(" "),s("p",[t._v("Add the keyword "),s("code",[t._v("errorMessages")]),t._v(" to Ajv instance:")]),t._v(" "),s("div",{staticClass:"language-javascript extra-class"},[s("pre",{pre:!0,attrs:{class:"language-javascript"}},[s("code",[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 function"}},[t._v("require")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token string"}},[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("default\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("{")]),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("allErrors")]),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("}")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// Ajv option allErrors is required")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("require")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"ajv-errors"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("ajv "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("/*, {singleError: true} */")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n")])])]),s("p",[t._v("See "),s("a",{attrs:{href:"#options"}},[t._v("Options")]),t._v(" below.")]),t._v(" "),s("h3",{attrs:{id:"single-message"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#single-message"}},[t._v("#")]),t._v(" Single message")]),t._v(" "),s("p",[t._v("Replace all errors in the current schema and subschemas with a single message:")]),t._v(" "),s("div",{staticClass:"language-javascript extra-class"},[s("pre",{pre:!0,attrs:{class:"language-javascript"}},[s("code",[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 "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[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('"object"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("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 "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("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 "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("foo")]),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 literal-property property"}},[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 "),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 literal-property property"}},[t._v("additionalProperties")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token boolean"}},[t._v("false")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("errorMessage")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"should be an object with an integer property foo only"')]),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 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("\nconsole"),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("validate")]),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 literal-property property"}},[t._v("foo")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"a"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("bar")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("2")]),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 comment"}},[t._v("// false")]),t._v("\nconsole"),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(" "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// processed errors")]),t._v("\n")])])]),s("p",[t._v("Processed errors:")]),t._v(" "),s("div",{staticClass:"language-json5 extra-class"},[s("pre",{pre:!0,attrs:{class:"language-json5"}},[s("code",[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 property unquoted"}},[t._v("keyword")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"errorMessage"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token property unquoted"}},[t._v("message")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"should be an object with an integer property foo only"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// ...")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token property unquoted"}},[t._v("params")]),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 property unquoted"}},[t._v("errors")]),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("{")]),s("span",{pre:!0,attrs:{class:"token property unquoted"}},[t._v("keyword")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"additionalProperties"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token property unquoted"}},[t._v("instancePath")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('""')]),t._v(" "),s("span",{pre:!0,attrs:{class:"token comment"}},[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 "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),s("span",{pre:!0,attrs:{class:"token property unquoted"}},[t._v("keyword")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"type"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token property unquoted"}},[t._v("instancePath")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('".foo"')]),t._v(" "),s("span",{pre:!0,attrs:{class:"token comment"}},[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 "),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("}")]),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("h3",{attrs:{id:"messages-for-keywords"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#messages-for-keywords"}},[t._v("#")]),t._v(" Messages for keywords")]),t._v(" "),s("p",[t._v("Replace errors for certain keywords in the current schema only:")]),t._v(" "),s("div",{staticClass:"language-javascript extra-class"},[s("pre",{pre:!0,attrs:{class:"language-javascript"}},[s("code",[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 "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[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('"object"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("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 "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("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 "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("foo")]),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 literal-property property"}},[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 "),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 literal-property property"}},[t._v("additionalProperties")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token boolean"}},[t._v("false")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("errorMessage")]),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 literal-property property"}},[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('"should be an object"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v('// will not replace internal "type" error for the property "foo"')]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("required")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"should have property foo"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("additionalProperties")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"should not have properties other than foo"')]),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\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("\nconsole"),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("validate")]),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 literal-property property"}},[t._v("foo")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"a"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("bar")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("2")]),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 comment"}},[t._v("// false")]),t._v("\nconsole"),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(" "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// processed errors")]),t._v("\n")])])]),s("p",[t._v("Processed errors:")]),t._v(" "),s("div",{staticClass:"language-json5 extra-class"},[s("pre",{pre:!0,attrs:{class:"language-json5"}},[s("code",[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 comment"}},[t._v("// original error")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token property unquoted"}},[t._v("keyword")]),s("span",{pre:!0,attrs:{class:"token operator"}},[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 property unquoted"}},[t._v("instancePath")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"/foo"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// ...")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token property unquoted"}},[t._v("message")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"should be integer"')]),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 "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// generated error")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token property unquoted"}},[t._v("keyword")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"errorMessage"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token property unquoted"}},[t._v("message")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"should not have properties other than foo"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// ...")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token property unquoted"}},[t._v("params")]),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 property unquoted"}},[t._v("errors")]),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 punctuation"}},[t._v("{")]),s("span",{pre:!0,attrs:{class:"token property unquoted"}},[t._v("keyword")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"additionalProperties"')]),t._v(" "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("/* , ... */")]),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("\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("}")]),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("p",[t._v('For keywords "required" and "dependencies" it is possible to specify different messages for different properties:')]),t._v(" "),s("div",{staticClass:"language-javascript extra-class"},[s("pre",{pre:!0,attrs:{class:"language-javascript"}},[s("code",[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 "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[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('"object"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("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(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"bar"')]),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 literal-property property"}},[t._v("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 "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("foo")]),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 literal-property property"}},[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 "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("bar")]),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 literal-property property"}},[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("}")]),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 literal-property property"}},[t._v("errorMessage")]),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 literal-property property"}},[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('"should be an object"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v('// will not replace internal "type" error for the property "foo"')]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("required")]),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 literal-property property"}},[t._v("foo")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v("'should have an integer property \"foo\"'")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("bar")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v("'should have a string property \"bar\"'")]),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("}")]),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("h3",{attrs:{id:"messages-for-properties-and-items"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#messages-for-properties-and-items"}},[t._v("#")]),t._v(" Messages for properties and items")]),t._v(" "),s("p",[t._v("Replace errors for properties / items (and deeper), regardless where in schema they were created:")]),t._v(" "),s("div",{staticClass:"language-javascript extra-class"},[s("pre",{pre:!0,attrs:{class:"language-javascript"}},[s("code",[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 "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[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('"object"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("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(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"bar"')]),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 literal-property property"}},[t._v("allOf")]),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 "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("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 "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("foo")]),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 literal-property property"}},[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(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("minimum")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("2")]),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 literal-property property"}},[t._v("bar")]),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 literal-property property"}},[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(" "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("minLength")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("2")]),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 literal-property property"}},[t._v("additionalProperties")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token boolean"}},[t._v("false")]),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("]")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("errorMessage")]),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 literal-property property"}},[t._v("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 "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("foo")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"data.foo should be integer >= 2"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("bar")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"data.bar should be string with length >= 2"')]),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("}")]),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 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("\nconsole"),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("validate")]),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 literal-property property"}},[t._v("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(" "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("bar")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"a"')]),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 comment"}},[t._v("// false")]),t._v("\nconsole"),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(" "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// processed errors")]),t._v("\n")])])]),s("p",[t._v("Processed errors:")]),t._v(" "),s("div",{staticClass:"language-json5 extra-class"},[s("pre",{pre:!0,attrs:{class:"language-json5"}},[s("code",[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 property unquoted"}},[t._v("keyword")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"errorMessage"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token property unquoted"}},[t._v("message")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"data.foo should be integer >= 2"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token property unquoted"}},[t._v("instancePath")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"/foo"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// ...")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token property unquoted"}},[t._v("params")]),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 property unquoted"}},[t._v("errors")]),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 punctuation"}},[t._v("{")]),s("span",{pre:!0,attrs:{class:"token property unquoted"}},[t._v("keyword")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"minimum"')]),t._v(" "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("/* , ... */")]),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("\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("}")]),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 property unquoted"}},[t._v("keyword")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"errorMessage"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token property unquoted"}},[t._v("message")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"data.bar should be string with length >= 2"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token property unquoted"}},[t._v("instancePath")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"/bar"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// ...")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token property unquoted"}},[t._v("params")]),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 property unquoted"}},[t._v("errors")]),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 punctuation"}},[t._v("{")]),s("span",{pre:!0,attrs:{class:"token property unquoted"}},[t._v("keyword")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"minLength"')]),t._v(" "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("/* , ... */")]),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("\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("}")]),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("h3",{attrs:{id:"default-message"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#default-message"}},[t._v("#")]),t._v(" Default message")]),t._v(" "),s("p",[t._v("When the value of keyword "),s("code",[t._v("errorMessage")]),t._v(" is an object you can specify a message that will be used if any error appears that is not specified by keywords/properties/items using "),s("code",[t._v("_")]),t._v(" property:")]),t._v(" "),s("div",{staticClass:"language-javascript extra-class"},[s("pre",{pre:!0,attrs:{class:"language-javascript"}},[s("code",[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 "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[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('"object"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("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(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"bar"')]),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 literal-property property"}},[t._v("allOf")]),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 "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("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 "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("foo")]),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 literal-property property"}},[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(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("minimum")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("2")]),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 literal-property property"}},[t._v("bar")]),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 literal-property property"}},[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(" "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("minLength")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("2")]),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 literal-property property"}},[t._v("additionalProperties")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token boolean"}},[t._v("false")]),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("]")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("errorMessage")]),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 literal-property property"}},[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('"data should be an object"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("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 "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("foo")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"data.foo should be integer >= 2"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("bar")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"data.bar should be string with length >= 2"')]),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 literal-property property"}},[t._v("_")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('\'data should have properties "foo" and "bar" only\'')]),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\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("\nconsole"),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("validate")]),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("}")]),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("// false")]),t._v("\nconsole"),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(" "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// processed errors")]),t._v("\n")])])]),s("p",[t._v("Processed errors:")]),t._v(" "),s("div",{staticClass:"language-json5 extra-class"},[s("pre",{pre:!0,attrs:{class:"language-json5"}},[s("code",[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 property unquoted"}},[t._v("keyword")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"errorMessage"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token property unquoted"}},[t._v("message")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('\'data should be an object with properties "foo" and "bar" only\'')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token property unquoted"}},[t._v("instancePath")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[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("// ...")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token property unquoted"}},[t._v("params")]),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 property unquoted"}},[t._v("errors")]),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 punctuation"}},[t._v("{")]),s("span",{pre:!0,attrs:{class:"token property unquoted"}},[t._v("keyword")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"required"')]),t._v(" "),s("span",{pre:!0,attrs:{class:"token comment"}},[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("{")]),s("span",{pre:!0,attrs:{class:"token property unquoted"}},[t._v("keyword")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"required"')]),t._v(" "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("/* , ... */")]),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("\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("}")]),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("p",[t._v("The message in property "),s("code",[t._v("_")]),t._v(" of "),s("code",[t._v("errorMessage")]),t._v(" replaces the same errors that would have been replaced if "),s("code",[t._v("errorMessage")]),t._v(" were a string.")]),t._v(" "),s("h2",{attrs:{id:"templates"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#templates"}},[t._v("#")]),t._v(" Templates")]),t._v(" "),s("p",[t._v("Custom error messages used in "),s("code",[t._v("errorMessage")]),t._v(" keyword can be templates using "),s("a",{attrs:{href:"https://tools.ietf.org/html/rfc6901",target:"_blank",rel:"noopener noreferrer"}},[t._v("JSON-pointers"),s("OutboundLink")],1),t._v(" or "),s("a",{attrs:{href:"http://tools.ietf.org/html/draft-luff-relative-json-pointer-00",target:"_blank",rel:"noopener noreferrer"}},[t._v("relative JSON-pointers"),s("OutboundLink")],1),t._v(" to data being validated, in which case the value will be interpolated. Also see "),s("a",{attrs:{href:"https://gist.github.com/geraintluff/5911303",target:"_blank",rel:"noopener noreferrer"}},[t._v("examples"),s("OutboundLink")],1),t._v(" of relative JSON-pointers.")]),t._v(" "),s("p",[t._v("The syntax to interpolate a value is "),s("code",[t._v("${}")]),t._v(".")]),t._v(" "),s("p",[t._v("The values used in messages will be JSON-stringified:")]),t._v(" "),s("ul",[s("li",[t._v("to differentiate between "),s("code",[t._v("false")]),t._v(" and "),s("code",[t._v('"false"')]),t._v(", etc.")]),t._v(" "),s("li",[t._v("to support structured values.")])]),t._v(" "),s("p",[t._v("Example:")]),t._v(" "),s("div",{staticClass:"language-javascript extra-class"},[s("pre",{pre:!0,attrs:{class:"language-javascript"}},[s("code",[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 "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[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('"object"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("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 "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("size")]),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 literal-property property"}},[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('"number"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("minimum")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("4")]),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("}")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("errorMessage")]),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 literal-property property"}},[t._v("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 "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("size")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"size should be a number bigger or equal to 4, current value is ${/size}"')]),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("}")]),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("h4",{attrs:{id:"using-property-names-in-error-messages"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#using-property-names-in-error-messages"}},[t._v("#")]),t._v(" Using property names in error messages")]),t._v(" "),s("p",[t._v("Property names can be used in error messages with the relative JSON-pointer (e.g. "),s("code",[t._v("0#")]),t._v(").")]),t._v(" "),s("p",[t._v("Example:")]),t._v(" "),s("div",{staticClass:"language-javascript extra-class"},[s("pre",{pre:!0,attrs:{class:"language-javascript"}},[s("code",[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 "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[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('"object"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("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 "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("size")]),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 literal-property property"}},[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('"number"')]),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("}")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("additionalProperties")]),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 literal-property property"}},[t._v("not")]),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 literal-property property"}},[t._v("errorMessage")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" “extra property is $"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("0")]),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"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])]),s("h2",{attrs:{id:"options"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#options"}},[t._v("#")]),t._v(" Options")]),t._v(" "),s("p",[t._v("Defaults:")]),t._v(" "),s("div",{staticClass:"language-json5 extra-class"},[s("pre",{pre:!0,attrs:{class:"language-json5"}},[s("code",[s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token property unquoted"}},[t._v("keepErrors")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token boolean"}},[t._v("false")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token property unquoted"}},[t._v("singleError")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token boolean"}},[t._v("false")]),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("ul",[s("li",[s("em",[t._v("keepErrors")]),t._v(": keep original errors. Default is to remove matched errors (they will still be available in "),s("code",[t._v("params.errors")]),t._v(" property of generated error). If an error was matched and included in the error generated by "),s("code",[t._v("errorMessage")]),t._v(" keyword it will have property "),s("code",[t._v("emUsed: true")]),t._v(".")]),t._v(" "),s("li",[s("em",[t._v("singleError")]),t._v(": create one error for all keywords used in "),s("code",[t._v("errorMessage")]),t._v(" keyword (error messages defined for properties and items are not merged because they have different instancePaths). Multiple error messages are concatenated. Option values:\n"),s("ul",[s("li",[s("code",[t._v("false")]),t._v(" (default): create multiple errors, one for each message")]),t._v(" "),s("li",[s("code",[t._v("true")]),t._v(": create single error, messages are concatenated using "),s("code",[t._v('"; "')])]),t._v(" "),s("li",[t._v("non-empty string: this string is used as a separator to concatenate messages")])])])]),t._v(" "),s("h2",{attrs:{id:"supporters"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#supporters"}},[t._v("#")]),t._v(" Supporters")]),t._v(" "),s("p",[s("a",{attrs:{href:"https://www.linkedin.com/in/rogerkepler/",target:"_blank",rel:"noopener noreferrer"}},[t._v("Roger Kepler"),s("OutboundLink")],1)]),t._v(" "),s("h2",{attrs:{id:"enterprise-support"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#enterprise-support"}},[t._v("#")]),t._v(" Enterprise support")]),t._v(" "),s("p",[t._v("ajv-errors package is a part of "),s("a",{attrs:{href:"https://tidelift.com/subscription/pkg/npm-ajv-errors?utm_source=npm-ajv-errors&utm_medium=referral&utm_campaign=enterprise&utm_term=repo",target:"_blank",rel:"noopener noreferrer"}},[t._v("Tidelift enterprise subscription"),s("OutboundLink")],1),t._v(" - it provides a centralised commercial support to open-source software users, in addition to the support provided by software maintainers.")]),t._v(" "),s("h2",{attrs:{id:"security-contact"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#security-contact"}},[t._v("#")]),t._v(" Security contact")]),t._v(" "),s("p",[t._v("To report a security vulnerability, please use the\n"),s("a",{attrs:{href:"https://tidelift.com/security",target:"_blank",rel:"noopener noreferrer"}},[t._v("Tidelift security contact"),s("OutboundLink")],1),t._v(".\nTidelift will coordinate the fix and disclosure. Please do NOT report security vulnerability via GitHub issues.")]),t._v(" "),s("h2",{attrs:{id:"license"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#license"}},[t._v("#")]),t._v(" License")]),t._v(" "),s("p",[s("a",{attrs:{href:"https://github.com/epoberezkin/ajv-errors/blob/master/LICENSE",target:"_blank",rel:"noopener noreferrer"}},[t._v("MIT"),s("OutboundLink")],1)])])}),[],!1,null,null,null);s.default=e.exports}}]); \ No newline at end of file diff --git a/assets/js/78.671a8b82.js b/assets/js/78.671a8b82.js new file mode 100644 index 000000000..54ca4919b --- /dev/null +++ b/assets/js/78.671a8b82.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[78],{510: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/79.b4aa6074.js b/assets/js/79.b4aa6074.js new file mode 100644 index 000000000..07f8a019b --- /dev/null +++ b/assets/js/79.b4aa6074.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[79],{508:function(t,e,a){"use strict";a.r(e);var r=a(14),n=Object(r.a)({},(function(){var t=this,e=t._self._c;return e("ContentSlotsDistributor",{attrs:{"slot-key":t.$parent.slotKey}},[e("p",[e("a",{attrs:{href:"https://github.com/ajv-validator/ajv-i18n",target:"_blank",rel:"noopener noreferrer"}},[t._v("ajv-i18n repository"),e("OutboundLink")],1)]),t._v(" "),e("h1",{attrs:{id:"ajv-i18n"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#ajv-i18n"}},[t._v("#")]),t._v(" ajv-i18n")]),t._v(" "),e("p",[t._v("Internationalised error messages for "),e("a",{attrs:{href:"https://github.com/ajv-validator/ajv",target:"_blank",rel:"noopener noreferrer"}},[t._v("Ajv"),e("OutboundLink")],1),t._v(" - superfast JSON validator for JSON Schema and JSON Type Definition.")]),t._v(" "),e("p",[e("a",{attrs:{href:"https://travis-ci.org/ajv-validator/ajv-i18n",target:"_blank",rel:"noopener noreferrer"}},[e("img",{attrs:{src:"https://travis-ci.org/ajv-validator/ajv-i18n.svg?branch=master",alt:"Build Status"}}),e("OutboundLink")],1),t._v(" "),e("a",{attrs:{href:"https://www.npmjs.com/package/ajv-i18n",target:"_blank",rel:"noopener noreferrer"}},[e("img",{attrs:{src:"https://img.shields.io/npm/v/ajv-i18n.svg",alt:"npm"}}),e("OutboundLink")],1),t._v(" "),e("a",{attrs:{href:"https://coveralls.io/github/ajv-validator/ajv-i18n?branch=master",target:"_blank",rel:"noopener noreferrer"}},[e("img",{attrs:{src:"https://coveralls.io/repos/github/ajv-validator/ajv-i18n/badge.svg?branch=master",alt:"Coverage Status"}}),e("OutboundLink")],1),t._v(" "),e("a",{attrs:{href:"https://gitter.im/ajv-validator/ajv",target:"_blank",rel:"noopener noreferrer"}},[e("img",{attrs:{src:"https://img.shields.io/gitter/room/ajv-validator/ajv.svg",alt:"Gitter"}}),e("OutboundLink")],1)]),t._v(" "),e("h2",{attrs:{id:"supported-locales"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#supported-locales"}},[t._v("#")]),t._v(" Supported locales")]),t._v(" "),e("table",[e("thead",[e("tr",[e("th",[t._v("locale")]),t._v(" "),e("th",{staticStyle:{"text-align":"center"}},[t._v("language")]),t._v(" "),e("th",{staticStyle:{"text-align":"center"}},[t._v("contributor")]),t._v(" "),e("th",{staticStyle:{"text-align":"center"}},[t._v("draft-04")]),t._v(" "),e("th",{staticStyle:{"text-align":"center"}},[t._v("draft-06"),e("sup",[t._v("1")])]),t._v(" "),e("th",{staticStyle:{"text-align":"center"}},[t._v("draft-07"),e("sup",[t._v("2")])]),t._v(" "),e("th",{staticStyle:{"text-align":"center"}},[t._v("draft"),e("br"),t._v("2019-09"),e("sup",[t._v("3")]),e("br"),t._v("/2020-12"),e("sup",[t._v("4")])]),t._v(" "),e("th",{staticStyle:{"text-align":"center"}},[t._v("JTD"),e("sup",[t._v("5")])])])]),t._v(" "),e("tbody",[e("tr",[e("td",[t._v("🇬🇧 en")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("English")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}}),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("✓")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("✓")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("✓")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("✓")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("✓")])]),t._v(" "),e("tr",[e("td",[t._v("AR ar")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("Arabic")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[e("a",{attrs:{href:"https://github.com/Mahmoud-Mardeni",target:"_blank",rel:"noopener noreferrer"}},[t._v("Mahmoud-Mardeni"),e("OutboundLink")],1)]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("✓")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("✓")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("✓")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("-")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("-")])]),t._v(" "),e("tr",[e("td",[t._v("CA ca")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("Catalan")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[e("a",{attrs:{href:"https://github.com/alexandreec",target:"_blank",rel:"noopener noreferrer"}},[t._v("alexandreec"),e("OutboundLink")],1)]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("✓")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("✓")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("✓")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("-")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("*")])]),t._v(" "),e("tr",[e("td",[t._v("🇨🇿 cs")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("Czech")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[e("a",{attrs:{href:"https://github.com/kiskovacs",target:"_blank",rel:"noopener noreferrer"}},[t._v("kiskovacs"),e("OutboundLink")],1),e("br"),e("a",{attrs:{href:"https://github.com/NAM0007",target:"_blank",rel:"noopener noreferrer"}},[t._v("NAM0007"),e("OutboundLink")],1)]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("✓"),e("br")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("✓"),e("br")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[e("br"),t._v("✓")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("-")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("*")])]),t._v(" "),e("tr",[e("td",[t._v("🇩🇪 de")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("German")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[e("a",{attrs:{href:"https://github.com/jmtoball",target:"_blank",rel:"noopener noreferrer"}},[t._v("jmtoball"),e("OutboundLink")],1),e("br"),e("a",{attrs:{href:"https://github.com/gflohr",target:"_blank",rel:"noopener noreferrer"}},[t._v("gflohr"),e("OutboundLink")],1)]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("✓"),e("br")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("✓"),e("br")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[e("br"),t._v("✓")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("✓"),e("br")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("✓"),e("br")])]),t._v(" "),e("tr",[e("td",[t._v("🇪🇸 es")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("Spanish")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[e("a",{attrs:{href:"https://github.com/jpablom",target:"_blank",rel:"noopener noreferrer"}},[t._v("jpablom"),e("OutboundLink")],1)]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("✓")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("✓")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("✓")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("-")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("*")])]),t._v(" "),e("tr",[e("td",[t._v("🇫🇮 fi")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("Finnish")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[e("a",{attrs:{href:"https://github.com/saulipurhonen",target:"_blank",rel:"noopener noreferrer"}},[t._v("saulipurhonen"),e("OutboundLink")],1)]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("✓")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("✓")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("✓")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("✓")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("✓")])]),t._v(" "),e("tr",[e("td",[t._v("🇫🇷 fr")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("French")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[e("a",{attrs:{href:"https://github.com/monlouisj",target:"_blank",rel:"noopener noreferrer"}},[t._v("monlouisj"),e("OutboundLink")],1),e("br"),e("a",{attrs:{href:"https://github.com/Telokis",target:"_blank",rel:"noopener noreferrer"}},[t._v("Telokis"),e("OutboundLink")],1)]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("✓"),e("br")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("✓"),e("br")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[e("br"),t._v("✓")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("-")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("*")])]),t._v(" "),e("tr",[e("td",[t._v("🇭🇺 hu")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("Hungarian")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[e("a",{attrs:{href:"https://github.com/szilveszter9",target:"_blank",rel:"noopener noreferrer"}},[t._v("szilveszter9"),e("OutboundLink")],1)]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("✓")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("-")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("-")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("-")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("*")])]),t._v(" "),e("tr",[e("td",[t._v("🇮🇩 id")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("Indonesian")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[e("a",{attrs:{href:"https://github.com/ekoeryanto",target:"_blank",rel:"noopener noreferrer"}},[t._v("ekoeryanto"),e("OutboundLink")],1)]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("✓")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("✓")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("✓")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("-")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("*")])]),t._v(" "),e("tr",[e("td",[t._v("🇮🇹 it")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("Italian")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[e("a",{attrs:{href:"https://github.com/jasoniangreen",target:"_blank",rel:"noopener noreferrer"}},[t._v("jasoniangreen"),e("OutboundLink")],1),e("br"),e("a",{attrs:{href:"https://github.com/lucacorti",target:"_blank",rel:"noopener noreferrer"}},[t._v("lucacorti"),e("OutboundLink")],1)]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("✓"),e("br")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[e("br"),t._v("✓")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[e("br"),t._v("✓")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[e("br"),t._v("✓")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[e("br"),t._v("✓")])]),t._v(" "),e("tr",[e("td",[t._v("🇯🇵 ja")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("Japanese")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[e("a",{attrs:{href:"https://github.com/gilgongo",target:"_blank",rel:"noopener noreferrer"}},[t._v("gilgongo"),e("OutboundLink")],1)]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("✓")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("-")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("-")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("-")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("*")])]),t._v(" "),e("tr",[e("td",[t._v("🇰🇷 ko")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("Korean")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[e("a",{attrs:{href:"https://github.com/MinByeongDon",target:"_blank",rel:"noopener noreferrer"}},[t._v("MinByeongDon"),e("OutboundLink")],1)]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("✓")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("✓")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("✓")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("✓")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("✓")])]),t._v(" "),e("tr",[e("td",[t._v("🇳🇴 nb")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("Norwegian bokmål")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[e("a",{attrs:{href:"https://github.com/mtramm",target:"_blank",rel:"noopener noreferrer"}},[t._v("mtramm"),e("OutboundLink")],1)]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("✓")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("✓")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("-")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("-")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("*")])]),t._v(" "),e("tr",[e("td",[t._v("🇳🇱 nl")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("Dutch")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[e("a",{attrs:{href:"https://github.com/pimlie",target:"_blank",rel:"noopener noreferrer"}},[t._v("pimlie"),e("OutboundLink")],1),e("br"),e("a",{attrs:{href:"https://github.com/niekvb",target:"_blank",rel:"noopener noreferrer"}},[t._v("niekvb"),e("OutboundLink")],1)]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("✓")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("✓")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("✓")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[e("br"),t._v("✓")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[e("br"),t._v("✓")])]),t._v(" "),e("tr",[e("td",[t._v("🇵🇱 pl")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("Polish")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[e("a",{attrs:{href:"https://github.com/danielzurawski",target:"_blank",rel:"noopener noreferrer"}},[t._v("danielzurawski"),e("OutboundLink")],1)]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("✓")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("-")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("-")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("-")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("*")])]),t._v(" "),e("tr",[e("td",[t._v("🇧🇷 pt-BR")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("Português - Brasil")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[e("a",{attrs:{href:"https://github.com/marcosrava",target:"_blank",rel:"noopener noreferrer"}},[t._v("marcosrava"),e("OutboundLink")],1),e("br"),e("a",{attrs:{href:"https://github.com/ggondim",target:"_blank",rel:"noopener noreferrer"}},[t._v("ggondim"),e("OutboundLink")],1)]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("✓")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("✓")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("✓")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[e("br"),t._v("✓")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[e("br"),t._v("✓")])]),t._v(" "),e("tr",[e("td",[t._v("🇷🇺 ru")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("Russian")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}}),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("✓")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("✓")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("✓")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("✓")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("✓")])]),t._v(" "),e("tr",[e("td",[t._v("🇸🇰 sk")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("Slovak")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[e("a",{attrs:{href:"https://github.com/kiskovacs",target:"_blank",rel:"noopener noreferrer"}},[t._v("kiskovacs"),e("OutboundLink")],1)]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("✓")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("✓")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("-")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("-")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("*")])]),t._v(" "),e("tr",[e("td",[t._v("🇸🇪 sv")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("Swedish")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[e("a",{attrs:{href:"https://github.com/Limmen",target:"_blank",rel:"noopener noreferrer"}},[t._v("limmen"),e("OutboundLink")],1)]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("✓")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("✓")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("-")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("-")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("*")])]),t._v(" "),e("tr",[e("td",[t._v("🇹🇭 th")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("Thai")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[e("a",{attrs:{href:"https://github.com/encX",target:"_blank",rel:"noopener noreferrer"}},[t._v("encX"),e("OutboundLink")],1)]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("✓")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("✓")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("✓")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("✓")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("✓")])]),t._v(" "),e("tr",[e("td",[t._v("🇨🇳 zh")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("Chinese")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[e("a",{attrs:{href:"https://github.com/jinzhubaofu",target:"_blank",rel:"noopener noreferrer"}},[t._v("jinzhubaofu"),e("OutboundLink")],1),e("br"),e("a",{attrs:{href:"https://github.com/leuction",target:"_blank",rel:"noopener noreferrer"}},[t._v("leuction"),e("OutboundLink")],1)]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("✓"),e("br")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[e("br"),t._v("✓")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[e("br"),t._v("✓")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[e("br"),t._v("✓")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[e("br"),t._v("✓")])]),t._v(" "),e("tr",[e("td",[t._v("🇹🇼 zh-TW")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("Chinese - Taiwan")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[e("a",{attrs:{href:"https://github.com/minipai",target:"_blank",rel:"noopener noreferrer"}},[t._v("minipai"),e("OutboundLink")],1)]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("✓")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("✓")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("✓")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("✓")]),t._v(" "),e("td",{staticStyle:{"text-align":"center"}},[t._v("✓")])])])]),t._v(" "),e("p",[e("sup",[t._v("1")]),t._v(" added boolean schema, keywords "),e("code",[t._v("const")]),t._v(", "),e("code",[t._v("contains")]),t._v(", "),e("code",[t._v("propertyNames")])]),t._v(" "),e("p",[e("sup",[t._v("2")]),t._v(" added keywords "),e("code",[t._v("if")]),t._v("/"),e("code",[t._v("then")]),t._v("/"),e("code",[t._v("else")])]),t._v(" "),e("p",[e("sup",[t._v("3")]),t._v(" added messages for keywords "),e("code",[t._v("unevaluatedProperties")]),t._v(", "),e("code",[t._v("unevaluatedItems")]),t._v(", "),e("code",[t._v("dependentRequired")])]),t._v(" "),e("p",[e("sup",[t._v("4")]),t._v(" keyword "),e("code",[t._v("items")]),t._v(" messages")]),t._v(" "),e("p",[e("sup",[t._v("5")]),t._v(" JSON Type Definition")]),t._v(" "),e("p",[t._v("* "),e("code",[t._v("discriminator")]),t._v(" form messages are not translated")]),t._v(" "),e("p",[t._v("Please contribute locales that you need to use if they are missing or incomplete.")]),t._v(" "),e("h2",{attrs:{id:"install"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#install"}},[t._v("#")]),t._v(" Install")]),t._v(" "),e("p",[t._v("Using npm:")]),t._v(" "),e("div",{staticClass:"language- extra-class"},[e("pre",{pre:!0,attrs:{class:"language-text"}},[e("code",[t._v("npm install ajv-i18n\n")])])]),e("h2",{attrs:{id:"usage"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#usage"}},[t._v("#")]),t._v(" Usage")]),t._v(" "),e("p",[t._v("In node:")]),t._v(" "),e("div",{staticClass:"language-javascript extra-class"},[e("pre",{pre:!0,attrs:{class:"language-javascript"}},[e("code",[e("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" Ajv "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token function"}},[t._v("require")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),e("span",{pre:!0,attrs:{class:"token string"}},[t._v('"ajv"')]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// version >= 8.0.0")]),t._v("\n"),e("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" localize "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token function"}},[t._v("require")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),e("span",{pre:!0,attrs:{class:"token string"}},[t._v('"ajv-i18n"')]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n"),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// or for JSON Type Definition")]),t._v("\n"),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v('// const localize = require("ajv-i18n/localize/jtd")')]),t._v("\n\n"),e("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" ajv "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token function"}},[t._v("Ajv")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),e("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("allErrors")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token boolean"}},[t._v("true")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("messages")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token boolean"}},[t._v("false")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n"),e("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" validate "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" ajv"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),e("span",{pre:!0,attrs:{class:"token function"}},[t._v("compile")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("schema"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n"),e("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" valid "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token function"}},[t._v("validate")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("data"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n\n"),e("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("if")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("!")]),t._v("valid"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// ru for Russian")]),t._v("\n localize"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),e("span",{pre:!0,attrs:{class:"token function"}},[t._v("ru")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("validate"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("errors"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// string with all errors and data paths")]),t._v("\n console"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),e("span",{pre:!0,attrs:{class:"token function"}},[t._v("log")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("ajv"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),e("span",{pre:!0,attrs:{class:"token function"}},[t._v("errorsText")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("validate"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("errors"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),e("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("separator")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token string"}},[t._v("'\\n'")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])]),e("p",[t._v("To require only necessary locales (e.g., with browserify):")]),t._v(" "),e("div",{staticClass:"language-javascript extra-class"},[e("pre",{pre:!0,attrs:{class:"language-javascript"}},[e("code",[e("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" localize_ru "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token function"}},[t._v("require")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),e("span",{pre:!0,attrs:{class:"token string"}},[t._v("'ajv-i18n/localize/ru'")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n"),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// or for JSON Type Definition")]),t._v("\n"),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// const localize_ru = require('ajv-i18n/localize/ru/jtd')")]),t._v("\n")])])]),e("p",[t._v("or")]),t._v(" "),e("div",{staticClass:"language-javascript extra-class"},[e("pre",{pre:!0,attrs:{class:"language-javascript"}},[e("code",[e("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" localize "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("en")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token function"}},[t._v("require")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),e("span",{pre:!0,attrs:{class:"token string"}},[t._v("'ajv-i18n/localize/en'")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("ru")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token function"}},[t._v("require")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),e("span",{pre:!0,attrs:{class:"token string"}},[t._v("'ajv-i18n/localize/ru'")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])]),e("p",[t._v("See "),e("a",{attrs:{href:"https://github.com/ajv-validator/ajv",target:"_blank",rel:"noopener noreferrer"}},[t._v("Ajv docs"),e("OutboundLink")],1),t._v(" for more information.")]),t._v(" "),e("h2",{attrs:{id:"tests"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#tests"}},[t._v("#")]),t._v(" Tests")]),t._v(" "),e("div",{staticClass:"language- extra-class"},[e("pre",{pre:!0,attrs:{class:"language-text"}},[e("code",[t._v("npm install\ngit submodule update --init\nnpm test\n")])])]),e("h2",{attrs:{id:"contributing"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#contributing"}},[t._v("#")]),t._v(" Contributing")]),t._v(" "),e("p",[t._v("Functions that localize error messages are generated using doT template "),e("a",{attrs:{href:"https://github.com/ajv-validator/ajv-i18n/tree/master/localize/localize.jst",target:"_blank",rel:"noopener noreferrer"}},[t._v("localize.jst"),e("OutboundLink")],1),t._v(", "),e("a",{attrs:{href:"https://github.com/ajv-validator/ajv-i18n/tree/master/messages/index.js",target:"_blank",rel:"noopener noreferrer"}},[t._v("JSON Schema messages"),e("OutboundLink")],1),t._v(" and "),e("a",{attrs:{href:"https://github.com/ajv-validator/ajv-i18n/tree/master/messages/jtd.js",target:"_blank",rel:"noopener noreferrer"}},[t._v("JSON Type Definition messages"),e("OutboundLink")],1),t._v(". Templates are pre-compiled, so doT is not a run-time dependency.")]),t._v(" "),e("p",[e("code",[t._v("npm run build")]),t._v(" - compiles functions to "),e("a",{attrs:{href:"https://github.com/ajv-validator/ajv/tree/master/localize",target:"_blank",rel:"noopener noreferrer"}},[t._v("localize"),e("OutboundLink")],1),t._v(" folder.")]),t._v(" "),e("h2",{attrs:{id:"contributors-of-locales"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#contributors-of-locales"}},[t._v("#")]),t._v(" Contributors of locales")]),t._v(" "),e("p",[e("a",{attrs:{href:"https://github.com/danielzurawski",title:"danielzurawski",target:"_blank",rel:"noopener noreferrer"}},[e("img",{attrs:{src:"https://avatars3.githubusercontent.com/u/1625711?v=3&s=40",alt:"danielzurawski"}}),e("OutboundLink")],1),t._v(" "),e("a",{attrs:{href:"https://github.com/szilveszter9",title:"szilveszter9",target:"_blank",rel:"noopener noreferrer"}},[e("img",{attrs:{src:"https://avatars0.githubusercontent.com/u/7540866?v=3&s=40",alt:"szilveszter9"}}),e("OutboundLink")],1),t._v(" "),e("a",{attrs:{href:"https://github.com/jmtoball",title:"jmtoball",target:"_blank",rel:"noopener noreferrer"}},[e("img",{attrs:{src:"https://avatars0.githubusercontent.com/u/219950?v=3&s=40",alt:"jmtoball"}}),e("OutboundLink")],1),t._v(" "),e("a",{attrs:{href:"https://github.com/gilgongo",title:"gilgongo",target:"_blank",rel:"noopener noreferrer"}},[e("img",{attrs:{src:"https://avatars2.githubusercontent.com/u/4561747?v=3&s=40",alt:"gilgongo"}}),e("OutboundLink")],1),t._v(" "),e("a",{attrs:{href:"https://github.com/jasoniangreen",title:"jasoniangreen",target:"_blank",rel:"noopener noreferrer"}},[e("img",{attrs:{src:"https://avatars3.githubusercontent.com/u/3481367?v=3&s=40",alt:"jasoniangreen"}}),e("OutboundLink")],1),t._v(" "),e("a",{attrs:{href:"https://github.com/jpablom",title:"jpablom",target:"_blank",rel:"noopener noreferrer"}},[e("img",{attrs:{src:"https://avatars0.githubusercontent.com/u/3935083?v=3&s=40",alt:"jpablom"}}),e("OutboundLink")],1),t._v(" "),e("a",{attrs:{href:"https://github.com/Limmen",title:"Limmen",target:"_blank",rel:"noopener noreferrer"}},[e("img",{attrs:{src:"https://avatars2.githubusercontent.com/u/8254791?v=3&s=40",alt:"limmen"}}),e("OutboundLink")],1),t._v(" "),e("a",{attrs:{href:"https://github.com/jinzhubaofu",title:"jinzhubaofu",target:"_blank",rel:"noopener noreferrer"}},[e("img",{attrs:{src:"https://avatars2.githubusercontent.com/u/811195?v=3&s=40",alt:"jinzhubaofu"}}),e("OutboundLink")],1),t._v(" "),e("a",{attrs:{href:"https://github.com/kiskovacs",title:"kiskovacs",target:"_blank",rel:"noopener noreferrer"}},[e("img",{attrs:{src:"https://avatars1.githubusercontent.com/u/2733311?v=3&s=40",alt:"kiskovacs"}}),e("OutboundLink")],1),t._v(" "),e("a",{attrs:{href:"https://github.com/Mahmoud-Mardeni",title:"mahmoud-mardeni",target:"_blank",rel:"noopener noreferrer"}},[e("img",{attrs:{src:"https://avatars2.githubusercontent.com/u/19661270?s=40&v=3",alt:"mahmoud-mardeni"}}),e("OutboundLink")],1),t._v(" "),e("a",{attrs:{href:"https://github.com/monlouisj",title:"monlouisj",target:"_blank",rel:"noopener noreferrer"}},[e("img",{attrs:{src:"https://avatars0.githubusercontent.com/u/5998380?v=3&s=40",alt:"monlouisj"}}),e("OutboundLink")],1),t._v(" "),e("a",{attrs:{href:"https://github.com/marcosrava",title:"marcosrava",target:"_blank",rel:"noopener noreferrer"}},[e("img",{attrs:{src:"https://avatars2.githubusercontent.com/u/243790?v=3&s=40",alt:"marcosrava"}}),e("OutboundLink")],1),t._v(" "),e("a",{attrs:{href:"https://github.com/mtramm",title:"mtramm",target:"_blank",rel:"noopener noreferrer"}},[e("img",{attrs:{src:"https://avatars3.githubusercontent.com/u/3519541?v=3&s=40",alt:"mtramm"}}),e("OutboundLink")],1),t._v(" "),e("a",{attrs:{href:"https://github.com/Mahmoud-Mardeni",title:"Mahmoud-Mardeni",target:"_blank",rel:"noopener noreferrer"}},[e("img",{attrs:{src:"https://avatars3.githubusercontent.com/u/19661270?v=3&s=40",alt:"Mahmoud-Mardeni"}}),e("OutboundLink")],1),t._v(" "),e("a",{attrs:{href:"https://github.com/leuction",title:"leuction",target:"_blank",rel:"noopener noreferrer"}},[e("img",{attrs:{src:"https://avatars3.githubusercontent.com/u/8056270?v=3&s=40",alt:"leuction"}}),e("OutboundLink")],1),t._v(" "),e("a",{attrs:{href:"https://github.com/lucacorti",title:"lucacorti",target:"_blank",rel:"noopener noreferrer"}},[e("img",{attrs:{src:"https://avatars2.githubusercontent.com/u/1076999?v=3&s=40",alt:"lucacorti"}}),e("OutboundLink")],1),t._v(" "),e("a",{attrs:{href:"https://github.com/minipai",title:"minipai",target:"_blank",rel:"noopener noreferrer"}},[e("img",{attrs:{src:"https://avatars2.githubusercontent.com/u/239570?s=40&v=4",alt:"minipai"}}),e("OutboundLink")],1),t._v(" "),e("a",{attrs:{href:"https://github.com/encX",title:"encX",target:"_blank",rel:"noopener noreferrer"}},[e("img",{attrs:{src:"https://avatars3.githubusercontent.com/u/5965883?v=3&s=40",alt:"encX"}}),e("OutboundLink")],1),t._v(" "),e("a",{attrs:{href:"https://github.com/pimlie",title:"pimlie",target:"_blank",rel:"noopener noreferrer"}},[e("img",{attrs:{src:"https://avatars3.githubusercontent.com/u/1067403?s=40&v=4",alt:"pimlie",width:"40px"}}),e("OutboundLink")],1),t._v(" "),e("a",{attrs:{href:"https://github.com/MinByeongDon",title:"MinByeongDon",target:"_blank",rel:"noopener noreferrer"}},[e("img",{attrs:{src:"https://avatars2.githubusercontent.com/u/6141807?s=40&v=4",alt:"MinByeongDon"}}),e("OutboundLink")],1),t._v(" "),e("a",{attrs:{href:"https://github.com/gflohr",title:"gflohr",target:"_blank",rel:"noopener noreferrer"}},[e("img",{attrs:{src:"https://avatars0.githubusercontent.com/u/7126580?s=40&v=4",alt:"gflohr"}}),e("OutboundLink")],1),t._v(" "),e("a",{attrs:{href:"https://github.com/ekoeryanto",title:"ekoeryanto",target:"_blank",rel:"noopener noreferrer"}},[e("img",{attrs:{src:"https://avatars2.githubusercontent.com/u/36023898?s=40&v=4",alt:"ekoeryanto"}}),e("OutboundLink")],1),t._v(" "),e("a",{attrs:{href:"https://github.com/Telokis",title:"Telokis",target:"_blank",rel:"noopener noreferrer"}},[e("img",{attrs:{src:"https://avatars3.githubusercontent.com/u/6382729?s=40&v=4",alt:"Telokis"}}),e("OutboundLink")],1),t._v(" "),e("a",{attrs:{href:"https://github.com/alexandreec",title:"alexandreec",target:"_blank",rel:"noopener noreferrer"}},[e("img",{attrs:{src:"https://avatars3.githubusercontent.com/u/15526814?s=40&v=4",alt:"alexandreec",width:"40px"}}),e("OutboundLink")],1),t._v(" "),e("a",{attrs:{href:"https://github.com/ggondim",title:"ggondim",target:"_blank",rel:"noopener noreferrer"}},[e("img",{attrs:{src:"https://avatars2.githubusercontent.com/u/2074685?s=40&v=4",alt:"ggondim"}}),e("OutboundLink")],1),t._v(" "),e("a",{attrs:{href:"https://github.com/niekvb",title:"niekvb",target:"_blank",rel:"noopener noreferrer"}},[e("img",{attrs:{src:"https://avatars3.githubusercontent.com/u/37668320?s=40&v=4",alt:"niekvb"}}),e("OutboundLink")],1),t._v(" "),e("a",{attrs:{href:"https://github.com/NAM0007",title:"NAM0007",target:"_blank",rel:"noopener noreferrer"}},[e("img",{attrs:{src:"https://avatars1.githubusercontent.com/u/47188486?s=40&v=4",alt:"NAM0007"}}),e("OutboundLink")],1),t._v(" "),e("a",{attrs:{href:"https://github.com/saulipurhonen",title:"saulipurhonen",target:"_blank",rel:"noopener noreferrer"}},[e("img",{attrs:{src:"https://avatars.githubusercontent.com/u/48789543?s=40&v=4",alt:"saulipurhonen"}}),e("OutboundLink")],1)]),t._v(" "),e("h2",{attrs:{id:"enterprise-support"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#enterprise-support"}},[t._v("#")]),t._v(" Enterprise support")]),t._v(" "),e("p",[t._v("ajv-i18n package is a part of "),e("a",{attrs:{href:"https://tidelift.com/subscription/pkg/npm-ajv-i18n?utm_source=npm-ajv-i18n&utm_medium=referral&utm_campaign=enterprise&utm_term=repo",target:"_blank",rel:"noopener noreferrer"}},[t._v("Tidelift enterprise subscription"),e("OutboundLink")],1),t._v(" - it provides a centralised commercial support to open-source software users, in addition to the support provided by software maintainers.")]),t._v(" "),e("h2",{attrs:{id:"security-contact"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#security-contact"}},[t._v("#")]),t._v(" Security contact")]),t._v(" "),e("p",[t._v("To report a security vulnerability, please use the\n"),e("a",{attrs:{href:"https://tidelift.com/security",target:"_blank",rel:"noopener noreferrer"}},[t._v("Tidelift security contact"),e("OutboundLink")],1),t._v(".\nTidelift will coordinate the fix and disclosure. Please do NOT report security vulnerability via GitHub issues.")]),t._v(" "),e("h2",{attrs:{id:"license"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#license"}},[t._v("#")]),t._v(" License")]),t._v(" "),e("p",[e("a",{attrs:{href:"https://github.com/ajv-validator/ajv-i18n/blob/master/LICENSE",target:"_blank",rel:"noopener noreferrer"}},[t._v("MIT"),e("OutboundLink")],1)])])}),[],!1,null,null,null);e.default=n.exports}}]); \ No newline at end of file diff --git a/assets/js/80.f95b09ad.js b/assets/js/80.f95b09ad.js new file mode 100644 index 000000000..a7fb4338d --- /dev/null +++ b/assets/js/80.f95b09ad.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[80],{509:function(t,s,a){"use strict";a.r(s);var e=a(14),r=Object(e.a)({},(function(){var t=this,s=t._self._c;return s("ContentSlotsDistributor",{attrs:{"slot-key":t.$parent.slotKey}},[s("p",[s("a",{attrs:{href:"https://github.com/ajv-validator/ajv-keywords",target:"_blank",rel:"noopener noreferrer"}},[t._v("ajv-keywords repository"),s("OutboundLink")],1)]),t._v(" "),s("h1",{attrs:{id:"ajv-keywords"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#ajv-keywords"}},[t._v("#")]),t._v(" ajv-keywords")]),t._v(" "),s("p",[t._v("Custom JSON-Schema keywords for "),s("a",{attrs:{href:"https://github.com/epoberezkin/ajv",target:"_blank",rel:"noopener noreferrer"}},[t._v("Ajv"),s("OutboundLink")],1),t._v(" validator")]),t._v(" "),s("p",[s("a",{attrs:{href:"https://github.com/ajv-validator/ajv-keywords/actions?query=workflow%3Abuild",target:"_blank",rel:"noopener noreferrer"}},[s("img",{attrs:{src:"https://github.com/ajv-validator/ajv-keywords/workflows/build/badge.svg",alt:"build"}}),s("OutboundLink")],1),t._v(" "),s("a",{attrs:{href:"https://www.npmjs.com/package/ajv-keywords",target:"_blank",rel:"noopener noreferrer"}},[s("img",{attrs:{src:"https://img.shields.io/npm/v/ajv-keywords.svg",alt:"npm"}}),s("OutboundLink")],1),t._v(" "),s("a",{attrs:{href:"https://www.npmjs.com/package/ajv-keywords",target:"_blank",rel:"noopener noreferrer"}},[s("img",{attrs:{src:"https://img.shields.io/npm/dm/ajv-keywords.svg",alt:"npm downloads"}}),s("OutboundLink")],1),t._v(" "),s("a",{attrs:{href:"https://coveralls.io/github/ajv-validator/ajv-keywords?branch=master",target:"_blank",rel:"noopener noreferrer"}},[s("img",{attrs:{src:"https://coveralls.io/repos/github/ajv-validator/ajv-keywords/badge.svg?branch=master",alt:"coverage"}}),s("OutboundLink")],1),t._v(" "),s("a",{attrs:{href:"https://gitter.im/ajv-validator/ajv",target:"_blank",rel:"noopener noreferrer"}},[s("img",{attrs:{src:"https://img.shields.io/gitter/room/ajv-validator/ajv.svg",alt:"gitter"}}),s("OutboundLink")],1)]),t._v(" "),s("p",[s("strong",[t._v("Please note")]),t._v(": This readme file is for "),s("a",{attrs:{href:"https://github.com/ajv-validator/ajv-keywords/releases/tag/v5.0.0",target:"_blank",rel:"noopener noreferrer"}},[t._v("ajv-keywords v5.0.0"),s("OutboundLink")],1),t._v(" that should be used with "),s("a",{attrs:{href:"https://github.com/ajv-validator/ajv",target:"_blank",rel:"noopener noreferrer"}},[t._v("ajv v8"),s("OutboundLink")],1),t._v(".")]),t._v(" "),s("p",[s("a",{attrs:{href:"https://github.com/ajv-validator/ajv-keywords/tree/v3",target:"_blank",rel:"noopener noreferrer"}},[t._v("ajv-keywords v3"),s("OutboundLink")],1),t._v(" should be used with "),s("a",{attrs:{href:"https://github.com/ajv-validator/ajv/tree/v6",target:"_blank",rel:"noopener noreferrer"}},[t._v("ajv v6"),s("OutboundLink")],1),t._v(".")]),t._v(" "),s("h2",{attrs:{id:"contents"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#contents"}},[t._v("#")]),t._v(" Contents")]),t._v(" "),s("ul",[s("li",[s("a",{attrs:{href:"#install"}},[t._v("Install")])]),t._v(" "),s("li",[s("a",{attrs:{href:"#usage"}},[t._v("Usage")])]),t._v(" "),s("li",[s("a",{attrs:{href:"#keywords"}},[t._v("Keywords")]),t._v(" "),s("ul",[s("li",[s("a",{attrs:{href:"#types"}},[t._v("Types")]),t._v(" "),s("ul",[s("li",[s("a",{attrs:{href:"#typeof"}},[t._v("typeof")])]),t._v(" "),s("li",[s("a",{attrs:{href:"#instanceof"}},[t._v("instanceof")]),s("sup",[t._v("+")])])])]),t._v(" "),s("li",[s("a",{attrs:{href:"#keywords-for-numbers"}},[t._v("Keywords for numbers")]),t._v(" "),s("ul",[s("li",[s("a",{attrs:{href:"#range-and-exclusiverange"}},[t._v("range and exclusiveRange")])])])]),t._v(" "),s("li",[s("a",{attrs:{href:"#keywords-for-strings"}},[t._v("Keywords for strings")]),t._v(" "),s("ul",[s("li",[s("a",{attrs:{href:"#regexp"}},[t._v("regexp")])]),t._v(" "),s("li",[s("a",{attrs:{href:"#transform"}},[t._v("transform")]),s("sup",[t._v("*")])])])]),t._v(" "),s("li",[s("a",{attrs:{href:"#keywords-for-arrays"}},[t._v("Keywords for arrays")]),t._v(" "),s("ul",[s("li",[s("a",{attrs:{href:"#uniqueitemproperties"}},[t._v("uniqueItemProperties")]),s("sup",[t._v("+")])])])]),t._v(" "),s("li",[s("a",{attrs:{href:"#keywords-for-objects"}},[t._v("Keywords for objects")]),t._v(" "),s("ul",[s("li",[s("a",{attrs:{href:"#allrequired"}},[t._v("allRequired")])]),t._v(" "),s("li",[s("a",{attrs:{href:"#anyrequired"}},[t._v("anyRequired")])]),t._v(" "),s("li",[s("a",{attrs:{href:"#onerequired"}},[t._v("oneRequired")])]),t._v(" "),s("li",[s("a",{attrs:{href:"#patternrequired"}},[t._v("patternRequired")])]),t._v(" "),s("li",[s("a",{attrs:{href:"#prohibited"}},[t._v("prohibited")])]),t._v(" "),s("li",[s("a",{attrs:{href:"#deepproperties"}},[t._v("deepProperties")])]),t._v(" "),s("li",[s("a",{attrs:{href:"#deeprequired"}},[t._v("deepRequired")])]),t._v(" "),s("li",[s("a",{attrs:{href:"#dynamicdefaults"}},[t._v("dynamicDefaults")]),s("sup",[t._v("*")]),s("sup",[t._v("+")])])])]),t._v(" "),s("li",[s("a",{attrs:{href:"#keywords-for-all-types"}},[t._v("Keywords for all types")]),t._v(" "),s("ul",[s("li",[s("a",{attrs:{href:"#selectselectcasesselectdefault"}},[t._v("select/selectCases/selectDefault")])])])])])]),t._v(" "),s("li",[s("a",{attrs:{href:"#security-contact"}},[t._v("Security contact")])]),t._v(" "),s("li",[s("a",{attrs:{href:"#open-source-software-support"}},[t._v("Open-source software support")])]),t._v(" "),s("li",[s("a",{attrs:{href:"#license"}},[t._v("License")])])]),t._v(" "),s("p",[s("sup",[t._v("*")]),t._v(" - keywords that modify data\n"),s("sup",[t._v("+")]),t._v(" - keywords that are not supported in "),s("a",{attrs:{href:"https://github.com/ajv-validator/ajv/blob/master/docs/standalone.md",target:"_blank",rel:"noopener noreferrer"}},[t._v("standalone validation code"),s("OutboundLink")],1)]),t._v(" "),s("h2",{attrs:{id:"install"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#install"}},[t._v("#")]),t._v(" Install")]),t._v(" "),s("p",[t._v("To install version 4 to use with "),s("a",{attrs:{href:"https://github.com/ajv-validator/ajv",target:"_blank",rel:"noopener noreferrer"}},[t._v("Ajv v7"),s("OutboundLink")],1),t._v(":")]),t._v(" "),s("div",{staticClass:"language- extra-class"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[t._v("npm install ajv-keywords\n")])])]),s("h2",{attrs:{id:"usage"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#usage"}},[t._v("#")]),t._v(" Usage")]),t._v(" "),s("p",[t._v("To add all available keywords:")]),t._v(" "),s("div",{staticClass:"language-javascript extra-class"},[s("pre",{pre:!0,attrs:{class:"language-javascript"}},[s("code",[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 function"}},[t._v("require")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"ajv"')]),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(" 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"),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("require")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"ajv-keywords"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("ajv"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n\najv"),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("(")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("instanceof")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"RegExp"')]),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 regex"}},[s("span",{pre:!0,attrs:{class:"token regex-delimiter"}},[t._v("/")]),s("span",{pre:!0,attrs:{class:"token regex-source language-regex"}},[t._v(".*")]),s("span",{pre:!0,attrs:{class:"token regex-delimiter"}},[t._v("/")])]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// true")]),t._v("\najv"),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("(")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("instanceof")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"RegExp"')]),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 string"}},[t._v('".*"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// false")]),t._v("\n")])])]),s("p",[t._v("To add a single keyword:")]),t._v(" "),s("div",{staticClass:"language-javascript extra-class"},[s("pre",{pre:!0,attrs:{class:"language-javascript"}},[s("code",[s("span",{pre:!0,attrs:{class:"token function"}},[t._v("require")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"ajv-keywords"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("ajv"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"instanceof"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n")])])]),s("p",[t._v("To add multiple keywords:")]),t._v(" "),s("div",{staticClass:"language-javascript extra-class"},[s("pre",{pre:!0,attrs:{class:"language-javascript"}},[s("code",[s("span",{pre:!0,attrs:{class:"token function"}},[t._v("require")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"ajv-keywords"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),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("[")]),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"typeof"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"instanceof"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n")])])]),s("p",[t._v("To add a single keyword directly (to avoid adding unused code):")]),t._v(" "),s("div",{staticClass:"language-javascript extra-class"},[s("pre",{pre:!0,attrs:{class:"language-javascript"}},[s("code",[s("span",{pre:!0,attrs:{class:"token function"}},[t._v("require")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"ajv-keywords/dist/keywords/select"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("ajv"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" opts"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n")])])]),s("p",[t._v("To add all keywords via Ajv options:")]),t._v(" "),s("div",{staticClass:"language-javascript extra-class"},[s("pre",{pre:!0,attrs:{class:"language-javascript"}},[s("code",[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("{")]),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("keywords")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("require")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"ajv-keywords/dist/definitions"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("opts"),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("\n")])])]),s("p",[t._v("To add one or several keywords via options:")]),t._v(" "),s("div",{staticClass:"language-javascript extra-class"},[s("pre",{pre:!0,attrs:{class:"language-javascript"}},[s("code",[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 "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("keywords")]),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 function"}},[t._v("require")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"ajv-keywords/dist/definitions/typeof"')]),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(")")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("require")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"ajv-keywords/dist/definitions/instanceof"')]),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(")")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v('// select exports an array of 3 definitions - see "select" in docs')]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("...")]),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("require")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"ajv-keywords/dist/definitions/select"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("opts"),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("}")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n")])])]),s("p",[s("code",[t._v("opts")]),t._v(" is an optional object with a property "),s("code",[t._v("defaultMeta")]),t._v(" - URI of meta-schema to use for keywords that use subschemas ("),s("code",[t._v("select")]),t._v(" and "),s("code",[t._v("deepProperties")]),t._v("). The default is "),s("code",[t._v('"http://json-schema.org/schema"')]),t._v(".")]),t._v(" "),s("h2",{attrs:{id:"keywords"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#keywords"}},[t._v("#")]),t._v(" Keywords")]),t._v(" "),s("h3",{attrs:{id:"types"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#types"}},[t._v("#")]),t._v(" Types")]),t._v(" "),s("h4",{attrs:{id:"typeof"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#typeof"}},[t._v("#")]),t._v(" "),s("code",[t._v("typeof")])]),t._v(" "),s("p",[t._v("Based on JavaScript "),s("code",[t._v("typeof")]),t._v(" operation.")]),t._v(" "),s("p",[t._v("The value of the keyword should be a string ("),s("code",[t._v('"undefined"')]),t._v(", "),s("code",[t._v('"string"')]),t._v(", "),s("code",[t._v('"number"')]),t._v(", "),s("code",[t._v('"object"')]),t._v(", "),s("code",[t._v('"function"')]),t._v(", "),s("code",[t._v('"boolean"')]),t._v(" or "),s("code",[t._v('"symbol"')]),t._v(") or an array of strings.")]),t._v(" "),s("p",[t._v("To pass validation the result of "),s("code",[t._v("typeof")]),t._v(" operation on the value should be equal to the string (or one of the strings in the array).")]),t._v(" "),s("div",{staticClass:"language-javascript extra-class"},[s("pre",{pre:!0,attrs:{class:"language-javascript"}},[s("code",[t._v("ajv"),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("(")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("typeof")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"undefined"')]),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 keyword"}},[t._v("undefined")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// true")]),t._v("\najv"),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("(")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("typeof")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"undefined"')]),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 keyword"}},[t._v("null")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// false")]),t._v("\najv"),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("(")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("typeof")]),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('"undefined"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[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("]")]),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 keyword"}},[t._v("null")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// true")]),t._v("\n")])])]),s("h4",{attrs:{id:"instanceof"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#instanceof"}},[t._v("#")]),t._v(" "),s("code",[t._v("instanceof")])]),t._v(" "),s("p",[t._v("Based on JavaScript "),s("code",[t._v("instanceof")]),t._v(" operation.")]),t._v(" "),s("p",[t._v("The value of the keyword should be a string ("),s("code",[t._v('"Object"')]),t._v(", "),s("code",[t._v('"Array"')]),t._v(", "),s("code",[t._v('"Function"')]),t._v(", "),s("code",[t._v('"Number"')]),t._v(", "),s("code",[t._v('"String"')]),t._v(", "),s("code",[t._v('"Date"')]),t._v(", "),s("code",[t._v('"RegExp"')]),t._v(" or "),s("code",[t._v('"Promise"')]),t._v(") or an array of strings.")]),t._v(" "),s("p",[t._v("To pass validation the result of "),s("code",[t._v("data instanceof ...")]),t._v(" operation on the value should be true:")]),t._v(" "),s("div",{staticClass:"language-javascript extra-class"},[s("pre",{pre:!0,attrs:{class:"language-javascript"}},[s("code",[t._v("ajv"),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("(")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("instanceof")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"Array"')]),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("[")]),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("// true")]),t._v("\najv"),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("(")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("instanceof")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"Array"')]),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("{")]),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("// false")]),t._v("\najv"),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("(")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("instanceof")]),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('"Array"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"Function"')]),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 keyword"}},[t._v("function")]),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("{")]),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("// true")]),t._v("\n")])])]),s("p",[t._v("You can add your own constructor function to be recognised by this keyword:")]),t._v(" "),s("div",{staticClass:"language-javascript extra-class"},[s("pre",{pre:!0,attrs:{class:"language-javascript"}},[s("code",[s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("class")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("MyClass")]),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"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" instanceofDef "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("require")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"ajv-keywords/dist/definitions/instanceof"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\ninstanceofDef"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),s("span",{pre:!0,attrs:{class:"token constant"}},[t._v("CONSTRUCTORS")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("MyClass "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" MyClass\najv"),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("(")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("instanceof")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"MyClass"')]),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 keyword"}},[t._v("new")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("MyClass")]),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 comment"}},[t._v("// true")]),t._v("\n")])])]),s("p",[s("strong",[t._v("Please note")]),t._v(": currently "),s("code",[t._v("instanceof")]),t._v(" is not supported in "),s("a",{attrs:{href:"https://github.com/ajv-validator/ajv/blob/master/docs/standalone.md",target:"_blank",rel:"noopener noreferrer"}},[t._v("standalone validation code"),s("OutboundLink")],1),t._v(" - it has to be implemented as "),s("a",{attrs:{href:"https://github.com/ajv-validator/ajv/blob/master/docs/keywords.md#define-keyword-with-code-generation-function",target:"_blank",rel:"noopener noreferrer"}},[s("code",[t._v("code")]),t._v(" keyword"),s("OutboundLink")],1),t._v(" to support it (PR is welcome).")]),t._v(" "),s("h3",{attrs:{id:"keywords-for-numbers"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#keywords-for-numbers"}},[t._v("#")]),t._v(" Keywords for numbers")]),t._v(" "),s("h4",{attrs:{id:"range-and-exclusiverange"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#range-and-exclusiverange"}},[t._v("#")]),t._v(" "),s("code",[t._v("range")]),t._v(" and "),s("code",[t._v("exclusiveRange")])]),t._v(" "),s("p",[t._v("Syntax sugar for the combination of minimum and maximum keywords (or exclusiveMinimum and exclusiveMaximum), also fails schema compilation if there are no numbers in the range.")]),t._v(" "),s("p",[t._v("The value of these keywords must be an array consisting of two numbers, the second must be greater or equal than the first one.")]),t._v(" "),s("p",[t._v("If the validated value is not a number the validation passes, otherwise to pass validation the value should be greater (or equal) than the first number and smaller (or equal) than the second number in the array.")]),t._v(" "),s("div",{staticClass:"language-javascript extra-class"},[s("pre",{pre:!0,attrs:{class:"language-javascript"}},[s("code",[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("{")]),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[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('"number"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("range")]),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 number"}},[t._v("1")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("3")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\najv"),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("schema"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[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(" "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// true")]),t._v("\najv"),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("schema"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("2")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// true")]),t._v("\najv"),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("schema"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("3")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// true")]),t._v("\najv"),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("schema"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("0.99")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// false")]),t._v("\najv"),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("schema"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("3.01")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// false")]),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("{")]),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[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('"number"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("exclusiveRange")]),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 number"}},[t._v("1")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("3")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\najv"),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("schema"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("1.01")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// true")]),t._v("\najv"),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("schema"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("2")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// true")]),t._v("\najv"),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("schema"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("2.99")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// true")]),t._v("\najv"),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("schema"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[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(" "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// false")]),t._v("\najv"),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("schema"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("3")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// false")]),t._v("\n")])])]),s("h3",{attrs:{id:"keywords-for-strings"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#keywords-for-strings"}},[t._v("#")]),t._v(" Keywords for strings")]),t._v(" "),s("h4",{attrs:{id:"regexp"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#regexp"}},[t._v("#")]),t._v(" "),s("code",[t._v("regexp")])]),t._v(" "),s("p",[t._v("This keyword allows to use regular expressions with flags in schemas, and also without "),s("code",[t._v('"u"')]),t._v(" flag when needed (the standard "),s("code",[t._v("pattern")]),t._v(" keyword does not support flags and implies the presence of "),s("code",[t._v('"u"')]),t._v(" flag).")]),t._v(" "),s("p",[t._v("This keyword applies only to strings. If the data is not a string, the validation succeeds.")]),t._v(" "),s("p",[t._v("The value of this keyword can be either a string (the result of "),s("code",[t._v("regexp.toString()")]),t._v(") or an object with the properties "),s("code",[t._v("pattern")]),t._v(" and "),s("code",[t._v("flags")]),t._v(" (the same strings that should be passed to RegExp constructor).")]),t._v(" "),s("div",{staticClass:"language-javascript extra-class"},[s("pre",{pre:!0,attrs:{class:"language-javascript"}},[s("code",[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 "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[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('"object"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("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 "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("foo")]),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 literal-property property"}},[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(" "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("regexp")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"/foo/i"')]),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 literal-property property"}},[t._v("bar")]),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 literal-property property"}},[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(" "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("regexp")]),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 literal-property property"}},[t._v("pattern")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"bar"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("flags")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"i"')]),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("\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\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 "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("foo")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"Food"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("bar")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"Barmen"')]),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 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 literal-property property"}},[t._v("foo")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"fog"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("bar")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"bad"')]),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("h4",{attrs:{id:"transform"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#transform"}},[t._v("#")]),t._v(" "),s("code",[t._v("transform")])]),t._v(" "),s("p",[t._v("This keyword allows a string to be modified during validation.")]),t._v(" "),s("p",[t._v("This keyword applies only to strings. If the data is not a string, the "),s("code",[t._v("transform")]),t._v(" keyword is ignored.")]),t._v(" "),s("p",[t._v("A standalone string cannot be modified, i.e. "),s("code",[t._v("data = 'a'; ajv.validate(schema, data);")]),t._v(", because strings are passed by value")]),t._v(" "),s("p",[s("strong",[t._v("Supported transformations:")])]),t._v(" "),s("ul",[s("li",[s("code",[t._v("trim")]),t._v(": remove whitespace from start and end")]),t._v(" "),s("li",[s("code",[t._v("trimStart")]),t._v("/"),s("code",[t._v("trimLeft")]),t._v(": remove whitespace from start")]),t._v(" "),s("li",[s("code",[t._v("trimEnd")]),t._v("/"),s("code",[t._v("trimRight")]),t._v(": remove whitespace from end")]),t._v(" "),s("li",[s("code",[t._v("toLowerCase")]),t._v(": convert to lower case")]),t._v(" "),s("li",[s("code",[t._v("toUpperCase")]),t._v(": convert to upper case")]),t._v(" "),s("li",[s("code",[t._v("toEnumCase")]),t._v(": change string case to be equal to one of "),s("code",[t._v("enum")]),t._v(" values in the schema")])]),t._v(" "),s("p",[t._v("Transformations are applied in the order they are listed.")]),t._v(" "),s("p",[t._v("Note: "),s("code",[t._v("toEnumCase")]),t._v(" requires that all allowed values are unique when case insensitive.")]),t._v(" "),s("p",[s("strong",[t._v("Example: multiple transformations")])]),t._v(" "),s("div",{staticClass:"language-javascript extra-class"},[s("pre",{pre:!0,attrs:{class:"language-javascript"}},[s("code",[s("span",{pre:!0,attrs:{class:"token function"}},[t._v("require")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"ajv-keywords"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("ajv"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"transform"')]),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 "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[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('"array"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("items")]),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 literal-property property"}},[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 literal-property property"}},[t._v("transform")]),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('"trim"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"toLowerCase"')]),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\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("[")]),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('" MixCase "')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),t._v("\najv"),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("schema"),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("\nconsole"),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(" "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// ['mixcase']")]),t._v("\n")])])]),s("p",[s("strong",[t._v("Example: "),s("code",[t._v("enumcase")])])]),t._v(" "),s("div",{staticClass:"language-javascript extra-class"},[s("pre",{pre:!0,attrs:{class:"language-javascript"}},[s("code",[s("span",{pre:!0,attrs:{class:"token function"}},[t._v("require")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"ajv-keywords"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),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("[")]),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"transform"')]),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 "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[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('"array"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("items")]),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 literal-property property"}},[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 literal-property property"}},[t._v("transform")]),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('"trim"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"toEnumCase"')]),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 keyword"}},[t._v("enum")]),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('"pH"')]),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\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("[")]),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"ph"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('" Ph"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"PH"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"pH "')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),t._v("\najv"),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("schema"),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("\nconsole"),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(" "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// ['pH','pH','pH','pH']")]),t._v("\n")])])]),s("h3",{attrs:{id:"keywords-for-arrays"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#keywords-for-arrays"}},[t._v("#")]),t._v(" Keywords for arrays")]),t._v(" "),s("h4",{attrs:{id:"uniqueitemproperties"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#uniqueitemproperties"}},[t._v("#")]),t._v(" "),s("code",[t._v("uniqueItemProperties")])]),t._v(" "),s("p",[t._v("The keyword allows to check that some properties in array items are unique.")]),t._v(" "),s("p",[t._v("This keyword applies only to arrays. If the data is not an array, the validation succeeds.")]),t._v(" "),s("p",[t._v("The value of this keyword must be an array of strings - property names that should have unique values across all items.")]),t._v(" "),s("div",{staticClass:"language-javascript extra-class"},[s("pre",{pre:!0,attrs:{class:"language-javascript"}},[s("code",[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 "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[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('"array"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("uniqueItemProperties")]),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('"id"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"name"')]),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\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("[")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("id")]),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("}")]),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 literal-property property"}},[t._v("id")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("2")]),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("{")]),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("id")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("3")]),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(" invalidData1 "),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("{")]),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("id")]),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("}")]),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 literal-property property"}},[t._v("id")]),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("}")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v('// duplicate "id"')]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("id")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("3")]),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\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" invalidData2 "),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("{")]),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("id")]),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(" "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("name")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"taco"')]),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 literal-property property"}},[t._v("id")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("2")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("name")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"taco"')]),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('// duplicate "name"')]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("id")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("3")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("name")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"salsa"')]),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")])])]),s("p",[t._v("This keyword is contributed by "),s("a",{attrs:{href:"https://github.com/blainesch",target:"_blank",rel:"noopener noreferrer"}},[t._v("@blainesch"),s("OutboundLink")],1),t._v(".")]),t._v(" "),s("p",[s("strong",[t._v("Please note")]),t._v(": currently "),s("code",[t._v("uniqueItemProperties")]),t._v(" is not supported in "),s("a",{attrs:{href:"https://github.com/ajv-validator/ajv/blob/master/docs/standalone.md",target:"_blank",rel:"noopener noreferrer"}},[t._v("standalone validation code"),s("OutboundLink")],1),t._v(" - it has to be implemented as "),s("a",{attrs:{href:"https://github.com/ajv-validator/ajv/blob/master/docs/keywords.md#define-keyword-with-code-generation-function",target:"_blank",rel:"noopener noreferrer"}},[s("code",[t._v("code")]),t._v(" keyword"),s("OutboundLink")],1),t._v(" to support it (PR is welcome).")]),t._v(" "),s("h3",{attrs:{id:"keywords-for-objects"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#keywords-for-objects"}},[t._v("#")]),t._v(" Keywords for objects")]),t._v(" "),s("h4",{attrs:{id:"allrequired"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#allrequired"}},[t._v("#")]),t._v(" "),s("code",[t._v("allRequired")])]),t._v(" "),s("p",[t._v("This keyword allows to require the presence of all properties used in "),s("code",[t._v("properties")]),t._v(" keyword in the same schema object.")]),t._v(" "),s("p",[t._v("This keyword applies only to objects. If the data is not an object, the validation succeeds.")]),t._v(" "),s("p",[t._v("The value of this keyword must be boolean.")]),t._v(" "),s("p",[t._v("If the value of the keyword is "),s("code",[t._v("false")]),t._v(", the validation succeeds.")]),t._v(" "),s("p",[t._v("If the value of the keyword is "),s("code",[t._v("true")]),t._v(", the validation succeeds if the data contains all properties defined in "),s("code",[t._v("properties")]),t._v(" keyword (in the same schema object).")]),t._v(" "),s("p",[t._v("If the "),s("code",[t._v("properties")]),t._v(" keyword is not present in the same schema object, schema compilation will throw exception.")]),t._v(" "),s("div",{staticClass:"language-javascript extra-class"},[s("pre",{pre:!0,attrs:{class:"language-javascript"}},[s("code",[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 "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[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('"object"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("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 "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("foo")]),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 literal-property property"}},[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('"number"')]),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 literal-property property"}},[t._v("bar")]),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 literal-property property"}},[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('"number"')]),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 literal-property property"}},[t._v("allRequired")]),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("}")]),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("{")]),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("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(" "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("bar")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("2")]),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(" alsoValidData "),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 literal-property property"}},[t._v("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(" "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("bar")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("2")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("baz")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("3")]),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(" invalidDataList "),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 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("{")]),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("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("}")]),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 literal-property property"}},[t._v("bar")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("2")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),t._v("\n")])])]),s("h4",{attrs:{id:"anyrequired"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#anyrequired"}},[t._v("#")]),t._v(" "),s("code",[t._v("anyRequired")])]),t._v(" "),s("p",[t._v("This keyword allows to require the presence of any (at least one) property from the list.")]),t._v(" "),s("p",[t._v("This keyword applies only to objects. If the data is not an object, the validation succeeds.")]),t._v(" "),s("p",[t._v("The value of this keyword must be an array of strings, each string being a property name. For data object to be valid at least one of the properties in this array should be present in the object.")]),t._v(" "),s("div",{staticClass:"language-javascript extra-class"},[s("pre",{pre:!0,attrs:{class:"language-javascript"}},[s("code",[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 "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[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('"object"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("anyRequired")]),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(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"bar"')]),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\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("{")]),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("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"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" alsoValidData "),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 literal-property property"}},[t._v("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(" "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("bar")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("2")]),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(" invalidDataList "),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 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("{")]),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("baz")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("3")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),t._v("\n")])])]),s("h4",{attrs:{id:"onerequired"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#onerequired"}},[t._v("#")]),t._v(" "),s("code",[t._v("oneRequired")])]),t._v(" "),s("p",[t._v("This keyword allows to require the presence of only one property from the list.")]),t._v(" "),s("p",[t._v("This keyword applies only to objects. If the data is not an object, the validation succeeds.")]),t._v(" "),s("p",[t._v("The value of this keyword must be an array of strings, each string being a property name. For data object to be valid exactly one of the properties in this array should be present in the object.")]),t._v(" "),s("div",{staticClass:"language-javascript extra-class"},[s("pre",{pre:!0,attrs:{class:"language-javascript"}},[s("code",[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 "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[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('"object"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("oneRequired")]),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(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"bar"')]),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\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("{")]),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("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"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" alsoValidData "),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 literal-property property"}},[t._v("bar")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("2")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("baz")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("3")]),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(" invalidDataList "),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 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("{")]),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("baz")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("3")]),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("{")]),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("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(" "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("bar")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("2")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),t._v("\n")])])]),s("h4",{attrs:{id:"patternrequired"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#patternrequired"}},[t._v("#")]),t._v(" "),s("code",[t._v("patternRequired")])]),t._v(" "),s("p",[t._v("This keyword allows to require the presence of properties that match some pattern(s).")]),t._v(" "),s("p",[t._v("This keyword applies only to objects. If the data is not an object, the validation succeeds.")]),t._v(" "),s("p",[t._v("The value of this keyword should be an array of strings, each string being a regular expression. For data object to be valid each regular expression in this array should match at least one property name in the data object.")]),t._v(" "),s("p",[t._v("If the array contains multiple regular expressions, more than one expression can match the same property name.")]),t._v(" "),s("div",{staticClass:"language-javascript extra-class"},[s("pre",{pre:!0,attrs:{class:"language-javascript"}},[s("code",[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 "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[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('"object"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("patternRequired")]),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('"f.*o"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"b.*r"')]),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\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("{")]),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("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(" "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("bar")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("2")]),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(" alsoValidData "),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 literal-property property"}},[t._v("foobar")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("3")]),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(" invalidDataList "),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 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("{")]),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("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("}")]),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 literal-property property"}},[t._v("bar")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("2")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),t._v("\n")])])]),s("h4",{attrs:{id:"prohibited"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#prohibited"}},[t._v("#")]),t._v(" "),s("code",[t._v("prohibited")])]),t._v(" "),s("p",[t._v("This keyword allows to prohibit that any of the properties in the list is present in the object.")]),t._v(" "),s("p",[t._v("This keyword applies only to objects. If the data is not an object, the validation succeeds.")]),t._v(" "),s("p",[t._v("The value of this keyword should be an array of strings, each string being a property name. For data object to be valid none of the properties in this array should be present in the object.")]),t._v(" "),s("div",{staticClass:"language-javascript extra-class"},[s("pre",{pre:!0,attrs:{class:"language-javascript"}},[s("code",[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 "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[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('"object"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("prohibited")]),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(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"bar"')]),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\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("{")]),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("baz")]),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"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" alsoValidData "),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 punctuation"}},[t._v("}")]),t._v("\n\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" invalidDataList "),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 punctuation"}},[t._v("{")]),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("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("}")]),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 literal-property property"}},[t._v("bar")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("2")]),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("{")]),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("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(" "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("bar")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("2")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),t._v("\n")])])]),s("p",[s("strong",[t._v("Please note")]),t._v(": "),s("code",[t._v("{prohibited: ['foo', 'bar']}")]),t._v(" is equivalent to "),s("code",[t._v("{not: {anyRequired: ['foo', 'bar']}}")]),t._v(" (i.e. it has the same validation result for any data).")]),t._v(" "),s("h4",{attrs:{id:"deepproperties"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#deepproperties"}},[t._v("#")]),t._v(" "),s("code",[t._v("deepProperties")])]),t._v(" "),s("p",[t._v("This keyword allows to validate deep properties (identified by JSON pointers).")]),t._v(" "),s("p",[t._v("This keyword applies only to objects. If the data is not an object, the validation succeeds.")]),t._v(" "),s("p",[t._v("The value should be an object, where keys are JSON pointers to the data, starting from the current position in data, and the values are JSON schemas. For data object to be valid the value of each JSON pointer should be valid according to the corresponding schema.")]),t._v(" "),s("div",{staticClass:"language-javascript extra-class"},[s("pre",{pre:!0,attrs:{class:"language-javascript"}},[s("code",[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 "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[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('"object"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("deepProperties")]),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 string-property property"}},[t._v('"/users/1/role"')]),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 keyword"}},[t._v("enum")]),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('"admin"')]),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("\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\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 "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("users")]),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("{")]),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 "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("id")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("123")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("role")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"admin"')]),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("]")]),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 keyword"}},[t._v("const")]),t._v(" alsoValidData "),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 literal-property property"}},[t._v("users")]),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 number"}},[t._v("1")]),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 literal-property property"}},[t._v("id")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("123")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("role")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"admin"')]),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("}")]),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 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 literal-property property"}},[t._v("users")]),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("{")]),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 "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("id")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("123")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("role")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"user"')]),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("]")]),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 keyword"}},[t._v("const")]),t._v(" alsoInvalidData "),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 literal-property property"}},[t._v("users")]),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 number"}},[t._v("1")]),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 literal-property property"}},[t._v("id")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("123")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("role")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"user"')]),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("}")]),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("h4",{attrs:{id:"deeprequired"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#deeprequired"}},[t._v("#")]),t._v(" "),s("code",[t._v("deepRequired")])]),t._v(" "),s("p",[t._v("This keyword allows to check that some deep properties (identified by JSON pointers) are available.")]),t._v(" "),s("p",[t._v("This keyword applies only to objects. If the data is not an object, the validation succeeds.")]),t._v(" "),s("p",[t._v("The value should be an array of JSON pointers to the data, starting from the current position in data. For data object to be valid each JSON pointer should be some existing part of the data.")]),t._v(" "),s("div",{staticClass:"language-javascript extra-class"},[s("pre",{pre:!0,attrs:{class:"language-javascript"}},[s("code",[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 "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[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('"object"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("deepRequired")]),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('"/users/1/role"')]),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\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 "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("users")]),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("{")]),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 "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("id")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("123")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("role")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"admin"')]),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("]")]),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 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 literal-property property"}},[t._v("users")]),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("{")]),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 "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("id")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("123")]),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("]")]),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("p",[t._v("See "),s("a",{attrs:{href:"https://github.com/json-schema-org/json-schema-spec/issues/203#issue-197211916",target:"_blank",rel:"noopener noreferrer"}},[t._v("json-schema-org/json-schema-spec#203"),s("OutboundLink")],1),t._v(" for an example of the equivalent schema without "),s("code",[t._v("deepRequired")]),t._v(" keyword.")]),t._v(" "),s("h3",{attrs:{id:"keywords-for-all-types"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#keywords-for-all-types"}},[t._v("#")]),t._v(" Keywords for all types")]),t._v(" "),s("h4",{attrs:{id:"select-selectcases-selectdefault"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#select-selectcases-selectdefault"}},[t._v("#")]),t._v(" "),s("code",[t._v("select")]),t._v("/"),s("code",[t._v("selectCases")]),t._v("/"),s("code",[t._v("selectDefault")])]),t._v(" "),s("p",[s("strong",[t._v("Please note")]),t._v(": these keywords are deprecated. It is recommended to use OpenAPI "),s("a",{attrs:{href:"https://ajv.js.org/json-schema.html#discriminator",target:"_blank",rel:"noopener noreferrer"}},[t._v("discriminator"),s("OutboundLink")],1),t._v(" keyword supported by Ajv v8 instead of "),s("code",[t._v("select")]),t._v(".")]),t._v(" "),s("p",[t._v("These keywords allow to choose the schema to validate the data based on the value of some property in the validated data.")]),t._v(" "),s("p",[t._v("These keywords must be present in the same schema object ("),s("code",[t._v("selectDefault")]),t._v(" is optional).")]),t._v(" "),s("p",[t._v("The value of "),s("code",[t._v("select")]),t._v(" keyword should be a "),s("a",{attrs:{href:"https://github.com/ajv-validator/ajv/blob/master/docs/validation.md#data-reference",target:"_blank",rel:"noopener noreferrer"}},[t._v("$data reference"),s("OutboundLink")],1),t._v(" that points to any primitive JSON type (string, number, boolean or null) in the data that is validated. You can also use a constant of primitive type as the value of this keyword (e.g., for debugging purposes).")]),t._v(" "),s("p",[t._v("The value of "),s("code",[t._v("selectCases")]),t._v(" keyword must be an object where each property name is a possible string representation of the value of "),s("code",[t._v("select")]),t._v(" keyword and each property value is a corresponding schema (from draft-06 it can be boolean) that must be used to validate the data.")]),t._v(" "),s("p",[t._v("The value of "),s("code",[t._v("selectDefault")]),t._v(" keyword is a schema (also can be boolean) that must be used to validate the data in case "),s("code",[t._v("selectCases")]),t._v(" has no key equal to the stringified value of "),s("code",[t._v("select")]),t._v(" keyword.")]),t._v(" "),s("p",[t._v("The validation succeeds in one of the following cases:")]),t._v(" "),s("ul",[s("li",[t._v("the validation of data using selected schema succeeds,")]),t._v(" "),s("li",[t._v("none of the schemas is selected for validation,")]),t._v(" "),s("li",[t._v("the value of select is undefined (no property in the data that the data reference points to).")])]),t._v(" "),s("p",[t._v("If "),s("code",[t._v("select")]),t._v(" value (in data) is not a primitive type the validation fails.")]),t._v(" "),s("p",[t._v("This keyword correctly tracks evaluated properties and items to work with "),s("code",[t._v("unevaluatedProperties")]),t._v(" and "),s("code",[t._v("unevaluatedItems")]),t._v(" keywords - only properties and items from the subschema that was used (one of "),s("code",[t._v("selectCases")]),t._v(" subschemas or "),s("code",[t._v("selectDefault")]),t._v(" subschema) are marked as evaluated.")]),t._v(" "),s("p",[s("strong",[t._v("Please note")]),t._v(": these keywords require Ajv "),s("code",[t._v("$data")]),t._v(" option to support "),s("a",{attrs:{href:"https://github.com/ajv-validator/ajv/blob/master/docs/validation.md#data-reference",target:"_blank",rel:"noopener noreferrer"}},[t._v("$data reference"),s("OutboundLink")],1),t._v(".")]),t._v(" "),s("div",{staticClass:"language-javascript extra-class"},[s("pre",{pre:!0,attrs:{class:"language-javascript"}},[s("code",[s("span",{pre:!0,attrs:{class:"token function"}},[t._v("require")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"ajv-keywords"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("ajv"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"select"')]),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 "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[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('"object"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("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('"kind"')]),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 literal-property property"}},[t._v("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 "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("kind")]),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 literal-property property"}},[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("}")]),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 literal-property property"}},[t._v("select")]),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 literal-property property"}},[t._v("$data")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"0/kind"')]),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 literal-property property"}},[t._v("selectCases")]),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 literal-property property"}},[t._v("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("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("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 "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("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 "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("kind")]),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 punctuation"}},[t._v("}")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("foo")]),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 literal-property property"}},[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("}")]),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 literal-property property"}},[t._v("additionalProperties")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token boolean"}},[t._v("false")]),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 literal-property property"}},[t._v("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("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("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('"bar"')]),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 literal-property property"}},[t._v("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 "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("kind")]),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 punctuation"}},[t._v("}")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("bar")]),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 literal-property property"}},[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('"number"')]),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 literal-property property"}},[t._v("additionalProperties")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token boolean"}},[t._v("false")]),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("}")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("selectDefault")]),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 literal-property property"}},[t._v("propertyNames")]),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 literal-property property"}},[t._v("not")]),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 keyword"}},[t._v("enum")]),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(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"bar"')]),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("\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("}")]),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 keyword"}},[t._v("const")]),t._v(" validDataList "),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("{")]),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("kind")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"foo"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("foo")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"any"')]),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 literal-property property"}},[t._v("kind")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"bar"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("bar")]),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("}")]),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 literal-property property"}},[t._v("kind")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"anything_else"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("not_bar_or_foo")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"any value"')]),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\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" invalidDataList "),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("{")]),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("kind")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),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(" "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// no property foo")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("kind")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"bar"')]),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("// no property bar")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("kind")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"foo"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("foo")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"any"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("another")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"any value"')]),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("// additional property")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("kind")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"bar"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("bar")]),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(" "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("another")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"any value"')]),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("// additional property")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("kind")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"anything_else"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("foo")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"any"')]),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("// property foo not allowed")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("kind")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"anything_else"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("bar")]),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("}")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// property bar not allowed")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),t._v("\n")])])]),s("h4",{attrs:{id:"dynamicdefaults"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#dynamicdefaults"}},[t._v("#")]),t._v(" "),s("code",[t._v("dynamicDefaults")])]),t._v(" "),s("p",[t._v("This keyword allows to assign dynamic defaults to properties, such as timestamps, unique IDs etc.")]),t._v(" "),s("p",[t._v("This keyword only works if "),s("code",[t._v("useDefaults")]),t._v(" options is used and not inside "),s("code",[t._v("anyOf")]),t._v(" keywords etc., in the same way as "),s("a",{attrs:{href:"https://github.com/epoberezkin/ajv#assigning-defaults",target:"_blank",rel:"noopener noreferrer"}},[t._v("default keyword treated by Ajv"),s("OutboundLink")],1),t._v(".")]),t._v(" "),s("p",[t._v("The keyword should be added on the object level. Its value should be an object with each property corresponding to a property name, in the same way as in standard "),s("code",[t._v("properties")]),t._v(" keyword. The value of each property can be:")]),t._v(" "),s("ul",[s("li",[t._v("an identifier of dynamic default function (a string)")]),t._v(" "),s("li",[t._v("an object with properties "),s("code",[t._v("func")]),t._v(" (an identifier) and "),s("code",[t._v("args")]),t._v(" (an object with parameters that will be passed to this function during schema compilation - see examples).")])]),t._v(" "),s("p",[t._v("The properties used in "),s("code",[t._v("dynamicDefaults")]),t._v(" should not be added to "),s("code",[t._v("required")]),t._v(" keyword in the same schema (or validation will fail), because unlike "),s("code",[t._v("default")]),t._v(" this keyword is processed after validation.")]),t._v(" "),s("p",[t._v("There are several predefined dynamic default functions:")]),t._v(" "),s("ul",[s("li",[s("code",[t._v('"timestamp"')]),t._v(" - current timestamp in milliseconds")]),t._v(" "),s("li",[s("code",[t._v('"datetime"')]),t._v(" - current date and time as string (ISO, valid according to "),s("code",[t._v("date-time")]),t._v(" format)")]),t._v(" "),s("li",[s("code",[t._v('"date"')]),t._v(" - current date as string (ISO, valid according to "),s("code",[t._v("date")]),t._v(" format)")]),t._v(" "),s("li",[s("code",[t._v('"time"')]),t._v(" - current time as string (ISO, valid according to "),s("code",[t._v("time")]),t._v(" format)")]),t._v(" "),s("li",[s("code",[t._v('"random"')]),t._v(" - pseudo-random number in [0, 1) interval")]),t._v(" "),s("li",[s("code",[t._v('"randomint"')]),t._v(" - pseudo-random integer number. If string is used as a property value, the function will randomly return 0 or 1. If object "),s("code",[t._v("{ func: 'randomint', args: { max: N } }")]),t._v(" is used then the default will be an integer number in [0, N) interval.")]),t._v(" "),s("li",[s("code",[t._v('"seq"')]),t._v(" - sequential integer number starting from 0. If string is used as a property value, the default sequence will be used. If object "),s("code",[t._v("{ func: 'seq', args: { name: 'foo'} }")]),t._v(" is used then the sequence with name "),s("code",[t._v('"foo"')]),t._v(" will be used. Sequences are global, even if different ajv instances are used.")])]),t._v(" "),s("div",{staticClass:"language-javascript extra-class"},[s("pre",{pre:!0,attrs:{class:"language-javascript"}},[s("code",[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 "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[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('"object"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("dynamicDefaults")]),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 literal-property property"}},[t._v("ts")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"datetime"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("r")]),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 literal-property property"}},[t._v("func")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"randomint"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("args")]),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 literal-property property"}},[t._v("max")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("100")]),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("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("id")]),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 literal-property property"}},[t._v("func")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"seq"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("args")]),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 literal-property property"}},[t._v("name")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"id"')]),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("\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 literal-property property"}},[t._v("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 "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("ts")]),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 literal-property property"}},[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 literal-property property"}},[t._v("format")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"date-time"')]),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 literal-property property"}},[t._v("r")]),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 literal-property property"}},[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(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("minimum")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("0")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("exclusiveMaximum")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("100")]),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 literal-property property"}},[t._v("id")]),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 literal-property property"}},[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(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("minimum")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("0")]),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("}")]),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 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("{")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\najv"),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(")")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// true")]),t._v("\ndata "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// { ts: '2016-12-01T22:07:28.829Z', r: 25, id: 0 }")]),t._v("\n\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" data1 "),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 punctuation"}},[t._v("}")]),t._v("\najv"),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("data1"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// true")]),t._v("\ndata1 "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// { ts: '2016-12-01T22:07:29.832Z', r: 68, id: 1 }")]),t._v("\n\najv"),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("data1"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// true")]),t._v("\ndata1 "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// didn't change, as all properties were defined")]),t._v("\n")])])]),s("p",[t._v("When using the "),s("code",[t._v("useDefaults")]),t._v(" option value "),s("code",[t._v('"empty"')]),t._v(", properties and items equal to "),s("code",[t._v("null")]),t._v(" or "),s("code",[t._v('""')]),t._v(" (empty string) will be considered missing and assigned defaults. Use "),s("code",[t._v("allOf")]),t._v(" "),s("a",{attrs:{href:"https://github.com/epoberezkin/ajv/blob/master/KEYWORDS.md#compound-keywords",target:"_blank",rel:"noopener noreferrer"}},[t._v("compound keyword"),s("OutboundLink")],1),t._v(" to execute "),s("code",[t._v("dynamicDefaults")]),t._v(" before validation.")]),t._v(" "),s("div",{staticClass:"language-javascript extra-class"},[s("pre",{pre:!0,attrs:{class:"language-javascript"}},[s("code",[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 "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[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('"object"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("allOf")]),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 "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("dynamicDefaults")]),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 literal-property property"}},[t._v("ts")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"datetime"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("r")]),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 literal-property property"}},[t._v("func")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"randomint"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("args")]),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 literal-property property"}},[t._v("min")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("5")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("max")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("100")]),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("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("id")]),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 literal-property property"}},[t._v("func")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"seq"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("args")]),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 literal-property property"}},[t._v("name")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"id"')]),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("\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("}")]),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 literal-property property"}},[t._v("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 "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("ts")]),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 literal-property property"}},[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("}")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("r")]),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 literal-property property"}},[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('"number"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("minimum")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("5")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("exclusiveMaximum")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("100")]),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 literal-property property"}},[t._v("id")]),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 literal-property property"}},[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(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("minimum")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("0")]),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("}")]),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("]")]),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 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("{")]),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("ts")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('""')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("r")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("null")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\najv"),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(")")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// true")]),t._v("\ndata "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// { ts: '2016-12-01T22:07:28.829Z', r: 25, id: 0 }")]),t._v("\n")])])]),s("p",[t._v("You can add your own dynamic default function to be recognised by this keyword:")]),t._v(" "),s("div",{staticClass:"language-javascript extra-class"},[s("pre",{pre:!0,attrs:{class:"language-javascript"}},[s("code",[s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" uuid "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("require")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"uuid"')]),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(" def "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("require")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"ajv-keywords/dist/definitions/dynamicDefaults"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\ndef"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),s("span",{pre:!0,attrs:{class:"token constant"}},[t._v("DEFAULTS")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),s("span",{pre:!0,attrs:{class:"token function-variable function"}},[t._v("uuid")]),t._v(" "),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 punctuation"}},[t._v(")")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=>")]),t._v(" uuid"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("v4\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 "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("dynamicDefaults")]),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 literal-property property"}},[t._v("id")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"uuid"')]),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 literal-property property"}},[t._v("properties")]),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 literal-property property"}},[t._v("id")]),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 literal-property property"}},[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(" "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("format")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"uuid"')]),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("\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(" data "),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 punctuation"}},[t._v("}")]),t._v("\najv"),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("schema"),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(" "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// true")]),t._v("\ndata "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// { id: 'a1183fbe-697b-4030-9bcc-cfeb282a9150' };")]),t._v("\n\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" data1 "),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 punctuation"}},[t._v("}")]),t._v("\najv"),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("schema"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" data1"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// true")]),t._v("\ndata1 "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// { id: '5b008de7-1669-467a-a5c6-70fa244d7209' }")]),t._v("\n")])])]),s("p",[t._v("You also can define dynamic default that accept parameters, e.g. version of uuid:")]),t._v(" "),s("div",{staticClass:"language-javascript extra-class"},[s("pre",{pre:!0,attrs:{class:"language-javascript"}},[s("code",[s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" uuid "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("require")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"uuid"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),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("getUuid")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token parameter"}},[t._v("args")]),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("const")]),t._v(" version "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"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("(")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("arvs "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("&&")]),t._v(" args"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("v"),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 string"}},[t._v('"4"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("return")]),t._v(" uuid"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),t._v("version"),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 keyword"}},[t._v("const")]),t._v(" def "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("require")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"ajv-keywords/dist/definitions/dynamicDefaults"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\ndef"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),s("span",{pre:!0,attrs:{class:"token constant"}},[t._v("DEFAULTS")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("uuid "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" getUuid\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 "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("dynamicDefaults")]),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 literal-property property"}},[t._v("id1")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"uuid"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// v4")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("id2")]),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 literal-property property"}},[t._v("func")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"uuid"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("v")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("4")]),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("// v4")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("id3")]),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 literal-property property"}},[t._v("func")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"uuid"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("v")]),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("}")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// v1")]),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")])])]),s("p",[s("strong",[t._v("Please note")]),t._v(": dynamic default functions are differentiated by the number of parameters they have ("),s("code",[t._v("function.length")]),t._v("). Functions that do not expect default must have one non-optional argument so that "),s("code",[t._v("function.length")]),t._v(" > 0.")]),t._v(" "),s("p",[s("code",[t._v("dynamicDefaults")]),t._v(" is not supported in "),s("a",{attrs:{href:"https://github.com/ajv-validator/ajv/blob/master/docs/standalone.md",target:"_blank",rel:"noopener noreferrer"}},[t._v("standalone validation code"),s("OutboundLink")],1),t._v(".")]),t._v(" "),s("h2",{attrs:{id:"security-contact"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#security-contact"}},[t._v("#")]),t._v(" Security contact")]),t._v(" "),s("p",[t._v("To report a security vulnerability, please use the\n"),s("a",{attrs:{href:"https://tidelift.com/security",target:"_blank",rel:"noopener noreferrer"}},[t._v("Tidelift security contact"),s("OutboundLink")],1),t._v(".\nTidelift will coordinate the fix and disclosure.")]),t._v(" "),s("p",[t._v("Please do NOT report security vulnerabilities via GitHub issues.")]),t._v(" "),s("h2",{attrs:{id:"open-source-software-support"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#open-source-software-support"}},[t._v("#")]),t._v(" Open-source software support")]),t._v(" "),s("p",[t._v("Ajv-keywords is a part of "),s("a",{attrs:{href:"https://tidelift.com/subscription/pkg/npm-ajv-keywords?utm_source=npm-ajv-keywords&utm_medium=referral&utm_campaign=readme",target:"_blank",rel:"noopener noreferrer"}},[t._v("Tidelift subscription"),s("OutboundLink")],1),t._v(" - it provides a centralised support to open-source software users, in addition to the support provided by software maintainers.")]),t._v(" "),s("h2",{attrs:{id:"license"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#license"}},[t._v("#")]),t._v(" License")]),t._v(" "),s("p",[s("a",{attrs:{href:"https://github.com/epoberezkin/ajv-keywords/blob/master/LICENSE",target:"_blank",rel:"noopener noreferrer"}},[t._v("MIT"),s("OutboundLink")],1)])])}),[],!1,null,null,null);s.default=r.exports}}]); \ No newline at end of file diff --git a/assets/js/81.27890529.js b/assets/js/81.27890529.js new file mode 100644 index 000000000..a9493ca24 --- /dev/null +++ b/assets/js/81.27890529.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[81],{511:function(e,t,a){"use strict";a.r(t);var s=a(14),r=Object(s.a)({},(function(){var e=this,t=e._self._c;return t("ContentSlotsDistributor",{attrs:{"slot-key":e.$parent.slotKey}},[t("h1",{attrs:{id:"security-considerations"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#security-considerations"}},[e._v("#")]),e._v(" Security considerations")]),e._v(" "),t("p",[e._v("JSON Schema, if properly used, can replace data sanitisation. It doesn't replace other API security considerations. It also introduces additional security aspects to consider.")]),e._v(" "),t("p"),t("div",{staticClass:"table-of-contents"},[t("ul",[t("li",[t("a",{attrs:{href:"#security-contact"}},[e._v("Security contact")])]),t("li",[t("a",{attrs:{href:"#untrusted-schemas"}},[e._v("Untrusted schemas")])]),t("li",[t("a",{attrs:{href:"#circular-references-in-javascript-objects"}},[e._v("Circular references in JavaScript objects")])]),t("li",[t("a",{attrs:{href:"#security-risks-of-trusted-schemas"}},[e._v("Security risks of trusted schemas")])]),t("li",[t("a",{attrs:{href:"#redos-attack"}},[e._v("ReDoS attack")])]),t("li",[t("a",{attrs:{href:"#content-security-policy"}},[e._v("Content Security Policy")])])])]),t("p"),e._v(" "),t("h2",{attrs:{id:"security-contact"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#security-contact"}},[e._v("#")]),e._v(" Security contact")]),e._v(" "),t("p",[e._v("To report a security vulnerability, please use the\n"),t("a",{attrs:{href:"https://tidelift.com/security",target:"_blank",rel:"noopener noreferrer"}},[e._v("Tidelift security contact"),t("OutboundLink")],1),e._v(".\nTidelift will coordinate the fix and disclosure. Please do NOT report security vulnerabilities via GitHub issues.")]),e._v(" "),t("h2",{attrs:{id:"untrusted-schemas"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#untrusted-schemas"}},[e._v("#")]),e._v(" Untrusted schemas")]),e._v(" "),t("p",[e._v("Ajv treats JSON schemas as trusted as your application code. This security model is based on the most common use case, when the schemas are static and bundled together with the application.")]),e._v(" "),t("p",[e._v("If your schemas are received from untrusted sources (or generated from untrusted data) there are several scenarios you need to prevent:")]),e._v(" "),t("ul",[t("li",[e._v("compiling schemas can cause stack overflow (if they are too deep)")]),e._v(" "),t("li",[e._v("compiling schemas can be slow (e.g. "),t("a",{attrs:{href:"https://github.com/ajv-validator/ajv/issues/557",target:"_blank",rel:"noopener noreferrer"}},[e._v("#557"),t("OutboundLink")],1),e._v(")")]),e._v(" "),t("li",[e._v("validating certain data can be slow")])]),e._v(" "),t("p",[e._v("It is difficult to predict all the scenarios, but at the very least it may help to limit the size of untrusted schemas (e.g. limit JSON string length) and also the maximum schema object depth (that can be high for relatively small JSON strings). You also may want to mitigate slow regular expressions in "),t("code",[e._v("pattern")]),e._v(" and "),t("code",[e._v("patternProperties")]),e._v(" keywords.")]),e._v(" "),t("p",[e._v("Regardless the measures you take, using untrusted schemas increases security risks.")]),e._v(" "),t("h2",{attrs:{id:"circular-references-in-javascript-objects"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#circular-references-in-javascript-objects"}},[e._v("#")]),e._v(" Circular references in JavaScript objects")]),e._v(" "),t("p",[e._v("Ajv does not support schemas and validated data that have circular references in objects. See "),t("a",{attrs:{href:"https://github.com/ajv-validator/ajv/issues/802",target:"_blank",rel:"noopener noreferrer"}},[e._v("issue #802"),t("OutboundLink")],1),e._v(".")]),e._v(" "),t("p",[e._v("An attempt to compile such schemas or validate such data would cause stack overflow (or will not complete in case of asynchronous validation). Depending on the parser you use, untrusted data can lead to circular references.")]),e._v(" "),t("h2",{attrs:{id:"security-risks-of-trusted-schemas"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#security-risks-of-trusted-schemas"}},[e._v("#")]),e._v(" Security risks of trusted schemas")]),e._v(" "),t("p",[e._v("Some keywords in JSON Schemas can lead to very slow validation for certain data. These keywords include (but may be not limited to):")]),e._v(" "),t("ul",[t("li",[t("code",[e._v("pattern")]),e._v(" and "),t("code",[e._v("format")]),e._v(" for large strings - in some cases using "),t("code",[e._v("maxLength")]),e._v(" can help mitigate it, but certain regular expressions can lead to exponential validation time even with relatively short strings (see "),t("a",{attrs:{href:"#redos-attack"}},[e._v("ReDoS attack")]),e._v(").")]),e._v(" "),t("li",[t("code",[e._v("patternProperties")]),e._v(" for large property names - use "),t("code",[e._v("propertyNames")]),e._v(" to mitigate, but some regular expressions can have exponential evaluation time as well.")]),e._v(" "),t("li",[t("code",[e._v("uniqueItems")]),e._v(" for large non-scalar arrays - use "),t("code",[e._v("maxItems")]),e._v(" to mitigate")])]),e._v(" "),t("div",{staticClass:"custom-block danger"},[t("p",{staticClass:"custom-block-title"},[e._v("Do NOT use allErrors in production")]),e._v(" "),t("p",[e._v("The suggestions above to prevent slow validation would only work if you do NOT use "),t("code",[e._v("allErrors: true")]),e._v(" in production code (using it would continue validation after validation errors).")])]),e._v(" "),t("p",[e._v("You can validate your JSON schemas against "),t("a",{attrs:{href:"https://github.com/ajv-validator/ajv/blob/master/lib/refs/json-schema-secure.json",target:"_blank",rel:"noopener noreferrer"}},[e._v("this meta-schema"),t("OutboundLink")],1),e._v(" to check that these recommendations are followed:")]),e._v(" "),t("div",{staticClass:"language-javascript extra-class"},[t("pre",{pre:!0,attrs:{class:"language-javascript"}},[t("code",[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("{")]),t("span",{pre:!0,attrs:{class:"token literal-property property"}},[e._v("strictTypes")]),t("span",{pre:!0,attrs:{class:"token operator"}},[e._v(":")]),e._v(" "),t("span",{pre:!0,attrs:{class:"token boolean"}},[e._v("false")]),t("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("}")]),t("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(")")]),e._v(" "),t("span",{pre:!0,attrs:{class:"token comment"}},[e._v("// this option is required for this schema")]),e._v("\n"),t("span",{pre:!0,attrs:{class:"token keyword"}},[e._v("const")]),e._v(" isSchemaSecure "),t("span",{pre:!0,attrs:{class:"token operator"}},[e._v("=")]),e._v(" ajv"),t("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(".")]),t("span",{pre:!0,attrs:{class:"token function"}},[e._v("compile")]),t("span",{pre:!0,attrs:{class:"token punctuation"}},[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/lib/refs/json-schema-secure.json"')]),t("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(")")]),t("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(")")]),e._v("\n\n"),t("span",{pre:!0,attrs:{class:"token keyword"}},[e._v("const")]),e._v(" schema1 "),t("span",{pre:!0,attrs:{class:"token operator"}},[e._v("=")]),e._v(" "),t("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("{")]),t("span",{pre:!0,attrs:{class:"token literal-property property"}},[e._v("format")]),t("span",{pre:!0,attrs:{class:"token operator"}},[e._v(":")]),e._v(" "),t("span",{pre:!0,attrs:{class:"token string"}},[e._v('"email"')]),t("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("}")]),e._v("\n"),t("span",{pre:!0,attrs:{class:"token function"}},[e._v("isSchemaSecure")]),t("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("(")]),e._v("schema1"),t("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(")")]),e._v(" "),t("span",{pre:!0,attrs:{class:"token comment"}},[e._v("// false")]),e._v("\n\n"),t("span",{pre:!0,attrs:{class:"token keyword"}},[e._v("const")]),e._v(" schema2 "),t("span",{pre:!0,attrs:{class:"token operator"}},[e._v("=")]),e._v(" "),t("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("{")]),t("span",{pre:!0,attrs:{class:"token literal-property property"}},[e._v("format")]),t("span",{pre:!0,attrs:{class:"token operator"}},[e._v(":")]),e._v(" "),t("span",{pre:!0,attrs:{class:"token string"}},[e._v('"email"')]),t("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(",")]),e._v(" "),t("span",{pre:!0,attrs:{class:"token literal-property property"}},[e._v("maxLength")]),t("span",{pre:!0,attrs:{class:"token operator"}},[e._v(":")]),e._v(" "),t("span",{pre:!0,attrs:{class:"token constant"}},[e._v("MAX_LENGTH")]),t("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("}")]),e._v("\n"),t("span",{pre:!0,attrs:{class:"token function"}},[e._v("isSchemaSecure")]),t("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("(")]),e._v("schema2"),t("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(")")]),e._v(" "),t("span",{pre:!0,attrs:{class:"token comment"}},[e._v("// true")]),e._v("\n")])])]),t("div",{staticClass:"custom-block danger"},[t("p",{staticClass:"custom-block-title"},[e._v("Untrusted data")]),e._v(" "),t("p",[e._v("Following all these recommendation is not a guarantee that validation using of untrusted data is safe - it can still lead to some undesirable results.")])]),e._v(" "),t("h2",{attrs:{id:"redos-attack"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#redos-attack"}},[e._v("#")]),e._v(" ReDoS attack")]),e._v(" "),t("p",[e._v("Certain regular expressions can lead to the exponential evaluation time even with relatively short strings.")]),e._v(" "),t("p",[e._v("Please assess the regular expressions you use in the schemas on their vulnerability to this attack - see "),t("a",{attrs:{href:"https://github.com/substack/safe-regex",target:"_blank",rel:"noopener noreferrer"}},[e._v("safe-regex"),t("OutboundLink")],1),e._v(", for example.")]),e._v(" "),t("p",[e._v("By default, Ajv uses the regex engine built into Node.js. This engine has exponential worst-case performance. This performance (and ReDoS attacks) can be mitigated by using a linear-time regex engine. Ajv supports the use of a third-party regex engine for this purpose.")]),e._v(" "),t("p",[e._v("To use a third-party regex engine in Ajv, set the ajv.opts.code.regExp property to that regex engine during instantiation. Here we use Google’s RE2 engine as an example.")]),e._v(" "),t("div",{staticClass:"language- extra-class"},[t("pre",{pre:!0,attrs:{class:"language-text"}},[t("code",[e._v('const Ajv = require("ajv") \nconst RE2 = require("re2") \nconst ajv = new Ajv({code: {regExp: RE2}}) \n')])])]),t("p",[e._v("For details about the interface of the "),t("code",[e._v("regexp")]),e._v(" option, see options.md under the docs folder.")]),e._v(" "),t("p",[e._v("Although linear-time regex engines eliminate ReDoS vulnerabilities, changing a regex engine carries some risk, including:")]),e._v(" "),t("ul",[t("li",[e._v("Minor changes in regex syntax.")]),e._v(" "),t("li",[e._v("Minor changes in regex semantics. For example, RE2 always interprets regexes in Unicode, and disagrees with JavaScript in its definition of whitespace. To avoid regressions, develop and test your regexes in the same regex engine that you use in production.")]),e._v(" "),t("li",[e._v("May not support some advanced features, such as look-aheads or back-references.")]),e._v(" "),t("li",[e._v("May have (minor) common-case performance degradation.")]),e._v(" "),t("li",[e._v("Increases size of distributable (e.g. RE2 includes a non-trivial C component).")])]),e._v(" "),t("div",{staticClass:"custom-block warning"},[t("p",{staticClass:"custom-block-title"},[e._v("ReDoS attack")]),e._v(" "),t("p",[e._v("Some formats that "),t("a",{attrs:{href:"https://github.com/ajv-validator/ajv-formats",target:"_blank",rel:"noopener noreferrer"}},[e._v("ajv-formats"),t("OutboundLink")],1),e._v(" package implements use "),t("a",{attrs:{href:"https://github.com/ajv-validator/ajv-formats/blob/master/src/formats.ts",target:"_blank",rel:"noopener noreferrer"}},[e._v("regular expressions"),t("OutboundLink")],1),e._v(" that can be vulnerable to ReDoS attack.")])]),e._v(" "),t("p",[e._v("If you use Ajv to validate data from untrusted sources "),t("strong",[e._v("it is strongly recommended")]),e._v(" to consider the following:")]),e._v(" "),t("ul",[t("li",[e._v('making assessment of "format" implementations in '),t("a",{attrs:{href:"https://github.com/ajv-validator/ajv-formats",target:"_blank",rel:"noopener noreferrer"}},[e._v("ajv-formats"),t("OutboundLink")],1),e._v(".")]),e._v(" "),t("li",[e._v("passing "),t("code",[e._v('"fast"')]),e._v(" option to ajv-formats plugin (see its docs) that simplifies some of the regular expressions (although it does not guarantee that they are safe).")]),e._v(" "),t("li",[e._v('replacing format implementations provided by ajv-formats with your own implementations of "format" keyword that either use different regular expressions or another approach to format validation. Please see '),t("a",{attrs:{href:"https://github.com/ajv-validator/ajv/blob/master/docs/api.md#api-addformat",target:"_blank",rel:"noopener noreferrer"}},[e._v("addFormat"),t("OutboundLink")],1),e._v(" method.")]),e._v(" "),t("li",[e._v('disabling format validation by ignoring "format" keyword with option '),t("code",[e._v("format: false")])])]),e._v(" "),t("p",[e._v("Whatever mitigation you choose, please assume all formats provided by ajv-formats as potentially unsafe and make your own assessment of their suitability for your validation scenarios.")]),e._v(" "),t("h2",{attrs:{id:"content-security-policy"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#content-security-policy"}},[e._v("#")]),e._v(" Content Security Policy")]),e._v(" "),t("p",[e._v("When using Ajv in a browser page with enabled Content Security Policy (CSP), "),t("code",[e._v("script-src")]),e._v(" directive must include "),t("code",[e._v("'unsafe-eval'")]),e._v(".")]),e._v(" "),t("div",{staticClass:"custom-block danger"},[t("p",{staticClass:"custom-block-title"},[e._v("Cross-site scripting attacks")]),e._v(" "),t("p",[t("code",[e._v("unsafe-eval")]),e._v(" is NOT recommended in a secure CSP"),t("a",{attrs:{href:"https://developer.chrome.com/extensions/contentSecurityPolicy#relaxing-eval",target:"_blank",rel:"noopener noreferrer"}},[e._v("[1]"),t("OutboundLink")],1),e._v(", as it has the potential to open the document to cross-site scripting (XSS) attacks.")])]),e._v(" "),t("p",[e._v("In order to use Ajv without relaxing CSP, you can "),t("a",{attrs:{href:"https://github.com/ajv-validator/ajv-cli#compile-schemas",target:"_blank",rel:"noopener noreferrer"}},[e._v("compile the schemas using CLI"),t("OutboundLink")],1),e._v(" or programmatically in your build code - see "),t("RouterLink",{attrs:{to:"/standalone.html"}},[e._v("Standalone validation code")]),e._v(". Compiled JavaScript file can export one or several validation functions that have the same code as the schemas compiled at runtime.")],1)])}),[],!1,null,null,null);t.default=r.exports}}]); \ No newline at end of file diff --git a/assets/js/82.85c05c4e.js b/assets/js/82.85c05c4e.js new file mode 100644 index 000000000..cfe10647b --- /dev/null +++ b/assets/js/82.85c05c4e.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[82],{512: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:"standalone-validation-code"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#standalone-validation-code"}},[t._v("#")]),t._v(" Standalone validation code")]),t._v(" "),s("p"),s("div",{staticClass:"table-of-contents"},[s("ul",[s("li",[s("a",{attrs:{href:"#two-step-process"}},[t._v("Two-step process")]),s("ul",[s("li",[s("a",{attrs:{href:"#generating-function-s-using-cli"}},[t._v("Generating function(s) using CLI")]),s("ul",[s("li",[s("a",{attrs:{href:"#using-the-defaults-es6-and-cjs-exports"}},[t._v("Using the defaults - ES6 and CJS exports")])])])]),s("li",[s("a",{attrs:{href:"#generating-using-the-js-library"}},[t._v("Generating using the JS library")]),s("ul",[s("li",[s("a",{attrs:{href:"#generating-functions-s-for-a-single-schema-using-the-js-library-es6-and-cjs-exports"}},[t._v("Generating functions(s) for a single schema using the JS library - ES6 and CJS exports")])]),s("li",[s("a",{attrs:{href:"#generating-functions-s-for-multiple-schemas-using-the-js-library-es6-and-cjs-exports"}},[t._v("Generating functions(s) for multiple schemas using the JS library - ES6 and CJS exports")])]),s("li",[s("a",{attrs:{href:"#generating-functions-s-for-multiple-schemas-using-the-js-library-es6-and-esm-exports"}},[t._v("Generating functions(s) for multiple schemas using the JS library - ES6 and ESM exports")])])])])])]),s("li",[s("a",{attrs:{href:"#using-the-validation-function-s"}},[t._v("Using the validation function(s)")]),s("ul",[s("li",[s("a",{attrs:{href:"#validating-a-single-schemas-using-the-js-library-es6-and-cjs"}},[t._v("Validating a single schemas using the JS library - ES6 and CJS")])]),s("li",[s("a",{attrs:{href:"#validating-multiple-schemas-using-the-js-library-es6-and-cjs"}},[t._v("Validating multiple schemas using the JS library - ES6 and CJS")])]),s("li",[s("a",{attrs:{href:"#validating-multiple-schemas-using-the-js-library-es6-and-esm"}},[t._v("Validating multiple schemas using the JS library - ES6 and ESM")])]),s("li",[s("a",{attrs:{href:"#requirement-at-runtime"}},[t._v("Requirement at runtime")])])])]),s("li",[s("a",{attrs:{href:"#configuration-and-limitations"}},[t._v("Configuration and limitations")])])])]),s("p"),t._v(" "),s("p",[t._v("Ajv supports generating standalone validation functions from JSON Schemas at compile/build time. These functions can then be used during runtime to do validation without initialising Ajv. It is useful for several reasons:")]),t._v(" "),s("ul",[s("li",[t._v("to reduce the browser bundle size - Ajv is not included in the bundle (although if you have a large number of schemas the bundle can become bigger - when the total size of generated validation code is bigger than Ajv code).")]),t._v(" "),s("li",[t._v("to reduce the start-up time - the validation and compilation of schemas will happen during build time.")]),t._v(" "),s("li",[t._v("to avoid dynamic code evaluation with Function constructor (used for schema compilation) - when it is prohibited by the browser page "),s("RouterLink",{attrs:{to:"/security.html#content-security-policy"}},[t._v("Content Security Policy")]),t._v(".")],1)]),t._v(" "),s("p",[t._v("This functionality in Ajv v7 supersedes the deprecated package ajv-pack that can be used with Ajv v6. All schemas, including those with recursive references, formats and user-defined keywords are supported, with few "),s("a",{attrs:{href:"#configuration-and-limitations"}},[t._v("limitations")]),t._v(".")]),t._v(" "),s("h2",{attrs:{id:"two-step-process"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#two-step-process"}},[t._v("#")]),t._v(" Two-step process")]),t._v(" "),s("p",[t._v("The "),s("strong",[t._v("first step")]),t._v(" is to "),s("strong",[t._v("generate")]),t._v(" the standalone validation function code. This is done at compile/build time of your project and the output is a generated JS file. The "),s("strong",[t._v("second step")]),t._v(" is to "),s("strong",[t._v("use")]),t._v(" the generated JS validation function.")]),t._v(" "),s("p",[t._v("There are two methods to generate the code, using either the Ajv CLI or the Ajv JS library. There are also a few different options that can be passed when generating code. Below is just a highlight of a few options:")]),t._v(" "),s("ul",[s("li",[t._v("Set the "),s("code",[t._v("code.source")]),t._v(" (JS) value to true or use the "),s("code",[t._v("compile")]),t._v(" (CLI) command to generate standalone code.")]),t._v(" "),s("li",[t._v("The standalone code can be generated in either ES5 or ES6, it defaults to ES6. Set the "),s("code",[t._v("code.es5")]),t._v(" (JS) value to true or pass the "),s("code",[t._v("--code-es5")]),t._v(" (CLI) flag to true if you want ES5 code.")]),t._v(" "),s("li",[t._v("The standalone code can be generated in either CJS (module.export & require) or ESM (exports & import), it defaults to CJS. Set the "),s("code",[t._v("code.esm")]),t._v(" (JS) value to true or pass the "),s("code",[t._v("--code-esm")]),t._v(" (CLI) flag if you want ESM exported code.")])]),t._v(" "),s("p",[t._v("Note that the way the function is exported, differs if you are exporting a single or multiple schemas. See examples below.")]),t._v(" "),s("h3",{attrs:{id:"generating-function-s-using-cli"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#generating-function-s-using-cli"}},[t._v("#")]),t._v(" Generating function(s) using CLI")]),t._v(" "),s("p",[t._v("In most cases you would use this functionality via "),s("a",{attrs:{href:"https://github.com/ajv-validator/ajv-cli",target:"_blank",rel:"noopener noreferrer"}},[t._v("ajv-cli"),s("OutboundLink")],1),t._v(" (>= 4.0.0) to generate the standalone code that exports the validation function. See "),s("a",{attrs:{href:"https://github.com/ajv-validator/ajv-cli#compile-schemas",target:"_blank",rel:"noopener noreferrer"}},[t._v("ajv-cli"),s("OutboundLink")],1),t._v(" docs and the "),s("a",{attrs:{href:"https://github.com/ajv-validator/ajv-cli#ajv-options",target:"_blank",rel:"noopener noreferrer"}},[t._v("cli options"),s("OutboundLink")],1),t._v(" for additional information.")]),t._v(" "),s("h4",{attrs:{id:"using-the-defaults-es6-and-cjs-exports"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#using-the-defaults-es6-and-cjs-exports"}},[t._v("#")]),t._v(" Using the defaults - ES6 and CJS exports")]),t._v(" "),s("div",{staticClass:"language-sh extra-class"},[s("pre",{pre:!0,attrs:{class:"language-sh"}},[s("code",[s("span",{pre:!0,attrs:{class:"token function"}},[t._v("npm")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("install")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token parameter variable"}},[t._v("-g")]),t._v(" ajv-cli\najv compile "),s("span",{pre:!0,attrs:{class:"token parameter variable"}},[t._v("-s")]),t._v(" schema.json "),s("span",{pre:!0,attrs:{class:"token parameter variable"}},[t._v("-o")]),t._v(" validate_schema.js\n")])])]),s("h3",{attrs:{id:"generating-using-the-js-library"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#generating-using-the-js-library"}},[t._v("#")]),t._v(" Generating using the JS library")]),t._v(" "),s("p",[t._v("Install the package, version >= v7.0.0:")]),t._v(" "),s("div",{staticClass:"language-sh extra-class"},[s("pre",{pre:!0,attrs:{class:"language-sh"}},[s("code",[s("span",{pre:!0,attrs:{class:"token function"}},[t._v("npm")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("install")]),t._v(" ajv\n")])])]),s("h4",{attrs:{id:"generating-functions-s-for-a-single-schema-using-the-js-library-es6-and-cjs-exports"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#generating-functions-s-for-a-single-schema-using-the-js-library-es6-and-cjs-exports"}},[t._v("#")]),t._v(" Generating functions(s) for a single schema using the JS library - ES6 and CJS exports")]),t._v(" "),s("div",{staticClass:"language-javascript extra-class"},[s("pre",{pre:!0,attrs:{class:"language-javascript"}},[s("code",[s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" fs "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("require")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"fs"')]),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(" path "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("require")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"path"')]),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(" Ajv "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("require")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"ajv"')]),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(" standaloneCode "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("require")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"ajv/dist/standalone"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("default\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 "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("$id")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"https://example.com/bar.json"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("$schema")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"http://json-schema.org/draft-07/schema#"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[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('"object"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("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 "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("bar")]),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 literal-property property"}},[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("}")]),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 string-property property"}},[t._v('"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('"bar"')]),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("// The generated code will have a default export:")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// `module.exports = ;module.exports.default = ;`")]),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("{")]),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("code")]),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 literal-property property"}},[t._v("source")]),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("}")]),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 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"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("let")]),t._v(" moduleCode "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("standaloneCode")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("ajv"),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("\n\n"),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// Now you can write the module code to file")]),t._v("\nfs"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("writeFileSync")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("path"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("join")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("__dirname"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"../consume/validate-cjs.js"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" moduleCode"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n")])])]),s("h4",{attrs:{id:"generating-functions-s-for-multiple-schemas-using-the-js-library-es6-and-cjs-exports"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#generating-functions-s-for-multiple-schemas-using-the-js-library-es6-and-cjs-exports"}},[t._v("#")]),t._v(" Generating functions(s) for multiple schemas using the JS library - ES6 and CJS exports")]),t._v(" "),s("div",{staticClass:"language-javascript extra-class"},[s("pre",{pre:!0,attrs:{class:"language-javascript"}},[s("code",[s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" fs "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("require")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"fs"')]),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(" path "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("require")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"path"')]),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(" Ajv "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("require")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"ajv"')]),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(" standaloneCode "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("require")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"ajv/dist/standalone"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("default\n\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" schemaFoo "),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 literal-property property"}},[t._v("$id")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"#/definitions/Foo"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("$schema")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"http://json-schema.org/draft-07/schema#"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[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('"object"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("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 "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("foo")]),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-property property"}},[t._v('"$ref"')]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"#/definitions/Bar"')]),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 keyword"}},[t._v("const")]),t._v(" schemaBar "),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 literal-property property"}},[t._v("$id")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"#/definitions/Bar"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("$schema")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"http://json-schema.org/draft-07/schema#"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[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('"object"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("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 "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("bar")]),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 literal-property property"}},[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("}")]),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 string-property property"}},[t._v('"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('"bar"')]),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("// For CJS, it generates an exports array, will generate")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v('// `exports["#/definitions/Foo"] = ...;exports["#/definitions/Bar"] = ... ;`')]),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("{")]),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("schemas")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),t._v("schemaFoo"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" schemaBar"),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 literal-property property"}},[t._v("code")]),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 literal-property property"}},[t._v("source")]),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("}")]),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 keyword"}},[t._v("let")]),t._v(" moduleCode "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("standaloneCode")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("ajv"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n\n"),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// Now you can write the module code to file")]),t._v("\nfs"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("writeFileSync")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("path"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("join")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("__dirname"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"../consume/validate-cjs.js"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" moduleCode"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n")])])]),s("h4",{attrs:{id:"generating-functions-s-for-multiple-schemas-using-the-js-library-es6-and-esm-exports"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#generating-functions-s-for-multiple-schemas-using-the-js-library-es6-and-esm-exports"}},[t._v("#")]),t._v(" Generating functions(s) for multiple schemas using the JS library - ES6 and ESM exports")]),t._v(" "),s("div",{staticClass:"language-javascript extra-class"},[s("pre",{pre:!0,attrs:{class:"language-javascript"}},[s("code",[s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" fs "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("require")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"fs"')]),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(" path "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("require")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"path"')]),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(" Ajv "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("require")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"ajv"')]),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(" standaloneCode "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("require")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"ajv/dist/standalone"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("default\n\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" schemaFoo "),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 literal-property property"}},[t._v("$id")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"#/definitions/Foo"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("$schema")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"http://json-schema.org/draft-07/schema#"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[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('"object"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("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 "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("foo")]),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-property property"}},[t._v('"$ref"')]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"#/definitions/Bar"')]),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 keyword"}},[t._v("const")]),t._v(" schemaBar "),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 literal-property property"}},[t._v("$id")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"#/definitions/Bar"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("$schema")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"http://json-schema.org/draft-07/schema#"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[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('"object"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("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 "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("bar")]),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 literal-property property"}},[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("}")]),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 string-property property"}},[t._v('"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('"bar"')]),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("// For ESM, the export name needs to be a valid export name, it can not be `export const #/definitions/Foo = ...;` so we")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// need to provide a mapping between a valid name and the $id field. Below will generate")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// `export const Foo = ...;export const Bar = ...;`")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// This mapping would not have been needed if the `$ids` was just `Bar` and `Foo` instead of `#/definitions/Foo`")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// and `#/definitions/Bar` respectfully")]),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("{")]),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("schemas")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),t._v("schemaFoo"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" schemaBar"),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 literal-property property"}},[t._v("code")]),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 literal-property property"}},[t._v("source")]),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(" "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("esm")]),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("}")]),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 keyword"}},[t._v("let")]),t._v(" moduleCode "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("standaloneCode")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),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("\n "),s("span",{pre:!0,attrs:{class:"token string-property property"}},[t._v('"Foo"')]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"#/definitions/Foo"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token string-property property"}},[t._v('"Bar"')]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"#/definitions/Bar"')]),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\n"),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// Now you can write the module code to file")]),t._v("\nfs"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("writeFileSync")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("path"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("join")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("__dirname"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"../consume/validate-esm.mjs"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" moduleCode"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n")])])]),s("div",{staticClass:"custom-block warning"},[s("p",{staticClass:"custom-block-title"},[t._v("ESM name mapping")]),t._v(" "),s("p",[t._v("The ESM version only requires the mapping if the ids are not valid export names. If the $ids were just the\n"),s("code",[t._v("Foo")]),t._v(" and "),s("code",[t._v("Bar")]),t._v(" instead of "),s("code",[t._v("#/definitions/Foo")]),t._v(" and "),s("code",[t._v("#/definitions/Bar")]),t._v(" then the mapping would not be needed.")])]),t._v(" "),s("h2",{attrs:{id:"using-the-validation-function-s"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#using-the-validation-function-s"}},[t._v("#")]),t._v(" Using the validation function(s)")]),t._v(" "),s("h3",{attrs:{id:"validating-a-single-schemas-using-the-js-library-es6-and-cjs"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#validating-a-single-schemas-using-the-js-library-es6-and-cjs"}},[t._v("#")]),t._v(" Validating a single schemas using the JS library - ES6 and CJS")]),t._v(" "),s("div",{staticClass:"language-javascript extra-class"},[s("pre",{pre:!0,attrs:{class:"language-javascript"}},[s("code",[s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" Bar "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("require")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token string"}},[t._v("'./validate-cjs'")]),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(" barPass "),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 literal-property property"}},[t._v("bar")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"something"')]),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(" barFail "),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 comment"}},[t._v('// bar: "something" // <= empty/omitted property that is required')]),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("let")]),t._v(" validateBar "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" Bar\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 operator"}},[t._v("!")]),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("validateBar")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("barPass"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n 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 string"}},[t._v('"ERRORS 1:"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" validateBar"),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(" "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("//Never reaches this because valid")]),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 operator"}},[t._v("!")]),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("validateBar")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("barFail"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n 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 string"}},[t._v('"ERRORS 2:"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" validateBar"),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(" "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("//Errors array gets logged")]),t._v("\n")])])]),s("h3",{attrs:{id:"validating-multiple-schemas-using-the-js-library-es6-and-cjs"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#validating-multiple-schemas-using-the-js-library-es6-and-cjs"}},[t._v("#")]),t._v(" Validating multiple schemas using the JS library - ES6 and CJS")]),t._v(" "),s("div",{staticClass:"language-javascript extra-class"},[s("pre",{pre:!0,attrs:{class:"language-javascript"}},[s("code",[s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" validations "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("require")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token string"}},[t._v("'./validate-cjs'")]),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(" fooPass "),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 literal-property property"}},[t._v("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("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("bar")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"something"')]),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 keyword"}},[t._v("const")]),t._v(" fooFail "),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 literal-property property"}},[t._v("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("\n "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v('// bar: "something" // <= empty/omitted property that is required')]),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 keyword"}},[t._v("let")]),t._v(" validateFoo "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" validations"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"#/definitions/Foo"')]),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 keyword"}},[t._v("if")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("!")]),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("validateFoo")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("fooPass"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n 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 string"}},[t._v('"ERRORS 1:"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" validateFoo"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("errors"),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("//Never reaches this because valid")]),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 operator"}},[t._v("!")]),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("validateFoo")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("fooFail"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n 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 string"}},[t._v('"ERRORS 2:"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" validateFoo"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("errors"),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("//Errors array gets logged")]),t._v("\n\n")])])]),s("h3",{attrs:{id:"validating-multiple-schemas-using-the-js-library-es6-and-esm"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#validating-multiple-schemas-using-the-js-library-es6-and-esm"}},[t._v("#")]),t._v(" Validating multiple schemas using the JS library - ES6 and ESM")]),t._v(" "),s("div",{staticClass:"language-javascript extra-class"},[s("pre",{pre:!0,attrs:{class:"language-javascript"}},[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("Foo"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" Bar"),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("'./validate-multiple-esm.mjs'")]),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(" fooPass "),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 literal-property property"}},[t._v("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("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("bar")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"something"')]),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 keyword"}},[t._v("const")]),t._v(" fooFail "),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 literal-property property"}},[t._v("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("\n "),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v('// bar: "something" // bar: "something" <= empty properties')]),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 keyword"}},[t._v("let")]),t._v(" validateFoo "),s("span",{pre:!0,attrs:{class:"token operator"}},[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 keyword"}},[t._v("if")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("!")]),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("validateFoo")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("fooPass"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n 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 string"}},[t._v('"ERRORS 1:"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" validateFoo"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("errors"),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("//Never reaches here because valid")]),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 operator"}},[t._v("!")]),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("validateFoo")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("fooFail"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n 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 string"}},[t._v('"ERRORS 2:"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" validateFoo"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("errors"),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("//Errors array gets logged")]),t._v("\n")])])]),s("h3",{attrs:{id:"requirement-at-runtime"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#requirement-at-runtime"}},[t._v("#")]),t._v(" Requirement at runtime")]),t._v(" "),s("p",[t._v("One of the main reason for using the standalone mode is to start applications faster to avoid runtime schema compilation.")]),t._v(" "),s("p",[t._v("The standalone generated functions still has a dependency on the Ajv. Specifically on the code in the "),s("a",{attrs:{href:"https://github.com/ajv-validator/ajv/tree/master/lib/runtime",target:"_blank",rel:"noopener noreferrer"}},[t._v("runtime"),s("OutboundLink")],1),t._v(" folder of the package.")]),t._v(" "),s("p",[t._v("Completely isolated validation functions can be generated if desired (won't be for most use cases). Run the generated code through a bundler like ES Build to create completely isolated validation functions that can be imported/required without any dependency on Ajv. This is also not needed if your project is already using a bundler.")]),t._v(" "),s("h2",{attrs:{id:"configuration-and-limitations"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#configuration-and-limitations"}},[t._v("#")]),t._v(" Configuration and limitations")]),t._v(" "),s("p",[t._v("To support standalone code generation:")]),t._v(" "),s("ul",[s("li",[t._v("Ajv option "),s("code",[t._v("code.source")]),t._v(" must be set to "),s("code",[t._v("true")])]),t._v(" "),s("li",[t._v("only "),s("code",[t._v("code")]),t._v(" and "),s("code",[t._v("macro")]),t._v(" user-defined keywords are supported (see "),s("RouterLink",{attrs:{to:"/keywords.html"}},[t._v("User defined keywords")]),t._v(").")],1),t._v(" "),s("li",[t._v("when "),s("code",[t._v("code")]),t._v(" keywords define variables in shared scope using "),s("code",[t._v("gen.scopeValue")]),t._v(", they must provide "),s("code",[t._v("code")]),t._v(" property with the code snippet. See source code of pre-defined keywords for examples in "),s("a",{attrs:{href:"https://github.com/ajv-validator/ajv/blob/master/lib/vocabularies",target:"_blank",rel:"noopener noreferrer"}},[t._v("vocabularies folder"),s("OutboundLink")],1),t._v(".")]),t._v(" "),s("li",[t._v("if formats are used in standalone code, ajv option "),s("code",[t._v("code.formats")]),t._v(" should contain the code snippet that will evaluate to an object with all used format definitions - it can be a call to "),s("code",[t._v('require("...")')]),t._v(" with the correct path (relative to the location of saved module):")])]),t._v(" "),s("div",{staticClass:"language-javascript extra-class"},[s("pre",{pre:!0,attrs:{class:"language-javascript"}},[s("code",[s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("import")]),t._v(" myFormats "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("from")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"./my-formats"')]),t._v("\n"),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("_"),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 "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("formats")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" myFormats"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("code")]),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 literal-property property"}},[t._v("source")]),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 literal-property property"}},[t._v("formats")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" _"),s("span",{pre:!0,attrs:{class:"token template-string"}},[s("span",{pre:!0,attrs:{class:"token template-punctuation string"}},[t._v("`")]),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('require("./my-formats")')]),s("span",{pre:!0,attrs:{class:"token template-punctuation string"}},[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("}")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n\nIf you only use formats from "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),t._v("ajv"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("-")]),t._v("formats"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("https"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("/")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("/")]),t._v("github"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("com"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("/")]),t._v("ajv"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("-")]),t._v("validator"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("/")]),t._v("ajv"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("-")]),t._v("formats"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("this")]),t._v(" option will be "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("set")]),t._v(" by "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("this")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("package")]),t._v(" automatically"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("\n")])])])])}),[],!1,null,null,null);s.default=e.exports}}]); \ No newline at end of file diff --git a/assets/js/83.aeedabc2.js b/assets/js/83.aeedabc2.js new file mode 100644 index 000000000..0a2f4b93f --- /dev/null +++ b/assets/js/83.aeedabc2.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[83],{513:function(t,a,s){"use strict";s.r(a);var e=s(14),r=Object(e.a)({},(function(){var t=this,a=t._self._c;return a("ContentSlotsDistributor",{attrs:{"slot-key":t.$parent.slotKey}},[a("h1",{attrs:{id:"strict-mode"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#strict-mode"}},[t._v("#")]),t._v(" Strict mode")]),t._v(" "),a("p",[t._v("Strict mode intends to prevent any unexpected behaviours or silently ignored mistakes in user schemas. It does not change any validation results compared with the specification, but it makes some schemas invalid and throws exception or logs warning (with "),a("code",[t._v('strict: "log"')]),t._v(" option) in case any restriction is violated.")]),t._v(" "),a("p",[t._v("To disable all strict mode restrictions use option "),a("code",[t._v("strict: false")]),t._v(". Some of the restrictions can be changed with their own options")]),t._v(" "),a("p"),a("div",{staticClass:"table-of-contents"},[a("ul",[a("li",[a("a",{attrs:{href:"#json-type-definition-schemas"}},[t._v("JSON Type Definition schemas")])]),a("li",[a("a",{attrs:{href:"#json-schema-schemas"}},[t._v("JSON Schema schemas")]),a("ul",[a("li",[a("a",{attrs:{href:"#prohibit-ignored-keywords"}},[t._v("Prohibit ignored keywords "),a("Badge",{attrs:{text:"strictSchema option"}})],1),a("ul",[a("li",[a("a",{attrs:{href:"#unknown-keywords"}},[t._v("Unknown keywords")])]),a("li",[a("a",{attrs:{href:"#ignored-additionalitems-keyword"}},[t._v('Ignored "additionalItems" keyword')])]),a("li",[a("a",{attrs:{href:"#ignored-if-then-else-keywords"}},[t._v('Ignored "if", "then", "else" keywords')])]),a("li",[a("a",{attrs:{href:"#ignored-contains-maxcontains-and-mincontains-keywords"}},[t._v('Ignored "contains", "maxContains" and "minContains" keywords')])]),a("li",[a("a",{attrs:{href:"#unknown-formats"}},[t._v("Unknown formats")])]),a("li",[a("a",{attrs:{href:"#ignored-defaults"}},[t._v("Ignored defaults")])])])]),a("li",[a("a",{attrs:{href:"#prevent-unexpected-validation"}},[t._v("Prevent unexpected validation")]),a("ul",[a("li",[a("a",{attrs:{href:"#overlap-between-properties-and-patternproperties-keywords"}},[t._v('Overlap between "properties" and "patternProperties" keywords '),a("Badge",{attrs:{text:"allowMatchingProperties option"}})],1)]),a("li",[a("a",{attrs:{href:"#defined-required-properties"}},[t._v("Defined required properties "),a("Badge",{attrs:{text:"strictRequired option"}})],1)]),a("li",[a("a",{attrs:{href:"#unconstrained-tuples"}},[t._v("Unconstrained tuples "),a("Badge",{attrs:{text:"strictTuples option"}})],1)])])]),a("li",[a("a",{attrs:{href:"#strict-types"}},[t._v("Strict types "),a("Badge",{attrs:{text:"strictTypes option"}})],1),a("ul",[a("li",[a("a",{attrs:{href:"#union-types"}},[t._v("Union types "),a("Badge",{attrs:{text:"allowUnionTypes option"}})],1)]),a("li",[a("a",{attrs:{href:"#contradictory-types"}},[t._v("Contradictory types")])]),a("li",[a("a",{attrs:{href:"#require-applicable-types"}},[t._v("Require applicable types")])])])]),a("li",[a("a",{attrs:{href:"#strict-number-validation"}},[t._v("Strict number validation "),a("Badge",{attrs:{text:"strictNumbers option"}})],1)])])])])]),a("p"),t._v(" "),a("h2",{attrs:{id:"json-type-definition-schemas"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#json-type-definition-schemas"}},[t._v("#")]),t._v(" JSON Type Definition schemas")]),t._v(" "),a("p",[t._v("JTD specification is strict - whether Ajv strict mode is enabled or not it will not allow schemas with ignored or ambiguous elements, including:")]),t._v(" "),a("ul",[a("li",[t._v("unknown schema keywords")]),t._v(" "),a("li",[t._v("combining multiple schema forms in one schema")]),t._v(" "),a("li",[t._v("defining the same property as both required and optional")]),t._v(" "),a("li",[t._v("re-defining discriminator tag inside properties, even if the definition is non-contradictory")])]),t._v(" "),a("p",[t._v("See "),a("RouterLink",{attrs:{to:"/json-type-definition.html"}},[t._v("JSON Type Definition")]),t._v(" for informal and "),a("a",{attrs:{href:"https://datatracker.ietf.org/doc/rfc8927/",target:"_blank",rel:"noopener noreferrer"}},[t._v("RFC8927"),a("OutboundLink")],1),t._v(" for formal specification descriptions.")],1),t._v(" "),a("p",[t._v("The only change that strict mode introduces to JTD schemas, without changing their syntax or semantics, is the requirement that all members that are present in optional "),a("code",[t._v("metadata")]),t._v(" members are defined as Ajv keywords. This restriction can be disabled with "),a("code",[t._v("strict: false")]),t._v(" option, without any impact to other JTD features.")]),t._v(" "),a("h2",{attrs:{id:"json-schema-schemas"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#json-schema-schemas"}},[t._v("#")]),t._v(" JSON Schema schemas")]),t._v(" "),a("p",[t._v("JSON Schema specification is very permissive and allows many elements in the schema to be quietly ignored or be ambiguous. It is recommended to use JSON Schema with strict mode.")]),t._v(" "),a("p",[t._v("Option "),a("code",[t._v("strict")]),t._v(" with value "),a("code",[t._v("true")]),t._v("/"),a("code",[t._v("false")]),t._v("/"),a("code",[t._v('"log"')]),t._v(" can be used to set all strict mode restriction to be the same, otherwise individual strict mode options can be used. See "),a("RouterLink",{attrs:{to:"/options.html#strict-mode-options"}},[t._v("Strict mode options")]),t._v(".")],1),t._v(" "),a("h3",{attrs:{id:"prohibit-ignored-keywords"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#prohibit-ignored-keywords"}},[t._v("#")]),t._v(" Prohibit ignored keywords "),a("Badge",{attrs:{text:"strictSchema option"}})],1),t._v(" "),a("h4",{attrs:{id:"unknown-keywords"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#unknown-keywords"}},[t._v("#")]),t._v(" Unknown keywords")]),t._v(" "),a("p",[t._v("JSON Schema "),a("a",{attrs:{href:"https://tools.ietf.org/html/draft-handrews-json-schema-02#section-6.5",target:"_blank",rel:"noopener noreferrer"}},[t._v("section 6.5"),a("OutboundLink")],1),t._v(" requires to ignore unknown keywords. The motivation is to increase cross-platform portability of schemas, so that implementations that do not support certain keywords can still do partial validation.")]),t._v(" "),a("p",[t._v("The problems with this approach are:")]),t._v(" "),a("ul",[a("li",[t._v("Different validation results with the same schema and data, leading to bugs and inconsistent behaviours.")]),t._v(" "),a("li",[t._v("Typos in keywords resulting in keywords being quietly ignored, requiring extensive test coverage of schemas to avoid these mistakes.")])]),t._v(" "),a("p",[t._v("By default Ajv fails schema compilation when unknown keywords are used. Users can explicitly define the keywords that should be allowed and ignored:")]),t._v(" "),a("div",{staticClass:"language-javascript extra-class"},[a("pre",{pre:!0,attrs:{class:"language-javascript"}},[a("code",[t._v("ajv"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("addKeyword")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"allowedKeyword"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n")])])]),a("p",[t._v("or use the convenience method "),a("code",[t._v("addVocabulary")]),t._v(" for multiple keywords")]),t._v(" "),a("div",{staticClass:"language-javascript extra-class"},[a("pre",{pre:!0,attrs:{class:"language-javascript"}},[a("code",[t._v("ajv"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("addVocabulary")]),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 string"}},[t._v('"allowed1"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"allowed2"')]),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("// simply calls addKeyword multiple times")]),t._v("\n")])])]),a("h4",{attrs:{id:"ignored-additionalitems-keyword"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#ignored-additionalitems-keyword"}},[t._v("#")]),t._v(' Ignored "additionalItems" keyword')]),t._v(" "),a("p",[t._v("JSON Schema section "),a("a",{attrs:{href:"https://tools.ietf.org/html/draft-handrews-json-schema-02#section-9.3.1.2",target:"_blank",rel:"noopener noreferrer"}},[t._v("9.3.1.2"),a("OutboundLink")],1),t._v(' requires to ignore "additionalItems" keyword if "items" keyword is absent or if it is not an array of items. This is inconsistent with the interaction of "additionalProperties" and "properties", and may cause unexpected results.')]),t._v(" "),a("p",[t._v('By default Ajv fails schema compilation when "additionalItems" is used without "items" (or if "items" is not an array).')]),t._v(" "),a("h4",{attrs:{id:"ignored-if-then-else-keywords"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#ignored-if-then-else-keywords"}},[t._v("#")]),t._v(' Ignored "if", "then", "else" keywords')]),t._v(" "),a("p",[t._v("JSON Schema section "),a("a",{attrs:{href:"https://tools.ietf.org/html/draft-handrews-json-schema-02#section-9.2.2",target:"_blank",rel:"noopener noreferrer"}},[t._v("9.2.2"),a("OutboundLink")],1),t._v(' requires to ignore "if" (only annotations are collected) if both "then" and "else" are absent, and ignore "then"/"else" if "if" is absent.')]),t._v(" "),a("p",[t._v("By default Ajv fails schema compilation in these cases.")]),t._v(" "),a("h4",{attrs:{id:"ignored-contains-maxcontains-and-mincontains-keywords"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#ignored-contains-maxcontains-and-mincontains-keywords"}},[t._v("#")]),t._v(' Ignored "contains", "maxContains" and "minContains" keywords')]),t._v(" "),a("p",[t._v("JSON Schema sections "),a("a",{attrs:{href:"https://json-schema.org/draft/2019-09/json-schema-validation.html#rfc.section.6.4.4",target:"_blank",rel:"noopener noreferrer"}},[t._v("6.4.4, 6.4.5"),a("OutboundLink")],1),t._v(' require to ignore keywords "maxContains" and "minContains" if "contains" keyword is absent.')]),t._v(" "),a("p",[t._v('It is also implied that when "minContains" is 0 and "maxContains" is absent, "contains" keyword is always valid.')]),t._v(" "),a("p",[t._v("By default Ajv fails schema compilation in these cases.")]),t._v(" "),a("h4",{attrs:{id:"unknown-formats"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#unknown-formats"}},[t._v("#")]),t._v(" Unknown formats")]),t._v(" "),a("p",[t._v("By default unknown formats throw exception during schema compilation (and fail validation in case format keyword value is "),a("RouterLink",{attrs:{to:"/guide/combining-schemas.html#data-reference"}},[t._v("$data reference")]),t._v("). It is possible to opt out of format validation completely with options "),a("code",[t._v("validateFormats: false")]),t._v(". You can define all known formats with "),a("code",[t._v("addFormat")]),t._v(" method or "),a("code",[t._v("formats")]),t._v(" option - to have some format ignored pass "),a("code",[t._v("true")]),t._v(" as its definition:")],1),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("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token literal-property property"}},[t._v("reserved")]),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("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n")])])]),a("p",[t._v("Standard JSON Schema formats are provided in "),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(" package - see "),a("a",{attrs:{href:"./guide/formats"}},[t._v("Formats")]),t._v(" section.")]),t._v(" "),a("h4",{attrs:{id:"ignored-defaults"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#ignored-defaults"}},[t._v("#")]),t._v(" Ignored defaults")]),t._v(" "),a("p",[t._v("With "),a("code",[t._v("useDefaults")]),t._v(" option Ajv modifies validated data by assigning defaults from the schema, but there are different limitations when the defaults can be ignored (see "),a("RouterLink",{attrs:{to:"/guide/modifying-data.html#assigning-defaults"}},[t._v("Assigning defaults")]),t._v("). In strict mode Ajv fails schema compilation if such defaults are used in the schema.")],1),t._v(" "),a("h3",{attrs:{id:"prevent-unexpected-validation"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#prevent-unexpected-validation"}},[t._v("#")]),t._v(" Prevent unexpected validation")]),t._v(" "),a("h4",{attrs:{id:"overlap-between-properties-and-patternproperties-keywords"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#overlap-between-properties-and-patternproperties-keywords"}},[t._v("#")]),t._v(' Overlap between "properties" and "patternProperties" keywords '),a("Badge",{attrs:{text:"allowMatchingProperties option"}})],1),t._v(" "),a("p",[t._v('The expectation of users (see #196, #286) is that "patternProperties" only apply to properties not already defined in "properties" keyword, but JSON Schema section '),a("a",{attrs:{href:"https://tools.ietf.org/html/draft-handrews-json-schema-02#section-9.3.2",target:"_blank",rel:"noopener noreferrer"}},[t._v("9.3.2"),a("OutboundLink")],1),t._v(' defines these two keywords as independent. It means that to some properties two subschemas can be applied - one defined in "properties" keyword and another defined in "patternProperties" for the pattern matching this property.')]),t._v(" "),a("p",[t._v('By default Ajv fails schema compilation if a pattern in "patternProperties" matches a property in "properties" in the same schema.')]),t._v(" "),a("p",[t._v("In addition to allowing such patterns by using option "),a("code",[t._v("strict: false")]),t._v(" or "),a("code",[t._v("strictSchema: false")]),t._v(", there is an option "),a("code",[t._v("allowMatchingProperties: true")]),t._v(" to only allow this case without disabling other strict mode restrictions - there are some rare cases when this is necessary.")]),t._v(" "),a("p",[t._v("To reiterate, neither this nor other strict mode restrictions change the validation results - they only restrict which schemas are valid.")]),t._v(" "),a("h4",{attrs:{id:"defined-required-properties"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#defined-required-properties"}},[t._v("#")]),t._v(" Defined required properties "),a("Badge",{attrs:{text:"strictRequired option"}})],1),t._v(" "),a("p",[t._v("With option "),a("code",[t._v("strictRequired")]),t._v(" set to "),a("code",[t._v('"log"')]),t._v(" or "),a("code",[t._v("true")]),t._v(' Ajv logs warning or throws exception if the property used in "required" keyword is not defined in "properties" keyword in the same or some parent schema relating to the same object (data instance).')]),t._v(" "),a("p",[t._v("By default this option is disabled.")]),t._v(" "),a("div",{staticClass:"custom-block warning"},[a("p",{staticClass:"custom-block-title"},[t._v("Property defined in parent schema")]),t._v(" "),a("p",[t._v("There are cases when property defined in the parent schema will not be taken into account.")])]),t._v(" "),a("h4",{attrs:{id:"unconstrained-tuples"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#unconstrained-tuples"}},[t._v("#")]),t._v(" Unconstrained tuples "),a("Badge",{attrs:{text:"strictTuples option"}})],1),t._v(" "),a("p",[t._v('Ajv also logs a warning if "items" is an array (for schema that defines a tuple) but neither "minItems" nor "additionalItems"/"maxItems" keyword is present (or have a wrong 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 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('"number"')]),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('"boolean"')]),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",[t._v('The above schema may have a mistake, as tuples usually are expected to have a fixed size. To "fix" it:')]),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('"number"')]),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('"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 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")]),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("false")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// or")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// maxItems: 2")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])]),a("p",[t._v("Sometimes users accidentally create schema for unit (a tuple with one item) that only validates the first item, this restriction prevents this mistake as well.")]),t._v(" "),a("p",[t._v("Use "),a("code",[t._v("strictTuples")]),t._v(" option to suppress this warning ("),a("code",[t._v("false")]),t._v(") or turn it into exception ("),a("code",[t._v("true")]),t._v(").")]),t._v(" "),a("p",[t._v("If you use "),a("code",[t._v("JSONSchemaType")]),t._v(" this mistake will also be prevented on a type level.")]),t._v(" "),a("h3",{attrs:{id:"strict-types"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#strict-types"}},[t._v("#")]),t._v(" Strict types "),a("Badge",{attrs:{text:"strictTypes option"}})],1),t._v(" "),a("p",[t._v("An additional option "),a("code",[t._v("strictTypes")]),t._v(' ("log" by default) imposes additional restrictions on how type keyword is used:')]),t._v(" "),a("h4",{attrs:{id:"union-types"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#union-types"}},[t._v("#")]),t._v(" Union types "),a("Badge",{attrs:{text:"allowUnionTypes option"}})],1),t._v(" "),a("p",[t._v("With "),a("code",[t._v("strictTypes")]),t._v(' option "type" keywords with multiple types (other than with "null") are prohibited.')]),t._v(" "),a("p",[t._v("Invalid:")]),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 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('"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("p",[t._v("Valid:")]),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 punctuation"}},[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(" "),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("p",[t._v("and")]),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("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("Unions can still be defined with "),a("code",[t._v("anyOf")]),t._v(" keyword.")]),t._v(" "),a("p",[t._v('The motivation for this restriction is that "type" is usually not the only keyword in the schema, and mixing other keywords that apply to different types is confusing. It is also consistent with wider range of versions of OpenAPI specification and has better tooling support. E.g., this example violating '),a("code",[t._v("strictTypes")]),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 punctuation"}},[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(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"array"')]),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("minimum")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("0")]),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 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("0")]),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",[t._v("is equivalent to this complying example, that is more verbose but also easier to maintain:")]),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("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("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("0")]),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("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 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("0")]),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("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])]),a("p",[t._v("It also can be refactored:")]),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("$defs")]),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("item")]),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("0")]),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 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("$ref")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"#/$defs/item"')]),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("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 literal-property property"}},[t._v("$ref")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"#/$defs/item"')]),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 punctuation"}},[t._v("}")]),t._v("\n")])])]),a("p",[t._v("This restriction can be lifted separately from other "),a("code",[t._v("strictTypes")]),t._v(" restrictions with "),a("code",[t._v("allowUnionTypes: true")]),t._v(" option.")]),t._v(" "),a("h4",{attrs:{id:"contradictory-types"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#contradictory-types"}},[t._v("#")]),t._v(" Contradictory types")]),t._v(" "),a("p",[t._v("Subschemas can apply to the same data instance, and it is possible to have contradictory type keywords - it usually indicate some mistake. For example:")]),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("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("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("}")]),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('"object"')]),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",[t._v("The schema above violates "),a("code",[t._v("strictTypes")]),t._v(' as "array" type is not compatible with object. If you used '),a("code",[t._v("allowUnionTypes: true")]),t._v(" option, the above schema can be fixed in this way:")]),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 punctuation"}},[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(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"object"')]),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("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("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("}")]),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('"object"')]),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("div",{staticClass:"custom-block tip"},[a("p",{staticClass:"custom-block-title"},[t._v('"number" vs "integer"')]),t._v(" "),a("p",[t._v('Type "number" can be narrowed to "integer", the opposite would violate '),a("code",[t._v("strictTypes")]),t._v(".")])]),t._v(" "),a("h4",{attrs:{id:"require-applicable-types"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#require-applicable-types"}},[t._v("#")]),t._v(" Require applicable types")]),t._v(" "),a("p",[t._v("This simple JSON Schema is valid, but it violates "),a("code",[t._v("strictTypes")]),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("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 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 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(",")]),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("\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])]),a("p",[t._v("This is a very common mistake that even people experienced with JSON Schema often make - the problem here is that any value that is not an object would be valid against this schema - this is rarely intentional.")]),t._v(" "),a("p",[t._v('To fix it, "type" keyword has to be added:')]),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 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(",")]),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("\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])]),a("p",[t._v('You do not necessarily have to have "type" keyword in the same schema object; as long as there is "type" keyword applying to the same part of data instance in the same schema document, not via "$ref", it will be ok:')]),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("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("{")]),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("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("]")]),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("{")]),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("}")]),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("]")]),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",[t._v('Both "properties" and "required" need '),a("code",[t._v('type: "object"')]),t._v(" to satisfy "),a("code",[t._v("strictTypes")]),t._v(" - it is sufficient to have it once in the parent schema, without repeating it in each schema.")]),t._v(" "),a("h3",{attrs:{id:"strict-number-validation"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#strict-number-validation"}},[t._v("#")]),t._v(" Strict number validation "),a("Badge",{attrs:{text:"strictNumbers option"}})],1),t._v(" "),a("p",[t._v("Strict mode also affects number validation. By default Ajv fails "),a("code",[t._v('{"type": "number"}')]),t._v(" (or "),a("code",[t._v('"integer"')]),t._v(") validation for "),a("code",[t._v("Infinity")]),t._v(" and "),a("code",[t._v("NaN")]),t._v(".")])])}),[],!1,null,null,null);a.default=r.exports}}]); \ No newline at end of file diff --git a/assets/js/84.b8472958.js b/assets/js/84.b8472958.js new file mode 100644 index 000000000..fbae6de25 --- /dev/null +++ b/assets/js/84.b8472958.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[84],{514:function(e,t,a){"use strict";a.r(t);var n=a(14),r=Object(n.a)({},(function(){var e=this,t=e._self._c;return t("ContentSlotsDistributor",{attrs:{"slot-key":e.$parent.slotKey}},[t("h1",{attrs:{id:"what-users-say"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#what-users-say"}},[e._v("#")]),e._v(" What users say")]),e._v(" "),t("p",[e._v("In the past 6 years of working on the JSON Schema Specification itself, Ajv stands out as the implementation of choice. It is very well documented and provides a rich API for extending JSON Schema which many thousands of people use in production today. A huge effort was put into testing, with many tests now forming part of the official test suite.")]),e._v(" "),t("p",[e._v("I've personally used Ajv in production to validate requests for a federated undiagnosed genetic disease program that has lead to new scientific discoveries and literally changed lives.")]),e._v(" "),t("p",[e._v("Ajv development can inform the future tooling and specification changes. There's no doubt that Ajv is partly responsible for the ubiquity and success of JSON Schema.")]),e._v(" "),t("p",[t("a",{attrs:{href:"https://github.com/relequestual",target:"_blank",rel:"noopener noreferrer"}},[e._v("Ben Hutton"),t("OutboundLink")],1),e._v(", JSON Schema Specification Lead")]),e._v(" "),t("br"),e._v(" "),t("p",[t("a",{attrs:{href:"https://eslint.org/",target:"_blank",rel:"noopener noreferrer"}},[e._v("ESLint"),t("OutboundLink")],1),e._v(" has used Ajv for validating our complex configurations. Ajv has proven to be reliable over the years we’ve been using it and ESLint is proud to sponsor Ajv’s continued development.")]),e._v(" "),t("p",[t("a",{attrs:{href:"https://github.com/nzakas",target:"_blank",rel:"noopener noreferrer"}},[e._v("Nicholas C. Zakas"),t("OutboundLink")],1),e._v(", ESLint creator and TSC member")]),e._v(" "),t("br"),e._v(" "),t("p",[e._v("I always thought that built-in data validation is a key feature of any web framework. We decided to leverage JSON Schema in "),t("a",{attrs:{href:"https://www.fastify.io",target:"_blank",rel:"noopener noreferrer"}},[e._v("Fastify"),t("OutboundLink")],1),e._v(", and Ajv fits our needs wonderfully: it’s fast, stable and well maintained.")]),e._v(" "),t("p",[t("a",{attrs:{href:"https://github.com/mcollina",target:"_blank",rel:"noopener noreferrer"}},[e._v("Matteo Collina"),t("OutboundLink")],1),e._v(", technical Director "),t("a",{attrs:{href:"https://github.com/nearform",target:"_blank",rel:"noopener noreferrer"}},[e._v("@nearform"),t("OutboundLink")],1),e._v(" and TSC member")]),e._v(" "),t("br"),e._v(" "),t("p",[e._v("Ajv has become a centerpiece of all data-validation logic in my open-source projects and businesses. It is spec-compliant, extensible, fast and has amazing support.")]),e._v(" "),t("p",[t("a",{attrs:{href:"https://github.com/gajus",target:"_blank",rel:"noopener noreferrer"}},[e._v("Gajus Kuizinas"),t("OutboundLink")],1),e._v(", Tech / Product Founder – building\n"),t("a",{attrs:{href:"https://twitter.com/contrahq",target:"_blank",rel:"noopener noreferrer"}},[e._v("@contrahq"),t("OutboundLink")],1)])])}),[],!1,null,null,null);t.default=r.exports}}]); \ No newline at end of file diff --git a/assets/js/85.05c37548.js b/assets/js/85.05c37548.js new file mode 100644 index 000000000..0e3cef339 --- /dev/null +++ b/assets/js/85.05c37548.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[85],{515:function(e,t,a){"use strict";a.r(t);var i=a(14),o=Object(i.a)({},(function(){var e=this,t=e._self._c;return t("ContentSlotsDistributor",{attrs:{"slot-key":e.$parent.slotKey}},[t("h1",{attrs:{id:"changes-from-ajv-v6-12-6-to-v8-0-0"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#changes-from-ajv-v6-12-6-to-v8-0-0"}},[e._v("#")]),e._v(" Changes from Ajv v6.12.6 to v8.0.0")]),e._v(" "),t("p",[e._v("If you are migrating from v7 see "),t("a",{attrs:{href:"https://github.com/ajv-validator/ajv/releases/tag/v8.0.0",target:"_blank",rel:"noopener noreferrer"}},[e._v("v8.0.0 release notes"),t("OutboundLink")],1),e._v(".")]),e._v(" "),t("p"),t("div",{staticClass:"table-of-contents"},[t("ul",[t("li",[t("a",{attrs:{href:"#new-features"}},[e._v("New features")])]),t("li",[t("a",{attrs:{href:"#better-typescript-support"}},[e._v("Better TypeScript support")])]),t("li",[t("a",{attrs:{href:"#potential-migration-difficulties"}},[e._v("Potential migration difficulties")])]),t("li",[t("a",{attrs:{href:"#api-changes"}},[e._v("API changes")]),t("ul",[t("li",[t("a",{attrs:{href:"#added-options"}},[e._v("Added options")])]),t("li",[t("a",{attrs:{href:"#changed-options"}},[e._v("Changed options")])]),t("li",[t("a",{attrs:{href:"#removed-options"}},[e._v("Removed options")])])])])])]),t("p"),e._v(" "),t("h2",{attrs:{id:"new-features"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#new-features"}},[e._v("#")]),e._v(" New features")]),e._v(" "),t("ul",[t("li",[e._v("support new schema specifications:\n"),t("ul",[t("li",[t("RouterLink",{attrs:{to:"/json-type-definition.html"}},[e._v("JSON Type Definition")]),e._v(" "),t("a",{attrs:{href:"https://datatracker.ietf.org/doc/rfc8927/",target:"_blank",rel:"noopener noreferrer"}},[e._v("RFC8927"),t("OutboundLink")],1),e._v(". See "),t("a",{attrs:{href:"https://ajv.js.org/guide/schema-language.html",target:"_blank",rel:"noopener noreferrer"}},[e._v("choosing schema language"),t("OutboundLink")],1),e._v(" for comparison with JSON Schema.")],1),e._v(" "),t("li",[e._v("JSON Schema draft-2020-12: "),t("RouterLink",{attrs:{to:"/json-schema.html#prefixitems"}},[e._v("prefixItems")]),e._v(" keyword and changed semantics of "),t("RouterLink",{attrs:{to:"/json-schema.html#items-in-draft-2020-12"}},[e._v("items")]),e._v(" keyword, "),t("RouterLink",{attrs:{to:"/guide/combining-schemas.html#extending-recursive-schemas"}},[e._v("dynamic recursive references")]),e._v(".")],1),e._v(" "),t("li",[e._v("JSON Schema draft-2019-09 features: "),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")])]),e._v(", "),t("RouterLink",{attrs:{to:"/guide/combining-schemas.html#extending-recursive-schemas"}},[e._v("dynamic recursive references")]),e._v(" and other "),t("RouterLink",{attrs:{to:"/json-schema.html#json-schema-draft-2019-09"}},[e._v("additional keywords")]),e._v(".")],1),e._v(" "),t("li",[e._v("OpenAPI "),t("RouterLink",{attrs:{to:"/json-schema.html#discriminator"}},[e._v("discriminator")]),e._v(" keyword.")],1)])]),e._v(" "),t("li",[e._v("Compiled parsers (as fast as JSON.parse on valid JSON, but replace validation and fail much faster on invalid JSON) and serializers (10x+ faster than JSON.stringify) from JSON Type Definition schemas - see examples in "),t("RouterLink",{attrs:{to:"/guide/getting-started.html#parsing-and-serializing-json"}},[e._v("javascript")]),e._v(" and "),t("RouterLink",{attrs:{to:"/guide/typescript.html#type-safe-parsers-and-serializers"}},[e._v("typescript")]),e._v(".")],1),e._v(" "),t("li",[e._v("comprehensive support for "),t("RouterLink",{attrs:{to:"/standalone.html"}},[e._v("standalone validation code")]),e._v(" - compiling one or multiple schemas to standalone modules with one or multiple exports.")],1),e._v(" "),t("li",[e._v("to reduce the mistakes in JSON schemas and unexpected validation results, "),t("RouterLink",{attrs:{to:"/strict-mode.html"}},[e._v("strict mode")]),e._v(" is added - it prohibits ignored or ambiguous JSON Schema elements. See "),t("RouterLink",{attrs:{to:"/strict-mode.html"}},[e._v("Strict mode")]),e._v(" and "),t("RouterLink",{attrs:{to:"/options.html"}},[e._v("Options")]),e._v(" for more details.")],1),e._v(" "),t("li",[e._v("to make code injection from untrusted schemas impossible, "),t("RouterLink",{attrs:{to:"/codegen.html"}},[e._v("code generation")]),e._v(" is fully re-written to be type-level safe against code injection.")],1),e._v(" "),t("li",[e._v("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.")]),e._v(" "),t("li",[e._v("schemas are compiled to ES6 code (ES5 code generation is supported with an option).")]),e._v(" "),t("li",[e._v("to improve reliability and maintainability the code is migrated to TypeScript.")]),e._v(" "),t("li",[e._v("separate Ajv classes from draft-07, draft-2019-09, draft-2020-12 and JSON Type Definition support with different default imports (see "),t("RouterLink",{attrs:{to:"/guide/getting-started.html"}},[e._v("Getting started")]),e._v(".")],1)]),e._v(" "),t("p",[t("strong",[e._v("Please note")]),e._v(":")]),e._v(" "),t("ul",[t("li",[e._v('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 version 6 that will be supported until 06/30/2021).')]),e._v(" "),t("li",[e._v("all formats are separated to "),t("a",{attrs:{href:"https://github.com/ajv-validator/ajv-formats",target:"_blank",rel:"noopener noreferrer"}},[e._v("ajv-formats"),t("OutboundLink")],1),e._v(" package - they have to be explicitly added if you use them.")]),e._v(" "),t("li",[e._v("Ajv instance can only be created with "),t("code",[e._v("new")]),e._v(" keyword, as Ajv is now ES6 class.")]),e._v(" "),t("li",[e._v("browser bundles are automatically published to ajv-dist package (but still available on cdnjs.com).")]),e._v(" "),t("li",[e._v("order of schema keyword validation changed - keywords that apply to all types (allOf etc.) are now validated first, before the keywords that apply to specific data types. You can still define custom keywords that apply to all types AND are validated after type-specific keywords using option "),t("code",[e._v("post: true")]),e._v(" in keyword definition.")]),e._v(" "),t("li",[e._v('regular expressions in keywords "pattern" and "patternProperties" are now used as if they had unicode "u" flag, as required by JSON Schema specification - it means that some regular expressions that were valid with Ajv v6 are now invalid (and vice versa).')]),e._v(" "),t("li",[e._v("JSON Schema validation errors changes:\n"),t("ul",[t("li",[t("code",[e._v("dataPath")]),e._v(" property replaced with "),t("code",[e._v("instancePath")])]),e._v(" "),t("li",[e._v('"should" replaced with "must" in the messages')]),e._v(" "),t("li",[e._v('property name is removed from "propertyName" keyword error message (it is still available in '),t("code",[e._v("error.params.propertyName")]),e._v(").")])])])]),e._v(" "),t("h2",{attrs:{id:"better-typescript-support"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#better-typescript-support"}},[e._v("#")]),e._v(" Better TypeScript support")]),e._v(" "),t("ul",[t("li",[e._v("Methods "),t("code",[e._v("compile")]),e._v(" and "),t("code",[e._v("compileAsync")]),e._v(" now return type-guards - see "),t("RouterLink",{attrs:{to:"/guide/getting-started.html"}},[e._v("Getting started")]),e._v(".")],1),e._v(" "),t("li",[e._v("Method "),t("code",[e._v("validate")]),e._v(" is a type-guard.")]),e._v(" "),t("li",[e._v("Better separation of asynchronous schemas on type level.")]),e._v(" "),t("li",[e._v("Schema utility types to simplify writing schemas:\n"),t("ul",[t("li",[e._v("JSONSchemaType: generates the type for JSON Schema for type interface in the type parameter.")]),e._v(" "),t("li",[e._v("JTDSchemaType: generates the type for JSON Type Definition schema for type interface in the type parameter.")]),e._v(" "),t("li",[e._v("JTDDataType: generates the type for data given JSON Type Definition schema type in the type parameter.")])])])]),e._v(" "),t("h2",{attrs:{id:"potential-migration-difficulties"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#potential-migration-difficulties"}},[e._v("#")]),e._v(" Potential migration difficulties")]),e._v(" "),t("ul",[t("li",[e._v("Schema compilation is now safer against code injections but slower than in v6 ("),t("a",{attrs:{href:"https://github.com/ajv-validator/ajv/issues/1386",target:"_blank",rel:"noopener noreferrer"}},[e._v("#1386"),t("OutboundLink")],1),e._v(") - consider using "),t("RouterLink",{attrs:{to:"/standalone.html"}},[e._v("standalone validation code")]),e._v(" if this is a problem. Validation performance in v8 is the same (or better, thanks to "),t("RouterLink",{attrs:{to:"/codegen.html#code-optimization"}},[e._v("code optimizations")]),e._v(").")],1),e._v(" "),t("li",[e._v("Schema object used as a key for compiled schema function, not serialized string ("),t("a",{attrs:{href:"https://github.com/ajv-validator/ajv/issues/1413",target:"_blank",rel:"noopener noreferrer"}},[e._v("#1413"),t("OutboundLink")],1),e._v(") can cause schema compilation on each validation if you pass a new schema object. See "),t("RouterLink",{attrs:{to:"/guide/managing-schemas.html"}},[e._v("Managing schemas")]),e._v(" for different approaches to manage caching of compiled validation functions.")],1),e._v(" "),t("li",[e._v("User defined formats with standalone validation code ("),t("a",{attrs:{href:"https://github.com/ajv-validator/ajv/issues/1470",target:"_blank",rel:"noopener noreferrer"}},[e._v("#1470"),t("OutboundLink")],1),e._v(") require passing code snippet to "),t("RouterLink",{attrs:{to:"/options.html#code"}},[e._v("code.formats")]),e._v(" option.")],1)]),e._v(" "),t("h2",{attrs:{id:"api-changes"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#api-changes"}},[e._v("#")]),e._v(" API changes")]),e._v(" "),t("ul",[t("li",[e._v("addVocabulary - NEW method that allows to add an array of keyword definitions.")]),e._v(" "),t("li",[e._v('addKeyword - keyword name should be passed as property in definition object, not as the first parameter (old API works with "deprecated" warning). Also "inline" keywords support is removed, code generation keywords can now be defined with "code" keyword - the same definition format that is used by all pre-defined keywords.')]),e._v(" "),t("li",[e._v("Ajv no longer allows to create the instance without "),t("code",[e._v("new")]),e._v(" keyword (it is ES6 class).")]),e._v(" "),t("li",[e._v("allow "),t("code",[e._v('":"')]),e._v(" in keyword names.")])]),e._v(" "),t("h3",{attrs:{id:"added-options"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#added-options"}},[e._v("#")]),e._v(" Added options")]),e._v(" "),t("ul",[t("li",[e._v('strict: true/false/"log" - enables/disables all strict mode restrictions:\n'),t("ul",[t("li",[e._v("strictSchema: "),t("strong",[e._v("true")]),e._v('/false/"log" - equivalent to the combination of strictKeywords and strictDefaults in v6, with additional restrictions (see '),t("RouterLink",{attrs:{to:"/strict-mode.html"}},[e._v("Strict mode")]),e._v(").")],1),e._v(" "),t("li",[e._v("strictTypes: true/false/"),t("strong",[e._v('"log"')]),e._v(" - prevent mistakes related to type keywords and keyword applicability (see "),t("RouterLink",{attrs:{to:"/strict-mode.html#strict-types"}},[e._v("Strict Types")]),e._v(").")],1),e._v(" "),t("li",[e._v("strictTuples: true/false/"),t("strong",[e._v('"log"')]),e._v(" - prevent incomplete tuple schemas (see "),t("RouterLink",{attrs:{to:"/strict-mode.html#prohibit-unconstrained-tuples"}},[e._v("Prohibit unconstrained tuples")]),e._v(")")],1),e._v(" "),t("li",[e._v("strictRequired: true/"),t("strong",[e._v("false")]),e._v('/"log" - to log or fail if properties used in JSON Schema "required" are not defined in "properties" (see '),t("RouterLink",{attrs:{to:"/strict-mode.html#defined-required-properties"}},[e._v("Defined required properties")]),e._v(").")],1)])]),e._v(" "),t("li",[e._v('allowUnionTypes: false - allow multiple non-null types in "type" keyword')]),e._v(" "),t("li",[e._v('allowMatchingProperties: false - allow overlap between "properties" and "patternProperties" keywords')]),e._v(" "),t("li",[e._v("discriminator: true - support OpenAPI "),t("RouterLink",{attrs:{to:"/json-schema.html#discriminator"}},[e._v("discriminator")]),e._v(" keyword")],1),e._v(" "),t("li",[e._v("loopEnum - optimise validation of enums, similar to "),t("RouterLink",{attrs:{to:"/options.html#looprequired"}},[e._v("loopRequired")]),e._v(" option.")],1),e._v(" "),t("li",[e._v("validateFormats - enable format validation ("),t("code",[e._v("true")]),e._v(" by default)")]),e._v(" "),t("li",[e._v("code: {optimize: number|boolean} - control "),t("RouterLink",{attrs:{to:"/codegen.html#code-optimization"}},[e._v("code optimisation")])],1),e._v(" "),t("li",[e._v("code: {es5: true} - generate ES5 code, the default is to generate ES6 code.")]),e._v(" "),t("li",[e._v("code: {lines: true} - add line breaks to generated code - simplifies debugging of compiled schemas when you need it")])]),e._v(" "),t("h3",{attrs:{id:"changed-options"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#changed-options"}},[e._v("#")]),e._v(" Changed options")]),e._v(" "),t("ul",[t("li",[t("code",[e._v("keywords")]),e._v(' - now expects the array of keyword definitions (old API works with "deprecated" warning).')]),e._v(" "),t("li",[t("code",[e._v("strictNumbers")]),e._v(" - true by default now.")])]),e._v(" "),t("h3",{attrs:{id:"removed-options"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#removed-options"}},[e._v("#")]),e._v(" Removed options")]),e._v(" "),t("ul",[t("li",[e._v("errorDataPath - was deprecated, now removed.")]),e._v(" "),t("li",[e._v("format - "),t("code",[e._v("validateFormats: false")]),e._v(" can be used instead, format mode can be chosen via ajv-formats package.")]),e._v(" "),t("li",[e._v("nullable: "),t("code",[e._v("nullable")]),e._v(" keyword is supported by default.")]),e._v(" "),t("li",[e._v("jsonPointers: JSONPointers are used to report errors by default, "),t("code",[e._v("jsPropertySyntax: true")]),e._v(" (deprecated) can be used if old format is needed.")]),e._v(" "),t("li",[e._v("unicode: deprecated, string length correctly accounts for multi-byte characters by default.")]),e._v(" "),t("li",[e._v("extendRefs: $ref siblings are validated by default (consistent with draft 2019-09), "),t("code",[e._v("ignoreKeywordsWithRef")]),e._v(" (deprecated) can be used instead to ignore $ref siblings.")]),e._v(" "),t("li",[e._v("missingRefs: now exception is always thrown. Pass empty schema with $id that should be ignored to ajv.addSchema.")]),e._v(" "),t("li",[e._v("processCode: replaced with "),t("code",[e._v("code: {process: (code, schemaEnv: object) => string}")]),e._v(".")]),e._v(" "),t("li",[e._v("sourceCode: replaced with "),t("code",[e._v("code: {source: true}")]),e._v(".")]),e._v(" "),t("li",[e._v("schemaId: removed, as JSON Schema draft-04 is no longer supported.")]),e._v(" "),t("li",[e._v("strictDefaults, strictKeywords: it is default now, controlled with "),t("code",[e._v("strict")]),e._v(" or "),t("code",[e._v("strictSchema")]),e._v(".")]),e._v(" "),t("li",[e._v('uniqueItems: \'"uniqueItems" keyword is always validated.')]),e._v(" "),t("li",[e._v("unknownFormats: the same can be achieved by passing true for formats that need to be ignored via "),t("code",[e._v("ajv.addFormat")]),e._v(" or "),t("code",[e._v("formats")]),e._v(" option.")]),e._v(" "),t("li",[e._v("cache and serialize: Map is used as cache, schema object as key.")])])])}),[],!1,null,null,null);t.default=o.exports}}]); \ No newline at end of file diff --git a/assets/js/app.b35705df.js b/assets/js/app.b35705df.js new file mode 100644 index 000000000..9e1e04a8f --- /dev/null +++ b/assets/js/app.b35705df.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.1",mode:r?"pure":"global",copyright:"© 2014-2024 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.37.1/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,454)),"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,307)),"components/NavLink":()=>n.e(42).then(n.bind(null,240)),"components/NavLinks":()=>Promise.all([n.e(0),n.e(13)]).then(n.bind(null,267)),"components/Navbar":()=>Promise.all([n.e(0),n.e(1)]).then(n.bind(null,381)),"components/Page":()=>Promise.all([n.e(0),n.e(12)]).then(n.bind(null,308)),"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,269)),"components/Sidebar":()=>Promise.all([n.e(0),n.e(11)]).then(n.bind(null,309)),"components/SidebarButton":()=>Promise.all([n.e(0),n.e(41)]).then(n.bind(null,310)),"components/SidebarGroup":()=>Promise.all([n.e(0),n.e(3)]).then(n.bind(null,268)),"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,472)),"global-components/CodeBlock":()=>Promise.all([n.e(0),n.e(5)]).then(n.bind(null,455)),"global-components/CodeGroup":()=>Promise.all([n.e(0),n.e(6)]).then(n.bind(null,456)),"layouts/404":()=>n.e(7).then(n.bind(null,457)),"layouts/Layout":()=>Promise.all([n.e(0),n.e(1),n.e(2)]).then(n.bind(null,458)),NotFound:()=>n.e(7).then(n.bind(null,457)),Layout:()=>Promise.all([n.e(0),n.e(1),n.e(2)]).then(n.bind(null,458))},Wa={"v-2216e8dc":()=>n.e(10).then(n.bind(null,473)),"v-0b4d4089":()=>n.e(44).then(n.bind(null,474)),"v-094b9dee":()=>n.e(45).then(n.bind(null,475)),"v-7eb94829":()=>n.e(46).then(n.bind(null,476)),"v-51aaf849":()=>n.e(48).then(n.bind(null,477)),"v-29ebca8e":()=>n.e(47).then(n.bind(null,478)),"v-126ea6be":()=>n.e(49).then(n.bind(null,479)),"v-4d7f1c8a":()=>n.e(51).then(n.bind(null,480)),"v-83a41dee":()=>n.e(52).then(n.bind(null,481)),"v-003ee409":()=>n.e(50).then(n.bind(null,482)),"v-49301ee2":()=>n.e(53).then(n.bind(null,483)),"v-d1f646ae":()=>n.e(54).then(n.bind(null,484)),"v-464fd629":()=>n.e(55).then(n.bind(null,485)),"v-7cca31fe":()=>n.e(56).then(n.bind(null,486)),"v-b5351e9e":()=>n.e(57).then(n.bind(null,487)),"v-62aa1369":()=>n.e(60).then(n.bind(null,488)),"v-f3391bf6":()=>n.e(59).then(n.bind(null,489)),"v-3ad539ae":()=>n.e(61).then(n.bind(null,490)),"v-76cafeae":()=>n.e(58).then(n.bind(null,491)),"v-5e92fa09":()=>n.e(62).then(n.bind(null,492)),"v-48953121":()=>n.e(64).then(n.bind(null,493)),"v-8de1af1a":()=>n.e(63).then(n.bind(null,494)),"v-1dfe032e":()=>n.e(66).then(n.bind(null,495)),"v-1f38ca2e":()=>n.e(65).then(n.bind(null,496)),"v-67c77489":()=>n.e(68).then(n.bind(null,497)),"v-27531941":()=>n.e(67).then(n.bind(null,498)),"v-c918a5fa":()=>n.e(69).then(n.bind(null,499)),"v-5a94ae89":()=>n.e(70).then(n.bind(null,500)),"v-2abeb1ab":()=>n.e(71).then(n.bind(null,501)),"v-959a2c2e":()=>n.e(72).then(n.bind(null,502)),"v-7bf93309":()=>n.e(74).then(n.bind(null,503)),"v-506a67bc":()=>n.e(73).then(n.bind(null,504)),"v-19f2c039":()=>n.e(76).then(n.bind(null,505)),"v-07fb5e62":()=>n.e(75).then(n.bind(null,506)),"v-b99d2c2e":()=>n.e(77).then(n.bind(null,507)),"v-7f55ccc9":()=>n.e(79).then(n.bind(null,508)),"v-bf7e876e":()=>n.e(80).then(n.bind(null,509)),"v-6731dec1":()=>n.e(78).then(n.bind(null,510)),"v-bb53a316":()=>n.e(81).then(n.bind(null,511)),"v-20f55eeb":()=>n.e(82).then(n.bind(null,512)),"v-74774829":()=>n.e(83).then(n.bind(null,513)),"v-90fdf4e6":()=>n.e(84).then(n.bind(null,514)),"v-114a7465":()=>n.e(85).then(n.bind(null,515))};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-2216e8dc",path:"/",component:Cs,beforeEnter:(e,t,n)=>{fs("Layout","v-2216e8dc").then(n)}},{path:"/index.html",redirect:"/"},{name:"v-0b4d4089",path:"/api.html",component:Cs,beforeEnter:(e,t,n)=>{fs("Layout","v-0b4d4089").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-51aaf849",path:"/components.html",component:Cs,beforeEnter:(e,t,n)=>{fs("Layout","v-51aaf849").then(n)}},{name:"v-29ebca8e",path:"/coercion.html",component:Cs,beforeEnter:(e,t,n)=>{fs("Layout","v-29ebca8e").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-4d7f1c8a",path:"/guide/async-validation.html",component:Cs,beforeEnter:(e,t,n)=>{fs("Layout","v-4d7f1c8a").then(n)}},{name:"v-83a41dee",path:"/guide/combining-schemas.html",component:Cs,beforeEnter:(e,t,n)=>{fs("Layout","v-83a41dee").then(n)}},{name:"v-003ee409",path:"/faq.html",component:Cs,beforeEnter:(e,t,n)=>{fs("Layout","v-003ee409").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-464fd629",path:"/guide/getting-started.html",component:Cs,beforeEnter:(e,t,n)=>{fs("Layout","v-464fd629").then(n)}},{name:"v-7cca31fe",path:"/guide/managing-schemas.html",component:Cs,beforeEnter:(e,t,n)=>{fs("Layout","v-7cca31fe").then(n)}},{name:"v-b5351e9e",path:"/guide/modifying-data.html",component:Cs,beforeEnter:(e,t,n)=>{fs("Layout","v-b5351e9e").then(n)}},{name:"v-62aa1369",path:"/guide/user-keywords.html",component:Cs,beforeEnter:(e,t,n)=>{fs("Layout","v-62aa1369").then(n)}},{name:"v-f3391bf6",path:"/guide/typescript.html",component:Cs,beforeEnter:(e,t,n)=>{fs("Layout","v-f3391bf6").then(n)}},{name:"v-3ad539ae",path:"/guide/why-ajv.html",component:Cs,beforeEnter:(e,t,n)=>{fs("Layout","v-3ad539ae").then(n)}},{name:"v-76cafeae",path:"/guide/schema-language.html",component:Cs,beforeEnter:(e,t,n)=>{fs("Layout","v-76cafeae").then(n)}},{name:"v-5e92fa09",path:"/json-schema.html",component:Cs,beforeEnter:(e,t,n)=>{fs("Layout","v-5e92fa09").then(n)}},{name:"v-48953121",path:"/keywords.html",component:Cs,beforeEnter:(e,t,n)=>{fs("Layout","v-48953121").then(n)}},{name:"v-8de1af1a",path:"/json-type-definition.html",component:Cs,beforeEnter:(e,t,n)=>{fs("Layout","v-8de1af1a").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-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-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-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-7bf93309",path:"/options.html",component:Cs,beforeEnter:(e,t,n)=>{fs("Layout","v-7bf93309").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-19f2c039",path:"/packages/ajv-cli.html",component:Cs,beforeEnter:(e,t,n)=>{fs("Layout","v-19f2c039").then(n)}},{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-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-6731dec1",path:"/packages/ajv-formats.html",component:Cs,beforeEnter:(e,t,n)=>{fs("Layout","v-6731dec1").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-74774829",path:"/strict-mode.html",component:Cs,beforeEnter:(e,t,n)=>{fs("Layout","v-74774829").then(n)}},{name:"v-90fdf4e6",path:"/testimonials.html",component:Cs,beforeEnter:(e,t,n)=>{fs("Layout","v-90fdf4e6").then(n)}},{name:"v-114a7465",path:"/v6-to-v8-migration.html",component:Cs,beforeEnter:(e,t,n)=>{fs("Layout","v-114a7465").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:[{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:"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"}]},{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:"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:"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:"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:"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:"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:"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:"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:"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:"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:"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:"User-defined keywords",frontmatter:{},regularPath:"/guide/user-keywords.html",relativePath:"guide/user-keywords.md",key:"v-62aa1369",path:"/guide/user-keywords.html"},{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:"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:"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:"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:"/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:"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:"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 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 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:"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 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"}]},{title:"Ajv News",frontmatter:{newsIndex:!0,editLink:!1},regularPath:"/news/",relativePath:"news/README.md",key:"v-506a67bc",path:"/news/"},{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"}]},{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"}]},{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"}]},{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:"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"}]},{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"}]},{title:"What users say",frontmatter:{},regularPath:"/testimonials.html",relativePath:"testimonials.md",key:"v-90fdf4e6",path:"/testimonials.html"},{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"}]}],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,459))),Kn.component("Column",()=>Promise.all([n.e(0),n.e(26)]).then(n.bind(null,460))),Kn.component("Columns",()=>Promise.all([n.e(0),n.e(27)]).then(n.bind(null,516))),Kn.component("Contributors",()=>Promise.all([n.e(0),n.e(21)]).then(n.bind(null,461))),Kn.component("Feature",()=>Promise.all([n.e(0),n.e(22)]).then(n.bind(null,462))),Kn.component("Features",()=>Promise.all([n.e(0),n.e(28)]).then(n.bind(null,517))),Kn.component("FooterColumn",()=>Promise.all([n.e(0),n.e(29)]).then(n.bind(null,463))),Kn.component("GitHub",()=>Promise.all([n.e(0),n.e(31)]).then(n.bind(null,464))),Kn.component("FooterColumns",()=>Promise.all([n.e(0),n.e(30)]).then(n.bind(null,518))),Kn.component("HeroSection",()=>Promise.all([n.e(0),n.e(23)]).then(n.bind(null,519))),Kn.component("HomePage",()=>Promise.all([n.e(0),n.e(32)]).then(n.bind(null,520))),Kn.component("HomeSection",()=>Promise.all([n.e(0),n.e(33)]).then(n.bind(null,465))),Kn.component("NewsHome",()=>Promise.all([n.e(0),n.e(34)]).then(n.bind(null,466))),Kn.component("NewsIndex",()=>n.e(43).then(n.bind(null,467))),Kn.component("NewsPost",()=>Promise.all([n.e(0),n.e(14)]).then(n.bind(null,468))),Kn.component("NewsPostMeta",()=>Promise.all([n.e(0),n.e(18)]).then(n.bind(null,469))),Kn.component("Projects",()=>Promise.all([n.e(0),n.e(35)]).then(n.bind(null,521))),Kn.component("Sponsors",()=>Promise.all([n.e(0),n.e(36)]).then(n.bind(null,470))),Kn.component("Subscribe",()=>Promise.all([n.e(0),n.e(37)]).then(n.bind(null,522))),Kn.component("Testimonial",()=>Promise.all([n.e(0),n.e(38)]).then(n.bind(null,471))),Kn.component("Testimonials",()=>Promise.all([n.e(0),n.e(39)]).then(n.bind(null,523))),Kn.component("Badge",()=>Promise.all([n.e(0),n.e(4)]).then(n.bind(null,472))),Kn.component("CodeBlock",()=>Promise.all([n.e(0),n.e(5)]).then(n.bind(null,455))),Kn.component("CodeGroup",()=>Promise.all([n.e(0),n.e(6)]).then(n.bind(null,456)));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/assets/js/vendors~docsearch.396fe082.js b/assets/js/vendors~docsearch.396fe082.js new file mode 100644 index 000000000..11c2945eb --- /dev/null +++ b/assets/js/vendors~docsearch.396fe082.js @@ -0,0 +1,3 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[9],{452:function(t,e,n){ +/*! docsearch 2.6.3 | © Algolia | github.com/algolia/docsearch */ +var r;"undefined"!=typeof self&&self,r=function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:r})},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=22)}([function(t,e,n){"use strict";var r,i=n(1);function s(t){return t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}t.exports={isArray:null,isFunction:null,isObject:null,bind:null,each:null,map:null,mixin:null,isMsie:function(t){if(void 0===t&&(t=navigator.userAgent),/(msie|trident)/i.test(t)){var e=t.match(/(msie |rv:)(\d+(.\d+)?)/i);if(e)return e[2]}return!1},escapeRegExChars:function(t){return t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},isNumber:function(t){return"number"==typeof t},toStr:function(t){return null==t?"":t+""},cloneDeep:function(t){var e=this.mixin({},t),n=this;return this.each(e,(function(t,r){t&&(n.isArray(t)?e[r]=[].concat(t):n.isObject(t)&&(e[r]=n.cloneDeep(t)))})),e},error:function(t){throw new Error(t)},every:function(t,e){var n=!0;return t?(this.each(t,(function(r,i){n&&(n=e.call(null,r,i,t)&&n)})),!!n):n},any:function(t,e){var n=!1;return t?(this.each(t,(function(r,i){if(e.call(null,r,i,t))return n=!0,!1})),n):n},getUniqueId:(r=0,function(){return r++}),templatify:function(t){if(this.isFunction(t))return t;var e=i.element(t);return"SCRIPT"===e.prop("tagName")?function(){return e.text()}:function(){return String(t)}},defer:function(t){setTimeout(t,0)},noop:function(){},formatPrefix:function(t,e){return e?"":t+"-"},className:function(t,e,n){return(n?"":".")+t+e},escapeHighlightedString:function(t,e,n){e=e||"";var r=document.createElement("div");r.appendChild(document.createTextNode(e)),n=n||"";var i=document.createElement("div");i.appendChild(document.createTextNode(n));var o=document.createElement("div");return o.appendChild(document.createTextNode(t)),o.innerHTML.replace(RegExp(s(r.innerHTML),"g"),e).replace(RegExp(s(i.innerHTML),"g"),n)}}},function(t,e,n){"use strict";t.exports={element:null}},function(t,e){var n=Object.prototype.hasOwnProperty,r=Object.prototype.toString;t.exports=function(t,e,i){if("[object Function]"!==r.call(e))throw new TypeError("iterator must be a function");var s=t.length;if(s===+s)for(var o=0;o was loaded but did not call our provided callback"),JSONPScriptError:s("JSONPScriptError"," + diff --git a/codegen.html b/codegen.html index 61430be28..9dbe82a3d 100644 --- a/codegen.html +++ b/codegen.html @@ -18,8 +18,8 @@ - - + +
- + diff --git a/coercion.html b/coercion.html index 2c62201cc..bd835c9b0 100644 --- a/coercion.html +++ b/coercion.html @@ -18,8 +18,8 @@ - - + +
- + diff --git a/components.html b/components.html index 3828842a0..8e669569c 100644 --- a/components.html +++ b/components.html @@ -18,8 +18,8 @@ - - + +
- + diff --git a/contributing/index.html b/contributing/index.html index 9cff0bb6f..9c4ee03b9 100644 --- a/contributing/index.html +++ b/contributing/index.html @@ -18,8 +18,8 @@ - - + +
- + diff --git a/faq.html b/faq.html index 42477eaa4..5486c426e 100644 --- a/faq.html +++ b/faq.html @@ -18,8 +18,8 @@ - - + +
- + diff --git a/guide/async-validation.html b/guide/async-validation.html index 31d62de1b..9e54e5794 100644 --- a/guide/async-validation.html +++ b/guide/async-validation.html @@ -18,8 +18,8 @@ - - + +
- + diff --git a/guide/combining-schemas.html b/guide/combining-schemas.html index 3f6df74d0..a529390ce 100644 --- a/guide/combining-schemas.html +++ b/guide/combining-schemas.html @@ -18,8 +18,8 @@ - - + +
- + diff --git a/guide/environments.html b/guide/environments.html index 0bcbd8e64..aa3576dd7 100644 --- a/guide/environments.html +++ b/guide/environments.html @@ -18,8 +18,8 @@ - - + +
- + diff --git a/guide/formats.html b/guide/formats.html index 79a9d9248..88ad71eb5 100644 --- a/guide/formats.html +++ b/guide/formats.html @@ -18,8 +18,8 @@ - - + +
- + diff --git a/guide/getting-started.html b/guide/getting-started.html index 7831e60de..6180e4832 100644 --- a/guide/getting-started.html +++ b/guide/getting-started.html @@ -18,8 +18,8 @@ - - + +
- + diff --git a/guide/managing-schemas.html b/guide/managing-schemas.html index f4c3eb48b..510f7b974 100644 --- a/guide/managing-schemas.html +++ b/guide/managing-schemas.html @@ -18,8 +18,8 @@ - - + +
- + diff --git a/guide/modifying-data.html b/guide/modifying-data.html index c3a202d5c..3292b3cf8 100644 --- a/guide/modifying-data.html +++ b/guide/modifying-data.html @@ -18,8 +18,8 @@ - - + +
- + diff --git a/guide/schema-language.html b/guide/schema-language.html index 4107b175c..7e564a95b 100644 --- a/guide/schema-language.html +++ b/guide/schema-language.html @@ -18,8 +18,8 @@ - - + +
- + diff --git a/guide/typescript.html b/guide/typescript.html index d0ed64c80..f107d8254 100644 --- a/guide/typescript.html +++ b/guide/typescript.html @@ -18,8 +18,8 @@ - - + +
- + diff --git a/guide/user-keywords.html b/guide/user-keywords.html index 56ae541d7..46f8f5753 100644 --- a/guide/user-keywords.html +++ b/guide/user-keywords.html @@ -18,8 +18,8 @@ - - + +
- + diff --git a/guide/why-ajv.html b/guide/why-ajv.html index e6dd95fd6..653659564 100644 --- a/guide/why-ajv.html +++ b/guide/why-ajv.html @@ -18,8 +18,8 @@ - - + +
- + diff --git a/index.html b/index.html index f17ecf03d..17d821ae0 100644 --- a/index.html +++ b/index.html @@ -18,8 +18,8 @@ - - + +
All news

# Contributors

Ajv is free to use and open-source that many developers contributed to. Join us!

epoberezkin - + spaced4ndy - + erikbrinkman - + jasoniangreen - + dependabot[bot] - + PBug90 - + blakeembrey - + sambauers - + gajus - + meirotstein - + Tyharo1 - + igor-savin-ht - + b4h0-c4t - + willfarrell - + boenrobot - + yume-chan - + GrahamLea - + franciscomorais - + asaid-0 - + domoritz - + imbstack - + pithu - + realityking - + efebarlas - + brendo - + pcwiek - + rehanvdm - + farrago - + SoAsEr - + kroky - + Delagen - + YChebotaev - + bhvngt - + t7yang - + teq0 - + wuweiss - + zekth - + egfx-notifications - + awlayton - + HotelDon - + donaldpipowitch - + mummybot - + G-Rath - + HolgerJeromin - + monkeywithacupcake - + ktrueda - + lucassaid - + marshall007 - + mattpolzin - + MichaelDeBoey - + Nonemoticoner - - dzuremar - + + orgads + papb - + philsturgeon - + carlo-quinonez - + radekmie - + merlindorin - + Romakita - + rbuckton - + ryanmeador - + mighty1231 - + simon04 - + SirLich - + krenor - + stuartpb - + TIBCOeddie - + bearmini - + + ahmdsolmn + + dzuremar + mxsgx - + m00s - + mbroadst - + MattiAstedrone - + MikeRalphson - + tyok - + MrJithil - + mychaelgo - + natflow - + nwoltman - + blottn - + nimerritt - + nicksrandall - + Noam3kCH - + eventlistener - + Opticsponge - - orgads - + jonganc - + jsdevel - + oldmud0 - + ossdev07 - + pskfyi - + qwertyforce - + rek - + sahilda - + schokotets - + superfaz - + tridium - + vlbee - + aladdin-add - + wyfo - + duxing - + anchnk - + ChALkeR - + not-an-aardvark - + thernstig - + TommyDew42 - + koba04 - + isTravis - + cvlab - + vargaeric - + villasv - + aristov - + billytrend - + byr-gdp - + cjancsar - + dfeufel - + ehmicky - + fpicalausa - + franrolando - + fridays - - delavara - + smithc10 - + caub - + dalcib - + dannyb648 - + dancasey - + rotu - + FunkyDck - + darcyparker - + daveisfera - + dsanders11 - + Delapouite - + dimitropoulos - + keyten - + thetric - + rubiagatra - + forivall - - ahmdsolmn - + + ecwyne + alexanderjsx - + Alexsey - + avanelli - + anslzo - + asprouse - + andyscott - + vixalien - + kulakowka - + wetneb - + vendeza - + benasher44 - + bradjones1 - + eventualbuddha - + cbrwflo - + cpillsbury - + ChuntaoLu - - jonasfj - + + delavara + jonathanGB - + + josdejong + jboavida - + justinpowers - + kapouer - + lehni - + platinumazure - + kpping - + laurens - + johanlelan - + leonardovillela - + LinusU - + alazyzombie - + jsbrain - + Eomm - + VIEWVIEWVIEW - + mduu - - ecwyne - + EtaiG - + gj - + rgeerts - + garrows - + gurgunday - + hadrien-toma - + seriousme - + hans-kinnek - + handrews - + is2ei - + idangozlan - + ivansieder - + P0lip - + JamesJansson - + mrjgreen - + jrr + + jonasfj
- + diff --git a/json-schema.html b/json-schema.html index 69d4cf829..1b0b39b0b 100644 --- a/json-schema.html +++ b/json-schema.html @@ -18,8 +18,8 @@ - - + +
- + diff --git a/json-type-definition.html b/json-type-definition.html index fdcf9e347..10b824e41 100644 --- a/json-type-definition.html +++ b/json-type-definition.html @@ -18,8 +18,8 @@ - - + +
- + diff --git a/keywords.html b/keywords.html index 7f7750d6e..eb417504f 100644 --- a/keywords.html +++ b/keywords.html @@ -18,8 +18,8 @@ - - + +
- + diff --git a/license.html b/license.html index f20a71a09..12b0bb9a4 100644 --- a/license.html +++ b/license.html @@ -18,8 +18,8 @@ - - + +
- + diff --git a/news/2020-08-14-mozilla-grant-openjs-foundation.html b/news/2020-08-14-mozilla-grant-openjs-foundation.html index b72cfa7ad..41f324b7d 100644 --- a/news/2020-08-14-mozilla-grant-openjs-foundation.html +++ b/news/2020-08-14-mozilla-grant-openjs-foundation.html @@ -18,8 +18,8 @@ - - + +
- + diff --git a/news/2020-12-15-ajv-version-7-released.html b/news/2020-12-15-ajv-version-7-released.html index 9f222ea5b..e4122285d 100644 --- a/news/2020-12-15-ajv-version-7-released.html +++ b/news/2020-12-15-ajv-version-7-released.html @@ -18,8 +18,8 @@ - - + +
- + 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 cb4720b88..599c3e842 100644 --- a/news/2021-03-07-ajv-supports-json-type-definition.html +++ b/news/2021-03-07-ajv-supports-json-type-definition.html @@ -18,8 +18,8 @@ - - + +
- + diff --git a/news/2021-03-27-ajv-version-8-released.html b/news/2021-03-27-ajv-version-8-released.html index 1ce9e9b16..1c033aad9 100644 --- a/news/2021-03-27-ajv-version-8-released.html +++ b/news/2021-03-27-ajv-version-8-released.html @@ -18,8 +18,8 @@ - - + +
- + diff --git a/news/2021-04-24-ajv-online-event.html b/news/2021-04-24-ajv-online-event.html index 04318368f..7bd4a70fb 100644 --- a/news/2021-04-24-ajv-online-event.html +++ b/news/2021-04-24-ajv-online-event.html @@ -18,8 +18,8 @@ - - + +
- + diff --git a/news/2021-05-24-ajv-online-event-video.html b/news/2021-05-24-ajv-online-event-video.html index dadfa89fd..42a04f755 100644 --- a/news/2021-05-24-ajv-online-event-video.html +++ b/news/2021-05-24-ajv-online-event-video.html @@ -18,8 +18,8 @@ - - + + - + 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 4e888718c..b4788809e 100644 --- a/news/2021-07-22-ajv-microsoft-foss-fund-award.html +++ b/news/2021-07-22-ajv-microsoft-foss-fund-award.html @@ -18,8 +18,8 @@ - - + +
- + diff --git a/news/index.html b/news/index.html index 6e8c9c66e..cce225424 100644 --- a/news/index.html +++ b/news/index.html @@ -18,8 +18,8 @@ - - + +
- + diff --git a/options.html b/options.html index a1f93fb87..ff61bbacf 100644 --- a/options.html +++ b/options.html @@ -18,8 +18,8 @@ - - + +
- + diff --git a/packages/ajv-cli.html b/packages/ajv-cli.html index 10b1eadae..1c655c636 100644 --- a/packages/ajv-cli.html +++ b/packages/ajv-cli.html @@ -18,8 +18,8 @@ - - + +
- + diff --git a/packages/ajv-errors.html b/packages/ajv-errors.html index c71bef7e5..7460fcd2c 100644 --- a/packages/ajv-errors.html +++ b/packages/ajv-errors.html @@ -18,8 +18,8 @@ - - + +
- + diff --git a/packages/ajv-formats.html b/packages/ajv-formats.html index 473f1c136..15c7634f8 100644 --- a/packages/ajv-formats.html +++ b/packages/ajv-formats.html @@ -18,8 +18,8 @@ - - + +
- + diff --git a/packages/ajv-i18n.html b/packages/ajv-i18n.html index fe61ee899..8cc3e975f 100644 --- a/packages/ajv-i18n.html +++ b/packages/ajv-i18n.html @@ -18,8 +18,8 @@ - - + +
- + diff --git a/packages/ajv-keywords.html b/packages/ajv-keywords.html index 6edf995ab..903901ab9 100644 --- a/packages/ajv-keywords.html +++ b/packages/ajv-keywords.html @@ -18,8 +18,8 @@ - - + +
- + diff --git a/packages/index.html b/packages/index.html index 309a27d7d..6a8e30063 100644 --- a/packages/index.html +++ b/packages/index.html @@ -18,8 +18,8 @@ - - + +
- + diff --git a/security.html b/security.html index 0106c1a44..4dd500fed 100644 --- a/security.html +++ b/security.html @@ -18,8 +18,8 @@ - - + +
- + diff --git a/standalone.html b/standalone.html index 2c80e15fb..09183ba37 100644 --- a/standalone.html +++ b/standalone.html @@ -18,8 +18,8 @@ - - + +
- + diff --git a/strict-mode.html b/strict-mode.html index f34b78be1..7c4d3d673 100644 --- a/strict-mode.html +++ b/strict-mode.html @@ -18,8 +18,8 @@ - - + +
- + diff --git a/testimonials.html b/testimonials.html index c6581082b..e0c63a013 100644 --- a/testimonials.html +++ b/testimonials.html @@ -18,8 +18,8 @@ - - + +
- + diff --git a/v6-to-v8-migration.html b/v6-to-v8-migration.html index 7958048d6..8bf669ab8 100644 --- a/v6-to-v8-migration.html +++ b/v6-to-v8-migration.html @@ -18,8 +18,8 @@ - - + +