Dexter Jin

Unnecessary Node Modules Deleted

Showing 1000 changed files with 0 additions and 4852 deletions

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

1 -#!/bin/sh
2 -basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3 -
4 -case `uname` in
5 - *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
6 -esac
7 -
8 -if [ -x "$basedir/node" ]; then
9 - "$basedir/node" "$basedir/../mime/cli.js" "$@"
10 - ret=$?
11 -else
12 - node "$basedir/../mime/cli.js" "$@"
13 - ret=$?
14 -fi
15 -exit $ret
1 -@IF EXIST "%~dp0\node.exe" (
2 - "%~dp0\node.exe" "%~dp0\..\mime\cli.js" %*
3 -) ELSE (
4 - @SETLOCAL
5 - @SET PATHEXT=%PATHEXT:;.JS;=;%
6 - node "%~dp0\..\mime\cli.js" %*
7 -)
...\ No newline at end of file ...\ No newline at end of file
1 -#!/bin/sh
2 -basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3 -
4 -case `uname` in
5 - *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
6 -esac
7 -
8 -if [ -x "$basedir/node" ]; then
9 - "$basedir/node" "$basedir/../sshpk/bin/sshpk-conv" "$@"
10 - ret=$?
11 -else
12 - node "$basedir/../sshpk/bin/sshpk-conv" "$@"
13 - ret=$?
14 -fi
15 -exit $ret
1 -@IF EXIST "%~dp0\node.exe" (
2 - "%~dp0\node.exe" "%~dp0\..\sshpk\bin\sshpk-conv" %*
3 -) ELSE (
4 - @SETLOCAL
5 - @SET PATHEXT=%PATHEXT:;.JS;=;%
6 - node "%~dp0\..\sshpk\bin\sshpk-conv" %*
7 -)
...\ No newline at end of file ...\ No newline at end of file
1 -#!/bin/sh
2 -basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3 -
4 -case `uname` in
5 - *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
6 -esac
7 -
8 -if [ -x "$basedir/node" ]; then
9 - "$basedir/node" "$basedir/../sshpk/bin/sshpk-sign" "$@"
10 - ret=$?
11 -else
12 - node "$basedir/../sshpk/bin/sshpk-sign" "$@"
13 - ret=$?
14 -fi
15 -exit $ret
1 -@IF EXIST "%~dp0\node.exe" (
2 - "%~dp0\node.exe" "%~dp0\..\sshpk\bin\sshpk-sign" %*
3 -) ELSE (
4 - @SETLOCAL
5 - @SET PATHEXT=%PATHEXT:;.JS;=;%
6 - node "%~dp0\..\sshpk\bin\sshpk-sign" %*
7 -)
...\ No newline at end of file ...\ No newline at end of file
1 -#!/bin/sh
2 -basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3 -
4 -case `uname` in
5 - *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
6 -esac
7 -
8 -if [ -x "$basedir/node" ]; then
9 - "$basedir/node" "$basedir/../sshpk/bin/sshpk-verify" "$@"
10 - ret=$?
11 -else
12 - node "$basedir/../sshpk/bin/sshpk-verify" "$@"
13 - ret=$?
14 -fi
15 -exit $ret
1 -@IF EXIST "%~dp0\node.exe" (
2 - "%~dp0\node.exe" "%~dp0\..\sshpk\bin\sshpk-verify" %*
3 -) ELSE (
4 - @SETLOCAL
5 - @SET PATHEXT=%PATHEXT:;.JS;=;%
6 - node "%~dp0\..\sshpk\bin\sshpk-verify" %*
7 -)
...\ No newline at end of file ...\ No newline at end of file
1 -#!/bin/sh
2 -basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3 -
4 -case `uname` in
5 - *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
6 -esac
7 -
8 -if [ -x "$basedir/node" ]; then
9 - "$basedir/node" "$basedir/../node-uuid/bin/uuid" "$@"
10 - ret=$?
11 -else
12 - node "$basedir/../node-uuid/bin/uuid" "$@"
13 - ret=$?
14 -fi
15 -exit $ret
1 -@IF EXIST "%~dp0\node.exe" (
2 - "%~dp0\node.exe" "%~dp0\..\node-uuid\bin\uuid" %*
3 -) ELSE (
4 - @SETLOCAL
5 - @SET PATHEXT=%PATHEXT:;.JS;=;%
6 - node "%~dp0\..\node-uuid\bin\uuid" %*
7 -)
...\ No newline at end of file ...\ No newline at end of file
1 -1.3.3 / 2016-05-02
2 -==================
3 -
4 - * deps: mime-types@~2.1.11
5 - - deps: mime-db@~1.23.0
6 - * deps: negotiator@0.6.1
7 - - perf: improve `Accept` parsing speed
8 - - perf: improve `Accept-Charset` parsing speed
9 - - perf: improve `Accept-Encoding` parsing speed
10 - - perf: improve `Accept-Language` parsing speed
11 -
12 -1.3.2 / 2016-03-08
13 -==================
14 -
15 - * deps: mime-types@~2.1.10
16 - - Fix extension of `application/dash+xml`
17 - - Update primary extension for `audio/mp4`
18 - - deps: mime-db@~1.22.0
19 -
20 -1.3.1 / 2016-01-19
21 -==================
22 -
23 - * deps: mime-types@~2.1.9
24 - - deps: mime-db@~1.21.0
25 -
26 -1.3.0 / 2015-09-29
27 -==================
28 -
29 - * deps: mime-types@~2.1.7
30 - - deps: mime-db@~1.19.0
31 - * deps: negotiator@0.6.0
32 - - Fix including type extensions in parameters in `Accept` parsing
33 - - Fix parsing `Accept` parameters with quoted equals
34 - - Fix parsing `Accept` parameters with quoted semicolons
35 - - Lazy-load modules from main entry point
36 - - perf: delay type concatenation until needed
37 - - perf: enable strict mode
38 - - perf: hoist regular expressions
39 - - perf: remove closures getting spec properties
40 - - perf: remove a closure from media type parsing
41 - - perf: remove property delete from media type parsing
42 -
43 -1.2.13 / 2015-09-06
44 -===================
45 -
46 - * deps: mime-types@~2.1.6
47 - - deps: mime-db@~1.18.0
48 -
49 -1.2.12 / 2015-07-30
50 -===================
51 -
52 - * deps: mime-types@~2.1.4
53 - - deps: mime-db@~1.16.0
54 -
55 -1.2.11 / 2015-07-16
56 -===================
57 -
58 - * deps: mime-types@~2.1.3
59 - - deps: mime-db@~1.15.0
60 -
61 -1.2.10 / 2015-07-01
62 -===================
63 -
64 - * deps: mime-types@~2.1.2
65 - - deps: mime-db@~1.14.0
66 -
67 -1.2.9 / 2015-06-08
68 -==================
69 -
70 - * deps: mime-types@~2.1.1
71 - - perf: fix deopt during mapping
72 -
73 -1.2.8 / 2015-06-07
74 -==================
75 -
76 - * deps: mime-types@~2.1.0
77 - - deps: mime-db@~1.13.0
78 - * perf: avoid argument reassignment & argument slice
79 - * perf: avoid negotiator recursive construction
80 - * perf: enable strict mode
81 - * perf: remove unnecessary bitwise operator
82 -
83 -1.2.7 / 2015-05-10
84 -==================
85 -
86 - * deps: negotiator@0.5.3
87 - - Fix media type parameter matching to be case-insensitive
88 -
89 -1.2.6 / 2015-05-07
90 -==================
91 -
92 - * deps: mime-types@~2.0.11
93 - - deps: mime-db@~1.9.1
94 - * deps: negotiator@0.5.2
95 - - Fix comparing media types with quoted values
96 - - Fix splitting media types with quoted commas
97 -
98 -1.2.5 / 2015-03-13
99 -==================
100 -
101 - * deps: mime-types@~2.0.10
102 - - deps: mime-db@~1.8.0
103 -
104 -1.2.4 / 2015-02-14
105 -==================
106 -
107 - * Support Node.js 0.6
108 - * deps: mime-types@~2.0.9
109 - - deps: mime-db@~1.7.0
110 - * deps: negotiator@0.5.1
111 - - Fix preference sorting to be stable for long acceptable lists
112 -
113 -1.2.3 / 2015-01-31
114 -==================
115 -
116 - * deps: mime-types@~2.0.8
117 - - deps: mime-db@~1.6.0
118 -
119 -1.2.2 / 2014-12-30
120 -==================
121 -
122 - * deps: mime-types@~2.0.7
123 - - deps: mime-db@~1.5.0
124 -
125 -1.2.1 / 2014-12-30
126 -==================
127 -
128 - * deps: mime-types@~2.0.5
129 - - deps: mime-db@~1.3.1
130 -
131 -1.2.0 / 2014-12-19
132 -==================
133 -
134 - * deps: negotiator@0.5.0
135 - - Fix list return order when large accepted list
136 - - Fix missing identity encoding when q=0 exists
137 - - Remove dynamic building of Negotiator class
138 -
139 -1.1.4 / 2014-12-10
140 -==================
141 -
142 - * deps: mime-types@~2.0.4
143 - - deps: mime-db@~1.3.0
144 -
145 -1.1.3 / 2014-11-09
146 -==================
147 -
148 - * deps: mime-types@~2.0.3
149 - - deps: mime-db@~1.2.0
150 -
151 -1.1.2 / 2014-10-14
152 -==================
153 -
154 - * deps: negotiator@0.4.9
155 - - Fix error when media type has invalid parameter
156 -
157 -1.1.1 / 2014-09-28
158 -==================
159 -
160 - * deps: mime-types@~2.0.2
161 - - deps: mime-db@~1.1.0
162 - * deps: negotiator@0.4.8
163 - - Fix all negotiations to be case-insensitive
164 - - Stable sort preferences of same quality according to client order
165 -
166 -1.1.0 / 2014-09-02
167 -==================
168 -
169 - * update `mime-types`
170 -
171 -1.0.7 / 2014-07-04
172 -==================
173 -
174 - * Fix wrong type returned from `type` when match after unknown extension
175 -
176 -1.0.6 / 2014-06-24
177 -==================
178 -
179 - * deps: negotiator@0.4.7
180 -
181 -1.0.5 / 2014-06-20
182 -==================
183 -
184 - * fix crash when unknown extension given
185 -
186 -1.0.4 / 2014-06-19
187 -==================
188 -
189 - * use `mime-types`
190 -
191 -1.0.3 / 2014-06-11
192 -==================
193 -
194 - * deps: negotiator@0.4.6
195 - - Order by specificity when quality is the same
196 -
197 -1.0.2 / 2014-05-29
198 -==================
199 -
200 - * Fix interpretation when header not in request
201 - * deps: pin negotiator@0.4.5
202 -
203 -1.0.1 / 2014-01-18
204 -==================
205 -
206 - * Identity encoding isn't always acceptable
207 - * deps: negotiator@~0.4.0
208 -
209 -1.0.0 / 2013-12-27
210 -==================
211 -
212 - * Genesis
1 -(The MIT License)
2 -
3 -Copyright (c) 2014 Jonathan Ong <me@jongleberry.com>
4 -Copyright (c) 2015 Douglas Christopher Wilson <doug@somethingdoug.com>
5 -
6 -Permission is hereby granted, free of charge, to any person obtaining
7 -a copy of this software and associated documentation files (the
8 -'Software'), to deal in the Software without restriction, including
9 -without limitation the rights to use, copy, modify, merge, publish,
10 -distribute, sublicense, and/or sell copies of the Software, and to
11 -permit persons to whom the Software is furnished to do so, subject to
12 -the following conditions:
13 -
14 -The above copyright notice and this permission notice shall be
15 -included in all copies or substantial portions of the Software.
16 -
17 -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
18 -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1 -# accepts
2 -
3 -[![NPM Version][npm-image]][npm-url]
4 -[![NPM Downloads][downloads-image]][downloads-url]
5 -[![Node.js Version][node-version-image]][node-version-url]
6 -[![Build Status][travis-image]][travis-url]
7 -[![Test Coverage][coveralls-image]][coveralls-url]
8 -
9 -Higher level content negotiation based on [negotiator](https://www.npmjs.com/package/negotiator). Extracted from [koa](https://www.npmjs.com/package/koa) for general use.
10 -
11 -In addition to negotiator, it allows:
12 -
13 -- Allows types as an array or arguments list, ie `(['text/html', 'application/json'])` as well as `('text/html', 'application/json')`.
14 -- Allows type shorthands such as `json`.
15 -- Returns `false` when no types match
16 -- Treats non-existent headers as `*`
17 -
18 -## Installation
19 -
20 -```sh
21 -npm install accepts
22 -```
23 -
24 -## API
25 -
26 -```js
27 -var accepts = require('accepts')
28 -```
29 -
30 -### accepts(req)
31 -
32 -Create a new `Accepts` object for the given `req`.
33 -
34 -#### .charset(charsets)
35 -
36 -Return the first accepted charset. If nothing in `charsets` is accepted,
37 -then `false` is returned.
38 -
39 -#### .charsets()
40 -
41 -Return the charsets that the request accepts, in the order of the client's
42 -preference (most preferred first).
43 -
44 -#### .encoding(encodings)
45 -
46 -Return the first accepted encoding. If nothing in `encodings` is accepted,
47 -then `false` is returned.
48 -
49 -#### .encodings()
50 -
51 -Return the encodings that the request accepts, in the order of the client's
52 -preference (most preferred first).
53 -
54 -#### .language(languages)
55 -
56 -Return the first accepted language. If nothing in `languages` is accepted,
57 -then `false` is returned.
58 -
59 -#### .languages()
60 -
61 -Return the languages that the request accepts, in the order of the client's
62 -preference (most preferred first).
63 -
64 -#### .type(types)
65 -
66 -Return the first accepted type (and it is returned as the same text as what
67 -appears in the `types` array). If nothing in `types` is accepted, then `false`
68 -is returned.
69 -
70 -The `types` array can contain full MIME types or file extensions. Any value
71 -that is not a full MIME types is passed to `require('mime-types').lookup`.
72 -
73 -#### .types()
74 -
75 -Return the types that the request accepts, in the order of the client's
76 -preference (most preferred first).
77 -
78 -## Examples
79 -
80 -### Simple type negotiation
81 -
82 -This simple example shows how to use `accepts` to return a different typed
83 -respond body based on what the client wants to accept. The server lists it's
84 -preferences in order and will get back the best match between the client and
85 -server.
86 -
87 -```js
88 -var accepts = require('accepts')
89 -var http = require('http')
90 -
91 -function app(req, res) {
92 - var accept = accepts(req)
93 -
94 - // the order of this list is significant; should be server preferred order
95 - switch(accept.type(['json', 'html'])) {
96 - case 'json':
97 - res.setHeader('Content-Type', 'application/json')
98 - res.write('{"hello":"world!"}')
99 - break
100 - case 'html':
101 - res.setHeader('Content-Type', 'text/html')
102 - res.write('<b>hello, world!</b>')
103 - break
104 - default:
105 - // the fallback is text/plain, so no need to specify it above
106 - res.setHeader('Content-Type', 'text/plain')
107 - res.write('hello, world!')
108 - break
109 - }
110 -
111 - res.end()
112 -}
113 -
114 -http.createServer(app).listen(3000)
115 -```
116 -
117 -You can test this out with the cURL program:
118 -```sh
119 -curl -I -H'Accept: text/html' http://localhost:3000/
120 -```
121 -
122 -## License
123 -
124 -[MIT](LICENSE)
125 -
126 -[npm-image]: https://img.shields.io/npm/v/accepts.svg
127 -[npm-url]: https://npmjs.org/package/accepts
128 -[node-version-image]: https://img.shields.io/node/v/accepts.svg
129 -[node-version-url]: http://nodejs.org/download/
130 -[travis-image]: https://img.shields.io/travis/jshttp/accepts/master.svg
131 -[travis-url]: https://travis-ci.org/jshttp/accepts
132 -[coveralls-image]: https://img.shields.io/coveralls/jshttp/accepts/master.svg
133 -[coveralls-url]: https://coveralls.io/r/jshttp/accepts
134 -[downloads-image]: https://img.shields.io/npm/dm/accepts.svg
135 -[downloads-url]: https://npmjs.org/package/accepts
1 -/*!
2 - * accepts
3 - * Copyright(c) 2014 Jonathan Ong
4 - * Copyright(c) 2015 Douglas Christopher Wilson
5 - * MIT Licensed
6 - */
7 -
8 -'use strict'
9 -
10 -/**
11 - * Module dependencies.
12 - * @private
13 - */
14 -
15 -var Negotiator = require('negotiator')
16 -var mime = require('mime-types')
17 -
18 -/**
19 - * Module exports.
20 - * @public
21 - */
22 -
23 -module.exports = Accepts
24 -
25 -/**
26 - * Create a new Accepts object for the given req.
27 - *
28 - * @param {object} req
29 - * @public
30 - */
31 -
32 -function Accepts(req) {
33 - if (!(this instanceof Accepts))
34 - return new Accepts(req)
35 -
36 - this.headers = req.headers
37 - this.negotiator = new Negotiator(req)
38 -}
39 -
40 -/**
41 - * Check if the given `type(s)` is acceptable, returning
42 - * the best match when true, otherwise `undefined`, in which
43 - * case you should respond with 406 "Not Acceptable".
44 - *
45 - * The `type` value may be a single mime type string
46 - * such as "application/json", the extension name
47 - * such as "json" or an array `["json", "html", "text/plain"]`. When a list
48 - * or array is given the _best_ match, if any is returned.
49 - *
50 - * Examples:
51 - *
52 - * // Accept: text/html
53 - * this.types('html');
54 - * // => "html"
55 - *
56 - * // Accept: text/*, application/json
57 - * this.types('html');
58 - * // => "html"
59 - * this.types('text/html');
60 - * // => "text/html"
61 - * this.types('json', 'text');
62 - * // => "json"
63 - * this.types('application/json');
64 - * // => "application/json"
65 - *
66 - * // Accept: text/*, application/json
67 - * this.types('image/png');
68 - * this.types('png');
69 - * // => undefined
70 - *
71 - * // Accept: text/*;q=.5, application/json
72 - * this.types(['html', 'json']);
73 - * this.types('html', 'json');
74 - * // => "json"
75 - *
76 - * @param {String|Array} types...
77 - * @return {String|Array|Boolean}
78 - * @public
79 - */
80 -
81 -Accepts.prototype.type =
82 -Accepts.prototype.types = function (types_) {
83 - var types = types_
84 -
85 - // support flattened arguments
86 - if (types && !Array.isArray(types)) {
87 - types = new Array(arguments.length)
88 - for (var i = 0; i < types.length; i++) {
89 - types[i] = arguments[i]
90 - }
91 - }
92 -
93 - // no types, return all requested types
94 - if (!types || types.length === 0) {
95 - return this.negotiator.mediaTypes()
96 - }
97 -
98 - if (!this.headers.accept) return types[0];
99 - var mimes = types.map(extToMime);
100 - var accepts = this.negotiator.mediaTypes(mimes.filter(validMime));
101 - var first = accepts[0];
102 - if (!first) return false;
103 - return types[mimes.indexOf(first)];
104 -}
105 -
106 -/**
107 - * Return accepted encodings or best fit based on `encodings`.
108 - *
109 - * Given `Accept-Encoding: gzip, deflate`
110 - * an array sorted by quality is returned:
111 - *
112 - * ['gzip', 'deflate']
113 - *
114 - * @param {String|Array} encodings...
115 - * @return {String|Array}
116 - * @public
117 - */
118 -
119 -Accepts.prototype.encoding =
120 -Accepts.prototype.encodings = function (encodings_) {
121 - var encodings = encodings_
122 -
123 - // support flattened arguments
124 - if (encodings && !Array.isArray(encodings)) {
125 - encodings = new Array(arguments.length)
126 - for (var i = 0; i < encodings.length; i++) {
127 - encodings[i] = arguments[i]
128 - }
129 - }
130 -
131 - // no encodings, return all requested encodings
132 - if (!encodings || encodings.length === 0) {
133 - return this.negotiator.encodings()
134 - }
135 -
136 - return this.negotiator.encodings(encodings)[0] || false
137 -}
138 -
139 -/**
140 - * Return accepted charsets or best fit based on `charsets`.
141 - *
142 - * Given `Accept-Charset: utf-8, iso-8859-1;q=0.2, utf-7;q=0.5`
143 - * an array sorted by quality is returned:
144 - *
145 - * ['utf-8', 'utf-7', 'iso-8859-1']
146 - *
147 - * @param {String|Array} charsets...
148 - * @return {String|Array}
149 - * @public
150 - */
151 -
152 -Accepts.prototype.charset =
153 -Accepts.prototype.charsets = function (charsets_) {
154 - var charsets = charsets_
155 -
156 - // support flattened arguments
157 - if (charsets && !Array.isArray(charsets)) {
158 - charsets = new Array(arguments.length)
159 - for (var i = 0; i < charsets.length; i++) {
160 - charsets[i] = arguments[i]
161 - }
162 - }
163 -
164 - // no charsets, return all requested charsets
165 - if (!charsets || charsets.length === 0) {
166 - return this.negotiator.charsets()
167 - }
168 -
169 - return this.negotiator.charsets(charsets)[0] || false
170 -}
171 -
172 -/**
173 - * Return accepted languages or best fit based on `langs`.
174 - *
175 - * Given `Accept-Language: en;q=0.8, es, pt`
176 - * an array sorted by quality is returned:
177 - *
178 - * ['es', 'pt', 'en']
179 - *
180 - * @param {String|Array} langs...
181 - * @return {Array|String}
182 - * @public
183 - */
184 -
185 -Accepts.prototype.lang =
186 -Accepts.prototype.langs =
187 -Accepts.prototype.language =
188 -Accepts.prototype.languages = function (languages_) {
189 - var languages = languages_
190 -
191 - // support flattened arguments
192 - if (languages && !Array.isArray(languages)) {
193 - languages = new Array(arguments.length)
194 - for (var i = 0; i < languages.length; i++) {
195 - languages[i] = arguments[i]
196 - }
197 - }
198 -
199 - // no languages, return all requested languages
200 - if (!languages || languages.length === 0) {
201 - return this.negotiator.languages()
202 - }
203 -
204 - return this.negotiator.languages(languages)[0] || false
205 -}
206 -
207 -/**
208 - * Convert extnames to mime.
209 - *
210 - * @param {String} type
211 - * @return {String}
212 - * @private
213 - */
214 -
215 -function extToMime(type) {
216 - return type.indexOf('/') === -1
217 - ? mime.lookup(type)
218 - : type
219 -}
220 -
221 -/**
222 - * Check if mime is valid.
223 - *
224 - * @param {String} type
225 - * @return {String}
226 - * @private
227 - */
228 -
229 -function validMime(type) {
230 - return typeof type === 'string';
231 -}
1 -{
2 - "_args": [
3 - [
4 - {
5 - "raw": "accepts@~1.3.3",
6 - "scope": null,
7 - "escapedName": "accepts",
8 - "name": "accepts",
9 - "rawSpec": "~1.3.3",
10 - "spec": ">=1.3.3 <1.4.0",
11 - "type": "range"
12 - },
13 - "C:\\Users\\yoon\\Desktop\\JS\\RUTroll\\node_modules\\express"
14 - ]
15 - ],
16 - "_from": "accepts@>=1.3.3 <1.4.0",
17 - "_id": "accepts@1.3.3",
18 - "_inCache": true,
19 - "_location": "/accepts",
20 - "_nodeVersion": "4.4.3",
21 - "_npmOperationalInternal": {
22 - "host": "packages-16-east.internal.npmjs.com",
23 - "tmp": "tmp/accepts-1.3.3.tgz_1462251932032_0.7092335098423064"
24 - },
25 - "_npmUser": {
26 - "name": "dougwilson",
27 - "email": "doug@somethingdoug.com"
28 - },
29 - "_npmVersion": "2.15.1",
30 - "_phantomChildren": {},
31 - "_requested": {
32 - "raw": "accepts@~1.3.3",
33 - "scope": null,
34 - "escapedName": "accepts",
35 - "name": "accepts",
36 - "rawSpec": "~1.3.3",
37 - "spec": ">=1.3.3 <1.4.0",
38 - "type": "range"
39 - },
40 - "_requiredBy": [
41 - "/express"
42 - ],
43 - "_resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.3.tgz",
44 - "_shasum": "c3ca7434938648c3e0d9c1e328dd68b622c284ca",
45 - "_shrinkwrap": null,
46 - "_spec": "accepts@~1.3.3",
47 - "_where": "C:\\Users\\yoon\\Desktop\\JS\\RUTroll\\node_modules\\express",
48 - "bugs": {
49 - "url": "https://github.com/jshttp/accepts/issues"
50 - },
51 - "contributors": [
52 - {
53 - "name": "Douglas Christopher Wilson",
54 - "email": "doug@somethingdoug.com"
55 - },
56 - {
57 - "name": "Jonathan Ong",
58 - "email": "me@jongleberry.com",
59 - "url": "http://jongleberry.com"
60 - }
61 - ],
62 - "dependencies": {
63 - "mime-types": "~2.1.11",
64 - "negotiator": "0.6.1"
65 - },
66 - "description": "Higher-level content negotiation",
67 - "devDependencies": {
68 - "istanbul": "0.4.3",
69 - "mocha": "~1.21.5"
70 - },
71 - "directories": {},
72 - "dist": {
73 - "shasum": "c3ca7434938648c3e0d9c1e328dd68b622c284ca",
74 - "tarball": "https://registry.npmjs.org/accepts/-/accepts-1.3.3.tgz"
75 - },
76 - "engines": {
77 - "node": ">= 0.6"
78 - },
79 - "files": [
80 - "LICENSE",
81 - "HISTORY.md",
82 - "index.js"
83 - ],
84 - "gitHead": "3e925b1e65ed7da2798849683d49814680dfa426",
85 - "homepage": "https://github.com/jshttp/accepts#readme",
86 - "keywords": [
87 - "content",
88 - "negotiation",
89 - "accept",
90 - "accepts"
91 - ],
92 - "license": "MIT",
93 - "maintainers": [
94 - {
95 - "name": "dougwilson",
96 - "email": "doug@somethingdoug.com"
97 - }
98 - ],
99 - "name": "accepts",
100 - "optionalDependencies": {},
101 - "readme": "ERROR: No README data found!",
102 - "repository": {
103 - "type": "git",
104 - "url": "git+https://github.com/jshttp/accepts.git"
105 - },
106 - "scripts": {
107 - "test": "mocha --reporter spec --check-leaks --bail test/",
108 - "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/",
109 - "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/"
110 - },
111 - "version": "1.3.3"
112 -}
1 -var Ajv = require('ajv');
2 -var ajv = Ajv({allErrors: true});
3 -
4 -var schema = {
5 - "properties": {
6 - "foo": { "type": "string" },
7 - "bar": { "type": "number", "maximum": 3 }
8 - }
9 -};
10 -
11 -var validate = ajv.compile(schema);
12 -
13 -test({"foo": "abc", "bar": 2});
14 -test({"foo": 2, "bar": 4});
15 -
16 -function test(data) {
17 - var valid = validate(data);
18 - if (valid) console.log('Valid!');
19 - else console.log('Invalid: ' + ajv.errorsText(validate.errors));
20 -}
...\ No newline at end of file ...\ No newline at end of file
1 -The MIT License (MIT)
2 -
3 -Copyright (c) 2015 Evgeny Poberezkin
4 -
5 -Permission is hereby granted, free of charge, to any person obtaining a copy
6 -of this software and associated documentation files (the "Software"), to deal
7 -in the Software without restriction, including without limitation the rights
8 -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 -copies of the Software, and to permit persons to whom the Software is
10 -furnished to do so, subject to the following conditions:
11 -
12 -The above copyright notice and this permission notice shall be included in all
13 -copies or substantial portions of the Software.
14 -
15 -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 -SOFTWARE.
22 -
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
1 -declare var ajv: {
2 - (options?: ajv.Options): ajv.Ajv;
3 - new (options?: ajv.Options): ajv.Ajv;
4 -}
5 -
6 -declare namespace ajv {
7 - interface Ajv {
8 - /**
9 - * Validate data using schema
10 - * Schema will be compiled and cached (using serialized JSON as key. [json-stable-stringify](https://github.com/substack/json-stable-stringify) is used to serialize.
11 - * @param {String|Object} schemaKeyRef key, ref or schema object
12 - * @param {Any} data to be validated
13 - * @return {Boolean} validation result. Errors from the last validation will be available in `ajv.errors` (and also in compiled schema: `schema.errors`).
14 - */
15 - validate(schemaKeyRef: Object | string, data: any): boolean;
16 - /**
17 - * Create validating function for passed schema.
18 - * @param {Object} schema schema object
19 - * @return {Function} validating function
20 - */
21 - compile(schema: Object): ValidateFunction;
22 - /**
23 - * Creates validating function for passed schema with asynchronous loading of missing schemas.
24 - * `loadSchema` option should be a function that accepts schema uri and node-style callback.
25 - * @this Ajv
26 - * @param {Object} schema schema object
27 - * @param {Function} callback node-style callback, it is always called with 2 parameters: error (or null) and validating function.
28 - */
29 - compileAsync(schema: Object, callback: (err: Error, validate: ValidateFunction) => any): void;
30 - /**
31 - * Adds schema to the instance.
32 - * @param {Object|Array} schema schema or array of schemas. If array is passed, `key` and other parameters will be ignored.
33 - * @param {String} key Optional schema key. Can be passed to `validate` method instead of schema object or id/ref. One schema per instance can have empty `id` and `key`.
34 - */
35 - addSchema(schema: Array<Object> | Object, key?: string): void;
36 - /**
37 - * Add schema that will be used to validate other schemas
38 - * options in META_IGNORE_OPTIONS are alway set to false
39 - * @param {Object} schema schema object
40 - * @param {String} key optional schema key
41 - */
42 - addMetaSchema(schema: Object, key?: string): void;
43 - /**
44 - * Validate schema
45 - * @param {Object} schema schema to validate
46 - * @return {Boolean} true if schema is valid
47 - */
48 - validateSchema(schema: Object): boolean;
49 - /**
50 - * Get compiled schema from the instance by `key` or `ref`.
51 - * @param {String} keyRef `key` that was passed to `addSchema` or full schema reference (`schema.id` or resolved id).
52 - * @return {Function} schema validating function (with property `schema`).
53 - */
54 - getSchema(keyRef: string): ValidateFunction;
55 - /**
56 - * Remove cached schema(s).
57 - * If no parameter is passed all schemas but meta-schemas are removed.
58 - * If RegExp is passed all schemas with key/id matching pattern but meta-schemas are removed.
59 - * Even if schema is referenced by other schemas it still can be removed as other schemas have local references.
60 - * @param {String|Object|RegExp} schemaKeyRef key, ref, pattern to match key/ref or schema object
61 - */
62 - removeSchema(schemaKeyRef?: Object | string | RegExp): void;
63 - /**
64 - * Add custom format
65 - * @param {String} name format name
66 - * @param {String|RegExp|Function} format string is converted to RegExp; function should return boolean (true when valid)
67 - */
68 - addFormat(name: string, format: FormatValidator | FormatDefinition): void;
69 - /**
70 - * Define custom keyword
71 - * @this Ajv
72 - * @param {String} keyword custom keyword, should be a valid identifier, should be different from all standard, custom and macro keywords.
73 - * @param {Object} definition keyword definition object with properties `type` (type(s) which the keyword applies to), `validate` or `compile`.
74 - */
75 - addKeyword(keyword: string, definition: KeywordDefinition): void;
76 - /**
77 - * Get keyword definition
78 - * @this Ajv
79 - * @param {String} keyword pre-defined or custom keyword.
80 - * @return {Object|Boolean} custom keyword definition, `true` if it is a predefined keyword, `false` otherwise.
81 - */
82 - getKeyword(keyword: string): Object | boolean;
83 - /**
84 - * Remove keyword
85 - * @this Ajv
86 - * @param {String} keyword pre-defined or custom keyword.
87 - */
88 - removeKeyword(keyword: string): void;
89 - /**
90 - * Convert array of error message objects to string
91 - * @param {Array<Object>} errors optional array of validation errors, if not passed errors from the instance are used.
92 - * @param {Object} options optional options with properties `separator` and `dataVar`.
93 - * @return {String} human readable string with all errors descriptions
94 - */
95 - errorsText(errors?: Array<ErrorObject>, options?: ErrorsTextOptions): string;
96 - errors?: Array<ErrorObject>;
97 - }
98 -
99 - interface Thenable <R> {
100 - then <U> (onFulfilled?: (value: R) => U | Thenable<U>, onRejected?: (error: any) => U | Thenable<U>): Thenable<U>;
101 - }
102 -
103 - interface ValidateFunction {
104 - (
105 - data: any,
106 - dataPath?: string,
107 - parentData?: Object | Array<any>,
108 - parentDataProperty?: string | number,
109 - rootData?: Object | Array<any>
110 - ): boolean | Thenable<boolean>;
111 - errors?: Array<ErrorObject>;
112 - schema?: Object;
113 - }
114 -
115 - interface Options {
116 - v5?: boolean;
117 - allErrors?: boolean;
118 - verbose?: boolean;
119 - jsonPointers?: boolean;
120 - uniqueItems?: boolean;
121 - unicode?: boolean;
122 - format?: string;
123 - formats?: Object;
124 - unknownFormats?: boolean | string | Array<string>;
125 - schemas?: Array<Object> | Object;
126 - ownProperties?: boolean;
127 - missingRefs?: boolean | string;
128 - extendRefs?: boolean | string;
129 - loadSchema?: (uri: string, cb: (err: Error, schema: Object) => any) => any;
130 - removeAdditional?: boolean | string;
131 - useDefaults?: boolean | string;
132 - coerceTypes?: boolean | string;
133 - async?: boolean | string;
134 - transpile?: string | ((code: string) => string);
135 - meta?: boolean | Object;
136 - validateSchema?: boolean | string;
137 - addUsedSchema?: boolean;
138 - inlineRefs?: boolean | number;
139 - passContext?: boolean;
140 - loopRequired?: number;
141 - multipleOfPrecision?: number;
142 - errorDataPath?: string;
143 - messages?: boolean;
144 - sourceCode?: boolean;
145 - beautify?: boolean | Object;
146 - cache?: Object;
147 - }
148 -
149 - type FormatValidator = string | RegExp | ((data: string) => boolean);
150 -
151 - interface FormatDefinition {
152 - validate: FormatValidator;
153 - compare: (data1: string, data2: string) => number;
154 - async?: boolean;
155 - }
156 -
157 - interface KeywordDefinition {
158 - type?: string | Array<string>;
159 - async?: boolean;
160 - errors?: boolean | string;
161 - // schema: false makes validate not to expect schema (ValidateFunction)
162 - schema?: boolean;
163 - modifying?: boolean;
164 - valid?: boolean;
165 - // one and only one of the following properties should be present
166 - validate?: ValidateFunction | SchemaValidateFunction;
167 - compile?: (schema: Object, parentSchema: Object) => ValidateFunction;
168 - macro?: (schema: Object, parentSchema: Object) => Object;
169 - inline?: (it: Object, keyword: string, schema: Object, parentSchema: Object) => string;
170 - }
171 -
172 - interface SchemaValidateFunction {
173 - (
174 - schema: Object,
175 - data: any,
176 - parentSchema?: Object,
177 - dataPath?: string,
178 - parentData?: Object | Array<any>,
179 - parentDataProperty?: string | number
180 - ): boolean | Thenable<boolean>;
181 - errors?: Array<ErrorObject>;
182 - }
183 -
184 - interface ErrorsTextOptions {
185 - separator?: string;
186 - dataVar?: string;
187 - }
188 -
189 - interface ErrorObject {
190 - keyword: string;
191 - dataPath: string;
192 - schemaPath: string;
193 - params: ErrorParameters;
194 - // Excluded if messages set to false.
195 - message?: string;
196 - // These are added with the `verbose` option.
197 - schema?: Object;
198 - parentSchema?: Object;
199 - data?: any;
200 - }
201 -
202 - type ErrorParameters = RefParams | LimitParams | AdditionalPropertiesParams |
203 - DependenciesParams | FormatParams | ComparisonParams |
204 - MultipleOfParams | PatternParams | RequiredParams |
205 - TypeParams | UniqueItemsParams | CustomParams |
206 - PatternGroupsParams | PatternRequiredParams |
207 - SwitchParams | NoParams | EnumParams;
208 -
209 - interface RefParams {
210 - ref: string;
211 - }
212 -
213 - interface LimitParams {
214 - limit: number;
215 - }
216 -
217 - interface AdditionalPropertiesParams {
218 - additionalProperty: string;
219 - }
220 -
221 - interface DependenciesParams {
222 - property: string;
223 - missingProperty: string;
224 - depsCount: number;
225 - deps: string;
226 - }
227 -
228 - interface FormatParams {
229 - format: string
230 - }
231 -
232 - interface ComparisonParams {
233 - comparison: string;
234 - limit: number | string;
235 - exclusive: boolean;
236 - }
237 -
238 - interface MultipleOfParams {
239 - multipleOf: number;
240 - }
241 -
242 - interface PatternParams {
243 - pattern: string;
244 - }
245 -
246 - interface RequiredParams {
247 - missingProperty: string;
248 - }
249 -
250 - interface TypeParams {
251 - type: string;
252 - }
253 -
254 - interface UniqueItemsParams {
255 - i: number;
256 - j: number;
257 - }
258 -
259 - interface CustomParams {
260 - keyword: string;
261 - }
262 -
263 - interface PatternGroupsParams {
264 - reason: string;
265 - limit: number;
266 - pattern: string;
267 - }
268 -
269 - interface PatternRequiredParams {
270 - missingPattern: string;
271 - }
272 -
273 - interface SwitchParams {
274 - caseIndex: number;
275 - }
276 -
277 - interface NoParams {}
278 -
279 - interface EnumParams {
280 - allowedValues: Array<any>;
281 - }
282 -}
283 -
284 -export = ajv;
This diff is collapsed. Click to expand it.
1 -'use strict';
2 -
3 -module.exports = {
4 - setup: setupAsync,
5 - compile: compileAsync
6 -};
7 -
8 -
9 -var util = require('./compile/util');
10 -
11 -var ASYNC = {
12 - '*': checkGenerators,
13 - 'co*': checkGenerators,
14 - 'es7': checkAsyncFunction
15 -};
16 -
17 -var TRANSPILE = {
18 - 'nodent': getNodent,
19 - 'regenerator': getRegenerator
20 -};
21 -
22 -var MODES = [
23 - { async: 'co*' },
24 - { async: 'es7', transpile: 'nodent' },
25 - { async: 'co*', transpile: 'regenerator' }
26 -];
27 -
28 -
29 -var regenerator, nodent;
30 -
31 -
32 -function setupAsync(opts, required) {
33 - if (required !== false) required = true;
34 - var async = opts.async
35 - , transpile = opts.transpile
36 - , check;
37 -
38 - switch (typeof transpile) {
39 - case 'string':
40 - var get = TRANSPILE[transpile];
41 - if (!get) throw new Error('bad transpiler: ' + transpile);
42 - return (opts._transpileFunc = get(opts, required));
43 - case 'undefined':
44 - case 'boolean':
45 - if (typeof async == 'string') {
46 - check = ASYNC[async];
47 - if (!check) throw new Error('bad async mode: ' + async);
48 - return (opts.transpile = check(opts, required));
49 - }
50 -
51 - for (var i=0; i<MODES.length; i++) {
52 - var _opts = MODES[i];
53 - if (setupAsync(_opts, false)) {
54 - util.copy(_opts, opts);
55 - return opts.transpile;
56 - }
57 - }
58 - /* istanbul ignore next */
59 - throw new Error('generators, nodent and regenerator are not available');
60 - case 'function':
61 - return (opts._transpileFunc = opts.transpile);
62 - default:
63 - throw new Error('bad transpiler: ' + transpile);
64 - }
65 -}
66 -
67 -
68 -function checkGenerators(opts, required) {
69 - /* jshint evil: true */
70 - try {
71 - (new Function('(function*(){})()'))();
72 - return true;
73 - } catch(e) {
74 - /* istanbul ignore next */
75 - if (required) throw new Error('generators not supported');
76 - }
77 -}
78 -
79 -
80 -function checkAsyncFunction(opts, required) {
81 - /* jshint evil: true */
82 - try {
83 - (new Function('(async function(){})()'))();
84 - /* istanbul ignore next */
85 - return true;
86 - } catch(e) {
87 - if (required) throw new Error('es7 async functions not supported');
88 - }
89 -}
90 -
91 -
92 -function getRegenerator(opts, required) {
93 - try {
94 - if (!regenerator) {
95 - var name = 'regenerator';
96 - regenerator = require(name);
97 - regenerator.runtime();
98 - }
99 - if (!opts.async || opts.async === true)
100 - opts.async = 'es7';
101 - return regeneratorTranspile;
102 - } catch(e) {
103 - /* istanbul ignore next */
104 - if (required) throw new Error('regenerator not available');
105 - }
106 -}
107 -
108 -
109 -function regeneratorTranspile(code) {
110 - return regenerator.compile(code).code;
111 -}
112 -
113 -
114 -function getNodent(opts, required) {
115 - /* jshint evil: true */
116 - try {
117 - if (!nodent) {
118 - var name = 'nodent';
119 - nodent = require(name)({ log: false, dontInstallRequireHook: true });
120 - }
121 - if (opts.async != 'es7') {
122 - if (opts.async && opts.async !== true) console.warn('nodent transpiles only es7 async functions');
123 - opts.async = 'es7';
124 - }
125 - return nodentTranspile;
126 - } catch(e) {
127 - /* istanbul ignore next */
128 - if (required) throw new Error('nodent not available');
129 - }
130 -}
131 -
132 -
133 -function nodentTranspile(code) {
134 - return nodent.compile(code, '', { promises: true, sourcemap: false }).code;
135 -}
136 -
137 -
138 -/**
139 - * Creates validating function for passed schema with asynchronous loading of missing schemas.
140 - * `loadSchema` option should be a function that accepts schema uri and node-style callback.
141 - * @this Ajv
142 - * @param {Object} schema schema object
143 - * @param {Function} callback node-style callback, it is always called with 2 parameters: error (or null) and validating function.
144 - */
145 -function compileAsync(schema, callback) {
146 - /* eslint no-shadow: 0 */
147 - /* jshint validthis: true */
148 - var schemaObj;
149 - var self = this;
150 - try {
151 - schemaObj = this._addSchema(schema);
152 - } catch(e) {
153 - setTimeout(function() { callback(e); });
154 - return;
155 - }
156 - if (schemaObj.validate) {
157 - setTimeout(function() { callback(null, schemaObj.validate); });
158 - } else {
159 - if (typeof this._opts.loadSchema != 'function')
160 - throw new Error('options.loadSchema should be a function');
161 - _compileAsync(schema, callback, true);
162 - }
163 -
164 -
165 - function _compileAsync(schema, callback, firstCall) {
166 - var validate;
167 - try { validate = self.compile(schema); }
168 - catch(e) {
169 - if (e.missingSchema) loadMissingSchema(e);
170 - else deferCallback(e);
171 - return;
172 - }
173 - deferCallback(null, validate);
174 -
175 - function loadMissingSchema(e) {
176 - var ref = e.missingSchema;
177 - if (self._refs[ref] || self._schemas[ref])
178 - return callback(new Error('Schema ' + ref + ' is loaded but ' + e.missingRef + ' cannot be resolved'));
179 - var _callbacks = self._loadingSchemas[ref];
180 - if (_callbacks) {
181 - if (typeof _callbacks == 'function')
182 - self._loadingSchemas[ref] = [_callbacks, schemaLoaded];
183 - else
184 - _callbacks[_callbacks.length] = schemaLoaded;
185 - } else {
186 - self._loadingSchemas[ref] = schemaLoaded;
187 - self._opts.loadSchema(ref, function (err, sch) {
188 - var _callbacks = self._loadingSchemas[ref];
189 - delete self._loadingSchemas[ref];
190 - if (typeof _callbacks == 'function') {
191 - _callbacks(err, sch);
192 - } else {
193 - for (var i=0; i<_callbacks.length; i++)
194 - _callbacks[i](err, sch);
195 - }
196 - });
197 - }
198 -
199 - function schemaLoaded(err, sch) {
200 - if (err) return callback(err);
201 - if (!(self._refs[ref] || self._schemas[ref])) {
202 - try {
203 - self.addSchema(sch, ref);
204 - } catch(e) {
205 - callback(e);
206 - return;
207 - }
208 - }
209 - _compileAsync(schema, callback);
210 - }
211 - }
212 -
213 - function deferCallback(err, validate) {
214 - if (firstCall) setTimeout(function() { callback(err, validate); });
215 - else return callback(err, validate);
216 - }
217 - }
218 -}
1 -'use strict';
2 -
3 -
4 -var Cache = module.exports = function Cache() {
5 - this._cache = {};
6 -};
7 -
8 -
9 -Cache.prototype.put = function Cache_put(key, value) {
10 - this._cache[key] = value;
11 -};
12 -
13 -
14 -Cache.prototype.get = function Cache_get(key) {
15 - return this._cache[key];
16 -};
17 -
18 -
19 -Cache.prototype.del = function Cache_del(key) {
20 - delete this._cache[key];
21 -};
22 -
23 -
24 -Cache.prototype.clear = function Cache_clear() {
25 - this._cache = {};
26 -};
1 -'use strict';
2 -
3 -//all requires must be explicit because browserify won't work with dynamic requires
4 -module.exports = {
5 - '$ref': require('../dotjs/ref'),
6 - allOf: require('../dotjs/allOf'),
7 - anyOf: require('../dotjs/anyOf'),
8 - dependencies: require('../dotjs/dependencies'),
9 - 'enum': require('../dotjs/enum'),
10 - format: require('../dotjs/format'),
11 - items: require('../dotjs/items'),
12 - maximum: require('../dotjs/_limit'),
13 - minimum: require('../dotjs/_limit'),
14 - maxItems: require('../dotjs/_limitItems'),
15 - minItems: require('../dotjs/_limitItems'),
16 - maxLength: require('../dotjs/_limitLength'),
17 - minLength: require('../dotjs/_limitLength'),
18 - maxProperties: require('../dotjs/_limitProperties'),
19 - minProperties: require('../dotjs/_limitProperties'),
20 - multipleOf: require('../dotjs/multipleOf'),
21 - not: require('../dotjs/not'),
22 - oneOf: require('../dotjs/oneOf'),
23 - pattern: require('../dotjs/pattern'),
24 - properties: require('../dotjs/properties'),
25 - required: require('../dotjs/required'),
26 - uniqueItems: require('../dotjs/uniqueItems'),
27 - validate: require('../dotjs/validate')
28 -};
1 -'use strict';
2 -
3 -/*eslint complexity: 0*/
4 -
5 -module.exports = function equal(a, b) {
6 - if (a === b) return true;
7 -
8 - var arrA = Array.isArray(a)
9 - , arrB = Array.isArray(b)
10 - , i;
11 -
12 - if (arrA && arrB) {
13 - if (a.length != b.length) return false;
14 - for (i = 0; i < a.length; i++)
15 - if (!equal(a[i], b[i])) return false;
16 - return true;
17 - }
18 -
19 - if (arrA != arrB) return false;
20 -
21 - if (a && b && typeof a === 'object' && typeof b === 'object') {
22 - var keys = Object.keys(a);
23 - if (keys.length !== Object.keys(b).length) return false;
24 -
25 - var dateA = a instanceof Date
26 - , dateB = b instanceof Date;
27 - if (dateA && dateB) return a.getTime() == b.getTime();
28 - if (dateA != dateB) return false;
29 -
30 - var regexpA = a instanceof RegExp
31 - , regexpB = b instanceof RegExp;
32 - if (regexpA && regexpB) return a.toString() == b.toString();
33 - if (regexpA != regexpB) return false;
34 -
35 - for (i = 0; i < keys.length; i++)
36 - if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
37 -
38 - for (i = 0; i < keys.length; i++)
39 - if(!equal(a[keys[i]], b[keys[i]])) return false;
40 -
41 - return true;
42 - }
43 -
44 - return false;
45 -};
1 -'use strict';
2 -
3 -var util = require('./util');
4 -
5 -var DATE = /^\d\d\d\d-(\d\d)-(\d\d)$/;
6 -var DAYS = [0,31,29,31,30,31,30,31,31,30,31,30,31];
7 -var TIME = /^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d:\d\d)?$/i;
8 -var HOSTNAME = /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*$/i;
9 -var URI = /^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@\/?]|%[0-9a-f]{2})*)?(?:\#(?:[a-z0-9\-._~!$&'()*+,;=:@\/?]|%[0-9a-f]{2})*)?$/i;
10 -var UUID = /^(?:urn\:uuid\:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i;
11 -var JSON_POINTER = /^(?:\/(?:[^~\/]|~0|~1)*)*$|^\#(?:\/(?:[a-z0-9_\-\.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i;
12 -var RELATIVE_JSON_POINTER = /^(?:0|[1-9][0-9]*)(?:\#|(?:\/(?:[^~\/]|~0|~1)*)*)$/;
13 -
14 -
15 -module.exports = formats;
16 -
17 -function formats(mode) {
18 - mode = mode == 'full' ? 'full' : 'fast';
19 - var formatDefs = util.copy(formats[mode]);
20 - for (var fName in formats.compare) {
21 - formatDefs[fName] = {
22 - validate: formatDefs[fName],
23 - compare: formats.compare[fName]
24 - };
25 - }
26 - return formatDefs;
27 -}
28 -
29 -
30 -formats.fast = {
31 - // date: http://tools.ietf.org/html/rfc3339#section-5.6
32 - date: /^\d\d\d\d-[0-1]\d-[0-3]\d$/,
33 - // date-time: http://tools.ietf.org/html/rfc3339#section-5.6
34 - time: /^[0-2]\d:[0-5]\d:[0-5]\d(?:\.\d+)?(?:z|[+-]\d\d:\d\d)?$/i,
35 - 'date-time': /^\d\d\d\d-[0-1]\d-[0-3]\d[t\s][0-2]\d:[0-5]\d:[0-5]\d(?:\.\d+)?(?:z|[+-]\d\d:\d\d)$/i,
36 - // uri: https://github.com/mafintosh/is-my-json-valid/blob/master/formats.js
37 - uri: /^(?:[a-z][a-z0-9+-.]*)?(?:\:|\/)\/?[^\s]*$/i,
38 - // email (sources from jsen validator):
39 - // http://stackoverflow.com/questions/201323/using-a-regular-expression-to-validate-an-email-address#answer-8829363
40 - // http://www.w3.org/TR/html5/forms.html#valid-e-mail-address (search for 'willful violation')
41 - email: /^[a-z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i,
42 - hostname: HOSTNAME,
43 - // optimized https://www.safaribooksonline.com/library/view/regular-expressions-cookbook/9780596802837/ch07s16.html
44 - ipv4: /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,
45 - // optimized http://stackoverflow.com/questions/53497/regular-expression-that-matches-valid-ipv6-addresses
46 - ipv6: /^\s*(?:(?:(?:[0-9a-f]{1,4}:){7}(?:[0-9a-f]{1,4}|:))|(?:(?:[0-9a-f]{1,4}:){6}(?::[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){5}(?:(?:(?::[0-9a-f]{1,4}){1,2})|:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){4}(?:(?:(?::[0-9a-f]{1,4}){1,3})|(?:(?::[0-9a-f]{1,4})?:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){3}(?:(?:(?::[0-9a-f]{1,4}){1,4})|(?:(?::[0-9a-f]{1,4}){0,2}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){2}(?:(?:(?::[0-9a-f]{1,4}){1,5})|(?:(?::[0-9a-f]{1,4}){0,3}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){1}(?:(?:(?::[0-9a-f]{1,4}){1,6})|(?:(?::[0-9a-f]{1,4}){0,4}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?::(?:(?:(?::[0-9a-f]{1,4}){1,7})|(?:(?::[0-9a-f]{1,4}){0,5}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(?:%.+)?\s*$/i,
47 - regex: regex,
48 - // uuid: http://tools.ietf.org/html/rfc4122
49 - uuid: UUID,
50 - // JSON-pointer: https://tools.ietf.org/html/rfc6901
51 - // uri fragment: https://tools.ietf.org/html/rfc3986#appendix-A
52 - 'json-pointer': JSON_POINTER,
53 - // relative JSON-pointer: http://tools.ietf.org/html/draft-luff-relative-json-pointer-00
54 - 'relative-json-pointer': RELATIVE_JSON_POINTER
55 -};
56 -
57 -
58 -formats.full = {
59 - date: date,
60 - time: time,
61 - 'date-time': date_time,
62 - uri: uri,
63 - email: /^[a-z0-9!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&''*+\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,
64 - hostname: hostname,
65 - ipv4: /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,
66 - ipv6: /^\s*(?:(?:(?:[0-9a-f]{1,4}:){7}(?:[0-9a-f]{1,4}|:))|(?:(?:[0-9a-f]{1,4}:){6}(?::[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){5}(?:(?:(?::[0-9a-f]{1,4}){1,2})|:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){4}(?:(?:(?::[0-9a-f]{1,4}){1,3})|(?:(?::[0-9a-f]{1,4})?:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){3}(?:(?:(?::[0-9a-f]{1,4}){1,4})|(?:(?::[0-9a-f]{1,4}){0,2}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){2}(?:(?:(?::[0-9a-f]{1,4}){1,5})|(?:(?::[0-9a-f]{1,4}){0,3}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){1}(?:(?:(?::[0-9a-f]{1,4}){1,6})|(?:(?::[0-9a-f]{1,4}){0,4}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?::(?:(?:(?::[0-9a-f]{1,4}){1,7})|(?:(?::[0-9a-f]{1,4}){0,5}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(?:%.+)?\s*$/i,
67 - regex: regex,
68 - uuid: UUID,
69 - 'json-pointer': JSON_POINTER,
70 - 'relative-json-pointer': RELATIVE_JSON_POINTER
71 -};
72 -
73 -
74 -formats.compare = {
75 - date: compareDate,
76 - time: compareTime,
77 - 'date-time': compareDateTime
78 -};
79 -
80 -
81 -function date(str) {
82 - // full-date from http://tools.ietf.org/html/rfc3339#section-5.6
83 - var matches = str.match(DATE);
84 - if (!matches) return false;
85 -
86 - var month = +matches[1];
87 - var day = +matches[2];
88 - return month >= 1 && month <= 12 && day >= 1 && day <= DAYS[month];
89 -}
90 -
91 -
92 -function time(str, full) {
93 - var matches = str.match(TIME);
94 - if (!matches) return false;
95 -
96 - var hour = matches[1];
97 - var minute = matches[2];
98 - var second = matches[3];
99 - var timeZone = matches[5];
100 - return hour <= 23 && minute <= 59 && second <= 59 && (!full || timeZone);
101 -}
102 -
103 -
104 -var DATE_TIME_SEPARATOR = /t|\s/i;
105 -function date_time(str) {
106 - // http://tools.ietf.org/html/rfc3339#section-5.6
107 - var dateTime = str.split(DATE_TIME_SEPARATOR);
108 - return dateTime.length == 2 && date(dateTime[0]) && time(dateTime[1], true);
109 -}
110 -
111 -
112 -function hostname(str) {
113 - // https://tools.ietf.org/html/rfc1034#section-3.5
114 - // https://tools.ietf.org/html/rfc1123#section-2
115 - return str.length <= 255 && HOSTNAME.test(str);
116 -}
117 -
118 -
119 -var NOT_URI_FRAGMENT = /\/|\:/;
120 -function uri(str) {
121 - // http://jmrware.com/articles/2009/uri_regexp/URI_regex.html + optional protocol + required "."
122 - return NOT_URI_FRAGMENT.test(str) && URI.test(str);
123 -}
124 -
125 -
126 -function regex(str) {
127 - try {
128 - new RegExp(str);
129 - return true;
130 - } catch(e) {
131 - return false;
132 - }
133 -}
134 -
135 -
136 -function compareDate(d1, d2) {
137 - if (!(d1 && d2)) return;
138 - if (d1 > d2) return 1;
139 - if (d1 < d2) return -1;
140 - if (d1 === d2) return 0;
141 -}
142 -
143 -
144 -function compareTime(t1, t2) {
145 - if (!(t1 && t2)) return;
146 - t1 = t1.match(TIME);
147 - t2 = t2.match(TIME);
148 - if (!(t1 && t2)) return;
149 - t1 = t1[1] + t1[2] + t1[3] + (t1[4]||'');
150 - t2 = t2[1] + t2[2] + t2[3] + (t2[4]||'');
151 - if (t1 > t2) return 1;
152 - if (t1 < t2) return -1;
153 - if (t1 === t2) return 0;
154 -}
155 -
156 -
157 -function compareDateTime(dt1, dt2) {
158 - if (!(dt1 && dt2)) return;
159 - dt1 = dt1.split(DATE_TIME_SEPARATOR);
160 - dt2 = dt2.split(DATE_TIME_SEPARATOR);
161 - var res = compareDate(dt1[0], dt2[0]);
162 - if (res === undefined) return;
163 - return res || compareTime(dt1[1], dt2[1]);
164 -}
This diff is collapsed. Click to expand it.
1 -'use strict';
2 -
3 -var url = require('url')
4 - , equal = require('./equal')
5 - , util = require('./util')
6 - , SchemaObject = require('./schema_obj');
7 -
8 -module.exports = resolve;
9 -
10 -resolve.normalizeId = normalizeId;
11 -resolve.fullPath = getFullPath;
12 -resolve.url = resolveUrl;
13 -resolve.ids = resolveIds;
14 -resolve.inlineRef = inlineRef;
15 -resolve.schema = resolveSchema;
16 -
17 -/**
18 - * [resolve and compile the references ($ref)]
19 - * @this Ajv
20 - * @param {Function} compile reference to schema compilation funciton (localCompile)
21 - * @param {Object} root object with information about the root schema for the current schema
22 - * @param {String} ref reference to resolve
23 - * @return {Object|Function} schema object (if the schema can be inlined) or validation function
24 - */
25 -function resolve(compile, root, ref) {
26 - /* jshint validthis: true */
27 - var refVal = this._refs[ref];
28 - if (typeof refVal == 'string') {
29 - if (this._refs[refVal]) refVal = this._refs[refVal];
30 - else return resolve.call(this, compile, root, refVal);
31 - }
32 -
33 - refVal = refVal || this._schemas[ref];
34 - if (refVal instanceof SchemaObject) {
35 - return inlineRef(refVal.schema, this._opts.inlineRefs)
36 - ? refVal.schema
37 - : refVal.validate || this._compile(refVal);
38 - }
39 -
40 - var res = resolveSchema.call(this, root, ref);
41 - var schema, v, baseId;
42 - if (res) {
43 - schema = res.schema;
44 - root = res.root;
45 - baseId = res.baseId;
46 - }
47 -
48 - if (schema instanceof SchemaObject) {
49 - v = schema.validate || compile.call(this, schema.schema, root, undefined, baseId);
50 - } else if (schema) {
51 - v = inlineRef(schema, this._opts.inlineRefs)
52 - ? schema
53 - : compile.call(this, schema, root, undefined, baseId);
54 - }
55 -
56 - return v;
57 -}
58 -
59 -
60 -/**
61 - * Resolve schema, its root and baseId
62 - * @this Ajv
63 - * @param {Object} root root object with properties schema, refVal, refs
64 - * @param {String} ref reference to resolve
65 - * @return {Object} object with properties schema, root, baseId
66 - */
67 -function resolveSchema(root, ref) {
68 - /* jshint validthis: true */
69 - var p = url.parse(ref, false, true)
70 - , refPath = _getFullPath(p)
71 - , baseId = getFullPath(root.schema.id);
72 - if (refPath !== baseId) {
73 - var id = normalizeId(refPath);
74 - var refVal = this._refs[id];
75 - if (typeof refVal == 'string') {
76 - return resolveRecursive.call(this, root, refVal, p);
77 - } else if (refVal instanceof SchemaObject) {
78 - if (!refVal.validate) this._compile(refVal);
79 - root = refVal;
80 - } else {
81 - refVal = this._schemas[id];
82 - if (refVal instanceof SchemaObject) {
83 - if (!refVal.validate) this._compile(refVal);
84 - if (id == normalizeId(ref))
85 - return { schema: refVal, root: root, baseId: baseId };
86 - root = refVal;
87 - } else {
88 - return;
89 - }
90 - }
91 - if (!root.schema) return;
92 - baseId = getFullPath(root.schema.id);
93 - }
94 - return getJsonPointer.call(this, p, baseId, root.schema, root);
95 -}
96 -
97 -
98 -/* @this Ajv */
99 -function resolveRecursive(root, ref, parsedRef) {
100 - /* jshint validthis: true */
101 - var res = resolveSchema.call(this, root, ref);
102 - if (res) {
103 - var schema = res.schema;
104 - var baseId = res.baseId;
105 - root = res.root;
106 - if (schema.id) baseId = resolveUrl(baseId, schema.id);
107 - return getJsonPointer.call(this, parsedRef, baseId, schema, root);
108 - }
109 -}
110 -
111 -
112 -var PREVENT_SCOPE_CHANGE = util.toHash(['properties', 'patternProperties', 'enum', 'dependencies', 'definitions']);
113 -/* @this Ajv */
114 -function getJsonPointer(parsedRef, baseId, schema, root) {
115 - /* jshint validthis: true */
116 - parsedRef.hash = parsedRef.hash || '';
117 - if (parsedRef.hash.slice(0,2) != '#/') return;
118 - var parts = parsedRef.hash.split('/');
119 -
120 - for (var i = 1; i < parts.length; i++) {
121 - var part = parts[i];
122 - if (part) {
123 - part = util.unescapeFragment(part);
124 - schema = schema[part];
125 - if (!schema) break;
126 - if (schema.id && !PREVENT_SCOPE_CHANGE[part]) baseId = resolveUrl(baseId, schema.id);
127 - if (schema.$ref) {
128 - var $ref = resolveUrl(baseId, schema.$ref);
129 - var res = resolveSchema.call(this, root, $ref);
130 - if (res) {
131 - schema = res.schema;
132 - root = res.root;
133 - baseId = res.baseId;
134 - }
135 - }
136 - }
137 - }
138 - if (schema && schema != root.schema)
139 - return { schema: schema, root: root, baseId: baseId };
140 -}
141 -
142 -
143 -var SIMPLE_INLINED = util.toHash([
144 - 'type', 'format', 'pattern',
145 - 'maxLength', 'minLength',
146 - 'maxProperties', 'minProperties',
147 - 'maxItems', 'minItems',
148 - 'maximum', 'minimum',
149 - 'uniqueItems', 'multipleOf',
150 - 'required', 'enum'
151 -]);
152 -function inlineRef(schema, limit) {
153 - if (limit === false) return false;
154 - if (limit === undefined || limit === true) return checkNoRef(schema);
155 - else if (limit) return countKeys(schema) <= limit;
156 -}
157 -
158 -
159 -function checkNoRef(schema) {
160 - var item;
161 - if (Array.isArray(schema)) {
162 - for (var i=0; i<schema.length; i++) {
163 - item = schema[i];
164 - if (typeof item == 'object' && !checkNoRef(item)) return false;
165 - }
166 - } else {
167 - for (var key in schema) {
168 - if (key == '$ref') return false;
169 - item = schema[key];
170 - if (typeof item == 'object' && !checkNoRef(item)) return false;
171 - }
172 - }
173 - return true;
174 -}
175 -
176 -
177 -function countKeys(schema) {
178 - var count = 0, item;
179 - if (Array.isArray(schema)) {
180 - for (var i=0; i<schema.length; i++) {
181 - item = schema[i];
182 - if (typeof item == 'object') count += countKeys(item);
183 - if (count == Infinity) return Infinity;
184 - }
185 - } else {
186 - for (var key in schema) {
187 - if (key == '$ref') return Infinity;
188 - if (SIMPLE_INLINED[key]) {
189 - count++;
190 - } else {
191 - item = schema[key];
192 - if (typeof item == 'object') count += countKeys(item) + 1;
193 - if (count == Infinity) return Infinity;
194 - }
195 - }
196 - }
197 - return count;
198 -}
199 -
200 -
201 -function getFullPath(id, normalize) {
202 - if (normalize !== false) id = normalizeId(id);
203 - var p = url.parse(id, false, true);
204 - return _getFullPath(p);
205 -}
206 -
207 -
208 -function _getFullPath(p) {
209 - var protocolSeparator = p.protocol || p.href.slice(0,2) == '//' ? '//' : '';
210 - return (p.protocol||'') + protocolSeparator + (p.host||'') + (p.path||'') + '#';
211 -}
212 -
213 -
214 -var TRAILING_SLASH_HASH = /#\/?$/;
215 -function normalizeId(id) {
216 - return id ? id.replace(TRAILING_SLASH_HASH, '') : '';
217 -}
218 -
219 -
220 -function resolveUrl(baseId, id) {
221 - id = normalizeId(id);
222 - return url.resolve(baseId, id);
223 -}
224 -
225 -
226 -/* @this Ajv */
227 -function resolveIds(schema) {
228 - /* eslint no-shadow: 0 */
229 - /* jshint validthis: true */
230 - var id = normalizeId(schema.id);
231 - var localRefs = {};
232 - _resolveIds.call(this, schema, getFullPath(id, false), id);
233 - return localRefs;
234 -
235 - /* @this Ajv */
236 - function _resolveIds(schema, fullPath, baseId) {
237 - /* jshint validthis: true */
238 - if (Array.isArray(schema)) {
239 - for (var i=0; i<schema.length; i++)
240 - _resolveIds.call(this, schema[i], fullPath+'/'+i, baseId);
241 - } else if (schema && typeof schema == 'object') {
242 - if (typeof schema.id == 'string') {
243 - var id = baseId = baseId
244 - ? url.resolve(baseId, schema.id)
245 - : schema.id;
246 - id = normalizeId(id);
247 -
248 - var refVal = this._refs[id];
249 - if (typeof refVal == 'string') refVal = this._refs[refVal];
250 - if (refVal && refVal.schema) {
251 - if (!equal(schema, refVal.schema))
252 - throw new Error('id "' + id + '" resolves to more than one schema');
253 - } else if (id != normalizeId(fullPath)) {
254 - if (id[0] == '#') {
255 - if (localRefs[id] && !equal(schema, localRefs[id]))
256 - throw new Error('id "' + id + '" resolves to more than one schema');
257 - localRefs[id] = schema;
258 - } else {
259 - this._refs[id] = fullPath;
260 - }
261 - }
262 - }
263 - for (var key in schema)
264 - _resolveIds.call(this, schema[key], fullPath+'/'+util.escapeFragment(key), baseId);
265 - }
266 - }
267 -}
1 -'use strict';
2 -
3 -var ruleModules = require('./_rules')
4 - , toHash = require('./util').toHash;
5 -
6 -module.exports = function rules() {
7 - var RULES = [
8 - { type: 'number',
9 - rules: [ 'maximum', 'minimum', 'multipleOf'] },
10 - { type: 'string',
11 - rules: [ 'maxLength', 'minLength', 'pattern', 'format' ] },
12 - { type: 'array',
13 - rules: [ 'maxItems', 'minItems', 'uniqueItems', 'items' ] },
14 - { type: 'object',
15 - rules: [ 'maxProperties', 'minProperties', 'required', 'dependencies', 'properties' ] },
16 - { rules: [ '$ref', 'enum', 'not', 'anyOf', 'oneOf', 'allOf' ] }
17 - ];
18 -
19 - var ALL = [ 'type', 'additionalProperties', 'patternProperties' ];
20 - var KEYWORDS = [ 'additionalItems', '$schema', 'id', 'title', 'description', 'default' ];
21 - var TYPES = [ 'number', 'integer', 'string', 'array', 'object', 'boolean', 'null' ];
22 - RULES.all = toHash(ALL);
23 -
24 - RULES.forEach(function (group) {
25 - group.rules = group.rules.map(function (keyword) {
26 - ALL.push(keyword);
27 - var rule = RULES.all[keyword] = {
28 - keyword: keyword,
29 - code: ruleModules[keyword]
30 - };
31 - return rule;
32 - });
33 - });
34 -
35 - RULES.keywords = toHash(ALL.concat(KEYWORDS));
36 - RULES.types = toHash(TYPES);
37 - RULES.custom = {};
38 -
39 - return RULES;
40 -};
1 -'use strict';
2 -
3 -var util = require('./util');
4 -
5 -module.exports = SchemaObject;
6 -
7 -function SchemaObject(obj) {
8 - util.copy(obj, this);
9 -}
1 -'use strict';
2 -
3 -// https://mathiasbynens.be/notes/javascript-encoding
4 -// https://github.com/bestiejs/punycode.js - punycode.ucs2.decode
5 -module.exports = function ucs2length(str) {
6 - var length = 0
7 - , len = str.length
8 - , pos = 0
9 - , value;
10 - while (pos < len) {
11 - length++;
12 - value = str.charCodeAt(pos++);
13 - if (value >= 0xD800 && value <= 0xDBFF && pos < len) {
14 - // high surrogate, and there is a next character
15 - value = str.charCodeAt(pos);
16 - if ((value & 0xFC00) == 0xDC00) pos++; // low surrogate
17 - }
18 - }
19 - return length;
20 -};
1 -'use strict';
2 -
3 -
4 -module.exports = {
5 - copy: copy,
6 - checkDataType: checkDataType,
7 - checkDataTypes: checkDataTypes,
8 - coerceToTypes: coerceToTypes,
9 - toHash: toHash,
10 - getProperty: getProperty,
11 - escapeQuotes: escapeQuotes,
12 - ucs2length: require('./ucs2length'),
13 - varOccurences: varOccurences,
14 - varReplace: varReplace,
15 - cleanUpCode: cleanUpCode,
16 - cleanUpVarErrors: cleanUpVarErrors,
17 - schemaHasRules: schemaHasRules,
18 - schemaHasRulesExcept: schemaHasRulesExcept,
19 - stableStringify: require('json-stable-stringify'),
20 - toQuotedString: toQuotedString,
21 - getPathExpr: getPathExpr,
22 - getPath: getPath,
23 - getData: getData,
24 - unescapeFragment: unescapeFragment,
25 - escapeFragment: escapeFragment,
26 - escapeJsonPointer: escapeJsonPointer
27 -};
28 -
29 -
30 -function copy(o, to) {
31 - to = to || {};
32 - for (var key in o) to[key] = o[key];
33 - return to;
34 -}
35 -
36 -
37 -function checkDataType(dataType, data, negate) {
38 - var EQUAL = negate ? ' !== ' : ' === '
39 - , AND = negate ? ' || ' : ' && '
40 - , OK = negate ? '!' : ''
41 - , NOT = negate ? '' : '!';
42 - switch (dataType) {
43 - case 'null': return data + EQUAL + 'null';
44 - case 'array': return OK + 'Array.isArray(' + data + ')';
45 - case 'object': return '(' + OK + data + AND +
46 - 'typeof ' + data + EQUAL + '"object"' + AND +
47 - NOT + 'Array.isArray(' + data + '))';
48 - case 'integer': return '(typeof ' + data + EQUAL + '"number"' + AND +
49 - NOT + '(' + data + ' % 1)' +
50 - AND + data + EQUAL + data + ')';
51 - default: return 'typeof ' + data + EQUAL + '"' + dataType + '"';
52 - }
53 -}
54 -
55 -
56 -function checkDataTypes(dataTypes, data) {
57 - switch (dataTypes.length) {
58 - case 1: return checkDataType(dataTypes[0], data, true);
59 - default:
60 - var code = '';
61 - var types = toHash(dataTypes);
62 - if (types.array && types.object) {
63 - code = types.null ? '(': '(!' + data + ' || ';
64 - code += 'typeof ' + data + ' !== "object")';
65 - delete types.null;
66 - delete types.array;
67 - delete types.object;
68 - }
69 - if (types.number) delete types.integer;
70 - for (var t in types)
71 - code += (code ? ' && ' : '' ) + checkDataType(t, data, true);
72 -
73 - return code;
74 - }
75 -}
76 -
77 -
78 -var COERCE_TO_TYPES = toHash([ 'string', 'number', 'integer', 'boolean', 'null' ]);
79 -function coerceToTypes(optionCoerceTypes, dataTypes) {
80 - if (Array.isArray(dataTypes)) {
81 - var types = [];
82 - for (var i=0; i<dataTypes.length; i++) {
83 - var t = dataTypes[i];
84 - if (COERCE_TO_TYPES[t]) types[types.length] = t;
85 - else if (optionCoerceTypes === 'array' && t === 'array') types[types.length] = t;
86 - }
87 - if (types.length) return types;
88 - } else if (COERCE_TO_TYPES[dataTypes]) {
89 - return [dataTypes];
90 - } else if (optionCoerceTypes === 'array' && dataTypes === 'array') {
91 - return ['array'];
92 - }
93 -}
94 -
95 -
96 -function toHash(arr) {
97 - var hash = {};
98 - for (var i=0; i<arr.length; i++) hash[arr[i]] = true;
99 - return hash;
100 -}
101 -
102 -
103 -var IDENTIFIER = /^[a-z$_][a-z$_0-9]*$/i;
104 -var SINGLE_QUOTE = /'|\\/g;
105 -function getProperty(key) {
106 - return typeof key == 'number'
107 - ? '[' + key + ']'
108 - : IDENTIFIER.test(key)
109 - ? '.' + key
110 - : "['" + escapeQuotes(key) + "']";
111 -}
112 -
113 -
114 -function escapeQuotes(str) {
115 - return str.replace(SINGLE_QUOTE, '\\$&')
116 - .replace(/\n/g, '\\n')
117 - .replace(/\r/g, '\\r')
118 - .replace(/\f/g, '\\f')
119 - .replace(/\t/g, '\\t');
120 -}
121 -
122 -
123 -function varOccurences(str, dataVar) {
124 - dataVar += '[^0-9]';
125 - var matches = str.match(new RegExp(dataVar, 'g'));
126 - return matches ? matches.length : 0;
127 -}
128 -
129 -
130 -function varReplace(str, dataVar, expr) {
131 - dataVar += '([^0-9])';
132 - expr = expr.replace(/\$/g, '$$$$');
133 - return str.replace(new RegExp(dataVar, 'g'), expr + '$1');
134 -}
135 -
136 -
137 -var EMPTY_ELSE = /else\s*{\s*}/g
138 - , EMPTY_IF_NO_ELSE = /if\s*\([^)]+\)\s*\{\s*\}(?!\s*else)/g
139 - , EMPTY_IF_WITH_ELSE = /if\s*\(([^)]+)\)\s*\{\s*\}\s*else(?!\s*if)/g;
140 -function cleanUpCode(out) {
141 - return out.replace(EMPTY_ELSE, '')
142 - .replace(EMPTY_IF_NO_ELSE, '')
143 - .replace(EMPTY_IF_WITH_ELSE, 'if (!($1))');
144 -}
145 -
146 -
147 -var ERRORS_REGEXP = /[^v\.]errors/g
148 - , REMOVE_ERRORS = /var errors = 0;|var vErrors = null;|validate.errors = vErrors;/g
149 - , REMOVE_ERRORS_ASYNC = /var errors = 0;|var vErrors = null;/g
150 - , RETURN_VALID = 'return errors === 0;'
151 - , RETURN_TRUE = 'validate.errors = null; return true;'
152 - , RETURN_ASYNC = /if \(errors === 0\) return true;\s*else throw new ValidationError\(vErrors\);/
153 - , RETURN_TRUE_ASYNC = 'return true;';
154 -
155 -function cleanUpVarErrors(out, async) {
156 - var matches = out.match(ERRORS_REGEXP);
157 - if (!matches || matches.length !== 2) return out;
158 - return async
159 - ? out.replace(REMOVE_ERRORS_ASYNC, '')
160 - .replace(RETURN_ASYNC, RETURN_TRUE_ASYNC)
161 - : out.replace(REMOVE_ERRORS, '')
162 - .replace(RETURN_VALID, RETURN_TRUE);
163 -}
164 -
165 -
166 -function schemaHasRules(schema, rules) {
167 - for (var key in schema) if (rules[key]) return true;
168 -}
169 -
170 -
171 -function schemaHasRulesExcept(schema, rules, exceptKeyword) {
172 - for (var key in schema) if (key != exceptKeyword && rules[key]) return true;
173 -}
174 -
175 -
176 -function toQuotedString(str) {
177 - return '\'' + escapeQuotes(str) + '\'';
178 -}
179 -
180 -
181 -function getPathExpr(currentPath, expr, jsonPointers, isNumber) {
182 - var path = jsonPointers // false by default
183 - ? '\'/\' + ' + expr + (isNumber ? '' : '.replace(/~/g, \'~0\').replace(/\\//g, \'~1\')')
184 - : (isNumber ? '\'[\' + ' + expr + ' + \']\'' : '\'[\\\'\' + ' + expr + ' + \'\\\']\'');
185 - return joinPaths(currentPath, path);
186 -}
187 -
188 -
189 -function getPath(currentPath, prop, jsonPointers) {
190 - var path = jsonPointers // false by default
191 - ? toQuotedString('/' + escapeJsonPointer(prop))
192 - : toQuotedString(getProperty(prop));
193 - return joinPaths(currentPath, path);
194 -}
195 -
196 -
197 -var JSON_POINTER = /^\/(?:[^~]|~0|~1)*$/;
198 -var RELATIVE_JSON_POINTER = /^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;
199 -function getData($data, lvl, paths) {
200 - var up, jsonPointer, data, matches;
201 - if ($data === '') return 'rootData';
202 - if ($data[0] == '/') {
203 - if (!JSON_POINTER.test($data)) throw new Error('Invalid JSON-pointer: ' + $data);
204 - jsonPointer = $data;
205 - data = 'rootData';
206 - } else {
207 - matches = $data.match(RELATIVE_JSON_POINTER);
208 - if (!matches) throw new Error('Invalid JSON-pointer: ' + $data);
209 - up = +matches[1];
210 - jsonPointer = matches[2];
211 - if (jsonPointer == '#') {
212 - if (up >= lvl) throw new Error('Cannot access property/index ' + up + ' levels up, current level is ' + lvl);
213 - return paths[lvl - up];
214 - }
215 -
216 - if (up > lvl) throw new Error('Cannot access data ' + up + ' levels up, current level is ' + lvl);
217 - data = 'data' + ((lvl - up) || '');
218 - if (!jsonPointer) return data;
219 - }
220 -
221 - var expr = data;
222 - var segments = jsonPointer.split('/');
223 - for (var i=0; i<segments.length; i++) {
224 - var segment = segments[i];
225 - if (segment) {
226 - data += getProperty(unescapeJsonPointer(segment));
227 - expr += ' && ' + data;
228 - }
229 - }
230 - return expr;
231 -}
232 -
233 -
234 -function joinPaths (a, b) {
235 - if (a == '""') return b;
236 - return (a + ' + ' + b).replace(/' \+ '/g, '');
237 -}
238 -
239 -
240 -function unescapeFragment(str) {
241 - return unescapeJsonPointer(decodeURIComponent(str));
242 -}
243 -
244 -
245 -function escapeFragment(str) {
246 - return encodeURIComponent(escapeJsonPointer(str));
247 -}
248 -
249 -
250 -function escapeJsonPointer(str) {
251 - return str.replace(/~/g, '~0').replace(/\//g, '~1');
252 -}
253 -
254 -
255 -function unescapeJsonPointer(str) {
256 - return str.replace(/~1/g, '/').replace(/~0/g, '~');
257 -}
1 -'use strict';
2 -
3 -module.exports = ValidationError;
4 -
5 -
6 -function ValidationError(errors) {
7 - this.message = 'validation failed';
8 - this.errors = errors;
9 - this.ajv = this.validation = true;
10 -}
11 -
12 -
13 -ValidationError.prototype = Object.create(Error.prototype);
14 -ValidationError.prototype.constructor = ValidationError;
1 -{{# def.definitions }}
2 -{{# def.errors }}
3 -{{# def.setupKeyword }}
4 -{{# def.$data }}
5 -
6 -{{
7 - var $isMax = $keyword == 'maximum'
8 - , $exclusiveKeyword = $isMax ? 'exclusiveMaximum' : 'exclusiveMinimum'
9 - , $schemaExcl = it.schema[$exclusiveKeyword]
10 - , $isDataExcl = it.opts.v5 && $schemaExcl && $schemaExcl.$data
11 - , $op = $isMax ? '<' : '>'
12 - , $notOp = $isMax ? '>' : '<';
13 -}}
14 -
15 -{{? $isDataExcl }}
16 - {{
17 - var $schemaValueExcl = it.util.getData($schemaExcl.$data, $dataLvl, it.dataPathArr)
18 - , $exclusive = 'exclusive' + $lvl
19 - , $opExpr = 'op' + $lvl
20 - , $opStr = '\' + ' + $opExpr + ' + \'';
21 - }}
22 - var schemaExcl{{=$lvl}} = {{=$schemaValueExcl}};
23 - {{ $schemaValueExcl = 'schemaExcl' + $lvl; }}
24 -
25 - var exclusive{{=$lvl}};
26 - if (typeof {{=$schemaValueExcl}} != 'boolean' && typeof {{=$schemaValueExcl}} != 'undefined') {
27 - {{ var $errorKeyword = $exclusiveKeyword; }}
28 - {{# def.error:'_exclusiveLimit' }}
29 - } else if({{# def.$dataNotType:'number' }}
30 - ((exclusive{{=$lvl}} = {{=$schemaValueExcl}} === true)
31 - ? {{=$data}} {{=$notOp}}= {{=$schemaValue}}
32 - : {{=$data}} {{=$notOp}} {{=$schemaValue}})
33 - || {{=$data}} !== {{=$data}}) {
34 - var op{{=$lvl}} = exclusive{{=$lvl}} ? '{{=$op}}' : '{{=$op}}=';
35 -{{??}}
36 - {{
37 - var $exclusive = $schemaExcl === true
38 - , $opStr = $op; /*used in error*/
39 - if (!$exclusive) $opStr += '=';
40 - var $opExpr = '\'' + $opStr + '\''; /*used in error*/
41 - }}
42 -
43 - if ({{# def.$dataNotType:'number' }}
44 - {{=$data}} {{=$notOp}}{{?$exclusive}}={{?}} {{=$schemaValue}}
45 - || {{=$data}} !== {{=$data}}) {
46 -{{?}}
47 - {{ var $errorKeyword = $keyword; }}
48 - {{# def.error:'_limit' }}
49 - } {{? $breakOnError }} else { {{?}}
1 -{{# def.definitions }}
2 -{{# def.errors }}
3 -{{# def.setupKeyword }}
4 -{{# def.$data }}
5 -
6 -{{ var $op = $keyword == 'maxItems' ? '>' : '<'; }}
7 -if ({{# def.$dataNotType:'number' }} {{=$data}}.length {{=$op}} {{=$schemaValue}}) {
8 - {{ var $errorKeyword = $keyword; }}
9 - {{# def.error:'_limitItems' }}
10 -} {{? $breakOnError }} else { {{?}}
1 -{{# def.definitions }}
2 -{{# def.errors }}
3 -{{# def.setupKeyword }}
4 -{{# def.$data }}
5 -
6 -{{ var $op = $keyword == 'maxLength' ? '>' : '<'; }}
7 -if ({{# def.$dataNotType:'number' }} {{# def.strLength }} {{=$op}} {{=$schemaValue}}) {
8 - {{ var $errorKeyword = $keyword; }}
9 - {{# def.error:'_limitLength' }}
10 -} {{? $breakOnError }} else { {{?}}
1 -{{# def.definitions }}
2 -{{# def.errors }}
3 -{{# def.setupKeyword }}
4 -{{# def.$data }}
5 -
6 -{{ var $op = $keyword == 'maxProperties' ? '>' : '<'; }}
7 -if ({{# def.$dataNotType:'number' }} Object.keys({{=$data}}).length {{=$op}} {{=$schemaValue}}) {
8 - {{ var $errorKeyword = $keyword; }}
9 - {{# def.error:'_limitProperties' }}
10 -} {{? $breakOnError }} else { {{?}}
1 -{{# def.definitions }}
2 -{{# def.errors }}
3 -{{# def.setupKeyword }}
4 -{{# def.setupNextLevel }}
5 -
6 -{{
7 - var $currentBaseId = $it.baseId
8 - , $allSchemasEmpty = true;
9 -}}
10 -
11 -{{~ $schema:$sch:$i }}
12 - {{? {{# def.nonEmptySchema:$sch }} }}
13 - {{
14 - $allSchemasEmpty = false;
15 - $it.schema = $sch;
16 - $it.schemaPath = $schemaPath + '[' + $i + ']';
17 - $it.errSchemaPath = $errSchemaPath + '/' + $i;
18 - }}
19 -
20 - {{# def.insertSubschemaCode }}
21 -
22 - {{# def.ifResultValid }}
23 - {{?}}
24 -{{~}}
25 -
26 -{{? $breakOnError }}
27 - {{? $allSchemasEmpty }}
28 - if (true) {
29 - {{??}}
30 - {{= $closingBraces.slice(0,-1) }}
31 - {{?}}
32 -{{?}}
33 -
34 -{{# def.cleanUp }}
1 -{{# def.definitions }}
2 -{{# def.errors }}
3 -{{# def.setupKeyword }}
4 -{{# def.setupNextLevel }}
5 -
6 -{{
7 - var $noEmptySchema = $schema.every(function($sch) {
8 - return {{# def.nonEmptySchema:$sch }};
9 - });
10 -}}
11 -{{? $noEmptySchema }}
12 - {{ var $currentBaseId = $it.baseId; }}
13 - var {{=$errs}} = errors;
14 - var {{=$valid}} = false;
15 -
16 - {{# def.setCompositeRule }}
17 -
18 - {{~ $schema:$sch:$i }}
19 - {{
20 - $it.schema = $sch;
21 - $it.schemaPath = $schemaPath + '[' + $i + ']';
22 - $it.errSchemaPath = $errSchemaPath + '/' + $i;
23 - }}
24 -
25 - {{# def.insertSubschemaCode }}
26 -
27 - {{=$valid}} = {{=$valid}} || {{=$nextValid}};
28 -
29 - if (!{{=$valid}}) {
30 - {{ $closingBraces += '}'; }}
31 - {{~}}
32 -
33 - {{# def.resetCompositeRule }}
34 -
35 - {{= $closingBraces }}
36 -
37 - if (!{{=$valid}}) {
38 - {{# def.addError:'anyOf' }}
39 - } else {
40 - {{# def.resetErrors }}
41 - {{? it.opts.allErrors }} } {{?}}
42 -
43 - {{# def.cleanUp }}
44 -{{??}}
45 - {{? $breakOnError }}
46 - if (true) {
47 - {{?}}
48 -{{?}}
1 -{{## def.coerceType:
2 - {{
3 - var $dataType = 'dataType' + $lvl
4 - , $coerced = 'coerced' + $lvl;
5 - }}
6 - var {{=$dataType}} = typeof {{=$data}};
7 - {{? it.opts.coerceTypes == 'array'}}
8 - if ({{=$dataType}} == 'object' && Array.isArray({{=$data}})) {{=$dataType}} = 'array';
9 - {{?}}
10 -
11 - var {{=$coerced}} = undefined;
12 -
13 - {{ var $bracesCoercion = ''; }}
14 - {{~ $coerceToTypes:$type:$i }}
15 - {{? $i }}
16 - if ({{=$coerced}} === undefined) {
17 - {{ $bracesCoercion += '}'; }}
18 - {{?}}
19 -
20 - {{? it.opts.coerceTypes == 'array' && $type != 'array' }}
21 - if ({{=$dataType}} == 'array' && {{=$data}}.length == 1) {
22 - {{=$coerced}} = {{=$data}} = {{=$data}}[0];
23 - {{=$dataType}} = typeof {{=$data}};
24 - /*if ({{=$dataType}} == 'object' && Array.isArray({{=$data}})) {{=$dataType}} = 'array';*/
25 - }
26 - {{?}}
27 -
28 - {{? $type == 'string' }}
29 - if ({{=$dataType}} == 'number' || {{=$dataType}} == 'boolean')
30 - {{=$coerced}} = '' + {{=$data}};
31 - else if ({{=$data}} === null) {{=$coerced}} = '';
32 - {{?? $type == 'number' || $type == 'integer' }}
33 - if ({{=$dataType}} == 'boolean' || {{=$data}} === null
34 - || ({{=$dataType}} == 'string' && {{=$data}} && {{=$data}} == +{{=$data}}
35 - {{? $type == 'integer' }} && !({{=$data}} % 1){{?}}))
36 - {{=$coerced}} = +{{=$data}};
37 - {{?? $type == 'boolean' }}
38 - if ({{=$data}} === 'false' || {{=$data}} === 0 || {{=$data}} === null)
39 - {{=$coerced}} = false;
40 - else if ({{=$data}} === 'true' || {{=$data}} === 1)
41 - {{=$coerced}} = true;
42 - {{?? $type == 'null' }}
43 - if ({{=$data}} === '' || {{=$data}} === 0 || {{=$data}} === false)
44 - {{=$coerced}} = null;
45 - {{?? it.opts.coerceTypes == 'array' && $type == 'array' }}
46 - if ({{=$dataType}} == 'string' || {{=$dataType}} == 'number' || {{=$dataType}} == 'boolean' || {{=$data}} == null)
47 - {{=$coerced}} = [{{=$data}}];
48 - {{?}}
49 - {{~}}
50 -
51 - {{= $bracesCoercion }}
52 -
53 - if ({{=$coerced}} === undefined) {
54 - {{# def.error:'type' }}
55 - } else {
56 - {{# def.setParentData }}
57 - {{=$data}} = {{=$coerced}};
58 - {{? !$dataLvl }}if ({{=$parentData}} !== undefined){{?}}
59 - {{=$parentData}}[{{=$parentDataProperty}}] = {{=$coerced}};
60 - }
61 -#}}
1 -{{# def.definitions }}
2 -{{# def.errors }}
3 -{{# def.setupKeyword }}
4 -{{# def.$data }}
5 -
6 -{{
7 - var $rule = this
8 - , $definition = 'definition' + $lvl
9 - , $rDef = $rule.definition;
10 - var $validate = $rDef.validate;
11 - var $compile, $inline, $macro, $ruleValidate, $validateCode;
12 -}}
13 -
14 -{{? $isData && $rDef.$data }}
15 - {{
16 - $validateCode = 'keywordValidate' + $lvl;
17 - var $validateSchema = $rDef.validateSchema;
18 - }}
19 - var {{=$definition}} = RULES.custom['{{=$keyword}}'].definition;
20 - var {{=$validateCode}} = {{=$definition}}.validate;
21 -{{??}}
22 - {{
23 - $ruleValidate = it.useCustomRule($rule, $schema, it.schema, it);
24 - $schemaValue = 'validate.schema' + $schemaPath;
25 - $validateCode = $ruleValidate.code;
26 - $compile = $rDef.compile;
27 - $inline = $rDef.inline;
28 - $macro = $rDef.macro;
29 - }}
30 -{{?}}
31 -
32 -{{
33 - var $ruleErrs = $validateCode + '.errors'
34 - , $i = 'i' + $lvl
35 - , $ruleErr = 'ruleErr' + $lvl
36 - , $asyncKeyword = $rDef.async;
37 -
38 - if ($asyncKeyword && !it.async)
39 - throw new Error('async keyword in sync schema');
40 -}}
41 -
42 -
43 -{{? !($inline || $macro) }}{{=$ruleErrs}} = null;{{?}}
44 -var {{=$errs}} = errors;
45 -var {{=$valid}};
46 -
47 -{{## def.callRuleValidate:
48 - {{=$validateCode}}.call(
49 - {{? it.opts.passContext }}this{{??}}self{{?}}
50 - {{? $compile || $rDef.schema === false }}
51 - , {{=$data}}
52 - {{??}}
53 - , {{=$schemaValue}}
54 - , {{=$data}}
55 - , validate.schema{{=it.schemaPath}}
56 - {{?}}
57 - , {{# def.dataPath }}
58 - {{# def.passParentData }}
59 - , rootData
60 - )
61 -#}}
62 -
63 -{{## def.extendErrors:_inline:
64 - for (var {{=$i}}={{=$errs}}; {{=$i}}<errors; {{=$i}}++) {
65 - var {{=$ruleErr}} = vErrors[{{=$i}}];
66 - if ({{=$ruleErr}}.dataPath === undefined)
67 - {{=$ruleErr}}.dataPath = (dataPath || '') + {{= it.errorPath }};
68 - {{# _inline ? 'if (\{\{=$ruleErr\}\}.schemaPath === undefined) {' : '' }}
69 - {{=$ruleErr}}.schemaPath = "{{=$errSchemaPath}}";
70 - {{# _inline ? '}' : '' }}
71 - {{? it.opts.verbose }}
72 - {{=$ruleErr}}.schema = {{=$schemaValue}};
73 - {{=$ruleErr}}.data = {{=$data}};
74 - {{?}}
75 - }
76 -#}}
77 -
78 -
79 -{{? $validateSchema }}
80 - {{=$valid}} = {{=$definition}}.validateSchema({{=$schemaValue}});
81 - if ({{=$valid}}) {
82 -{{?}}
83 -
84 -{{? $inline }}
85 - {{? $rDef.statements }}
86 - {{= $ruleValidate.validate }}
87 - {{??}}
88 - {{=$valid}} = {{= $ruleValidate.validate }};
89 - {{?}}
90 -{{?? $macro }}
91 - {{# def.setupNextLevel }}
92 - {{
93 - $it.schema = $ruleValidate.validate;
94 - $it.schemaPath = '';
95 - }}
96 - {{# def.setCompositeRule }}
97 - {{ var $code = it.validate($it).replace(/validate\.schema/g, $validateCode); }}
98 - {{# def.resetCompositeRule }}
99 - {{= $code }}
100 -{{??}}
101 - {{# def.beginDefOut}}
102 - {{# def.callRuleValidate }}
103 - {{# def.storeDefOut:def_callRuleValidate }}
104 -
105 - {{? $rDef.errors === false }}
106 - {{=$valid}} = {{? $asyncKeyword }}{{=it.yieldAwait}}{{?}}{{= def_callRuleValidate }};
107 - {{??}}
108 - {{? $asyncKeyword }}
109 - {{ $ruleErrs = 'customErrors' + $lvl; }}
110 - var {{=$ruleErrs}} = null;
111 - try {
112 - {{=$valid}} = {{=it.yieldAwait}}{{= def_callRuleValidate }};
113 - } catch (e) {
114 - {{=$valid}} = false;
115 - if (e instanceof ValidationError) {{=$ruleErrs}} = e.errors;
116 - else throw e;
117 - }
118 - {{??}}
119 - {{=$ruleErrs}} = null;
120 - {{=$valid}} = {{= def_callRuleValidate }};
121 - {{?}}
122 - {{?}}
123 -{{?}}
124 -
125 -{{? $rDef.modifying }}
126 - {{=$data}} = {{=$parentData}}[{{=$parentDataProperty}}];
127 -{{?}}
128 -
129 -{{? $validateSchema }}
130 - }
131 -{{?}}
132 -
133 -{{## def.notValidationResult:
134 - {{? $rDef.valid === undefined }}
135 - !{{? $macro }}{{=$nextValid}}{{??}}{{=$valid}}{{?}}
136 - {{??}}
137 - {{= !$rDef.valid }}
138 - {{?}}
139 -#}}
140 -
141 -{{? $rDef.valid }}
142 - {{? $breakOnError }} if (true) { {{?}}
143 -{{??}}
144 - if ({{# def.notValidationResult }}) {
145 - {{ $errorKeyword = $rule.keyword; }}
146 - {{# def.beginDefOut}}
147 - {{# def.error:'custom' }}
148 - {{# def.storeDefOut:def_customError }}
149 -
150 - {{? $inline }}
151 - {{? $rDef.errors }}
152 - {{? $rDef.errors != 'full' }}
153 - {{# def.extendErrors:true }}
154 - {{?}}
155 - {{??}}
156 - {{? $rDef.errors === false}}
157 - {{= def_customError }}
158 - {{??}}
159 - if ({{=$errs}} == errors) {
160 - {{= def_customError }}
161 - } else {
162 - {{# def.extendErrors:true }}
163 - }
164 - {{?}}
165 - {{?}}
166 - {{?? $macro }}
167 - {{# def.extraError:'custom' }}
168 - {{??}}
169 - {{? $rDef.errors === false}}
170 - {{= def_customError }}
171 - {{??}}
172 - if (Array.isArray({{=$ruleErrs}})) {
173 - if (vErrors === null) vErrors = {{=$ruleErrs}};
174 - else vErrors = vErrors.concat({{=$ruleErrs}});
175 - errors = vErrors.length;
176 - {{# def.extendErrors:false }}
177 - } else {
178 - {{= def_customError }}
179 - }
180 - {{?}}
181 - {{?}}
182 -
183 - } {{? $breakOnError }} else { {{?}}
184 -{{?}}
1 -{{## def.assignDefault:
2 - if ({{=$passData}} === undefined)
3 - {{=$passData}} = {{? it.opts.useDefaults == 'shared' }}
4 - {{= it.useDefault($sch.default) }}
5 - {{??}}
6 - {{= JSON.stringify($sch.default) }}
7 - {{?}};
8 -#}}
9 -
10 -
11 -{{## def.defaultProperties:
12 - {{
13 - var $schema = it.schema.properties
14 - , $schemaKeys = Object.keys($schema); }}
15 - {{~ $schemaKeys:$propertyKey }}
16 - {{ var $sch = $schema[$propertyKey]; }}
17 - {{? $sch.default !== undefined }}
18 - {{ var $passData = $data + it.util.getProperty($propertyKey); }}
19 - {{# def.assignDefault }}
20 - {{?}}
21 - {{~}}
22 -#}}
23 -
24 -
25 -{{## def.defaultItems:
26 - {{~ it.schema.items:$sch:$i }}
27 - {{? $sch.default !== undefined }}
28 - {{ var $passData = $data + '[' + $i + ']'; }}
29 - {{# def.assignDefault }}
30 - {{?}}
31 - {{~}}
32 -#}}
1 -{{## def.setupKeyword:
2 - {{
3 - var $lvl = it.level;
4 - var $dataLvl = it.dataLevel;
5 - var $schema = it.schema[$keyword];
6 - var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
7 - var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
8 - var $breakOnError = !it.opts.allErrors;
9 - var $errorKeyword;
10 -
11 - var $data = 'data' + ($dataLvl || '');
12 - var $valid = 'valid' + $lvl;
13 - var $errs = 'errs__' + $lvl;
14 - }}
15 -#}}
16 -
17 -
18 -{{## def.setCompositeRule:
19 - {{
20 - var $wasComposite = it.compositeRule;
21 - it.compositeRule = $it.compositeRule = true;
22 - }}
23 -#}}
24 -
25 -
26 -{{## def.resetCompositeRule:
27 - {{ it.compositeRule = $it.compositeRule = $wasComposite; }}
28 -#}}
29 -
30 -
31 -{{## def.setupNextLevel:
32 - {{
33 - var $it = it.util.copy(it);
34 - var $closingBraces = '';
35 - $it.level++;
36 - var $nextValid = 'valid' + $it.level;
37 - }}
38 -#}}
39 -
40 -
41 -{{## def.ifValid:
42 - {{? $breakOnError }}
43 - if ({{=$valid}}) {
44 - {{ $closingBraces += '}'; }}
45 - {{?}}
46 -#}}
47 -
48 -
49 -{{## def.ifResultValid:
50 - {{? $breakOnError }}
51 - if ({{=$nextValid}}) {
52 - {{ $closingBraces += '}'; }}
53 - {{?}}
54 -#}}
55 -
56 -
57 -{{## def.elseIfValid:
58 - {{? $breakOnError }}
59 - {{ $closingBraces += '}'; }}
60 - else {
61 - {{?}}
62 -#}}
63 -
64 -
65 -{{## def.nonEmptySchema:_schema:
66 - it.util.schemaHasRules(_schema, it.RULES.all)
67 -#}}
68 -
69 -
70 -{{## def.strLength:
71 - {{? it.opts.unicode === false }}
72 - {{=$data}}.length
73 - {{??}}
74 - ucs2length({{=$data}})
75 - {{?}}
76 -#}}
77 -
78 -
79 -{{## def.willOptimize:
80 - it.util.varOccurences($code, $nextData) < 2
81 -#}}
82 -
83 -
84 -{{## def.generateSubschemaCode:
85 - {{
86 - var $code = it.validate($it);
87 - $it.baseId = $currentBaseId;
88 - }}
89 -#}}
90 -
91 -
92 -{{## def.insertSubschemaCode:
93 - {{= it.validate($it) }}
94 - {{ $it.baseId = $currentBaseId; }}
95 -#}}
96 -
97 -
98 -{{## def._optimizeValidate:
99 - it.util.varReplace($code, $nextData, $passData)
100 -#}}
101 -
102 -
103 -{{## def.optimizeValidate:
104 - {{? {{# def.willOptimize}} }}
105 - {{= {{# def._optimizeValidate }} }}
106 - {{??}}
107 - var {{=$nextData}} = {{=$passData}};
108 - {{= $code }}
109 - {{?}}
110 -#}}
111 -
112 -
113 -{{## def.cleanUp: {{ out = it.util.cleanUpCode(out); }} #}}
114 -
115 -
116 -{{## def.cleanUpVarErrors: {{ out = it.util.cleanUpVarErrors(out, $async); }} #}}
117 -
118 -
119 -{{## def.$data:
120 - {{
121 - var $isData = it.opts.v5 && $schema && $schema.$data
122 - , $schemaValue;
123 - }}
124 - {{? $isData }}
125 - var schema{{=$lvl}} = {{= it.util.getData($schema.$data, $dataLvl, it.dataPathArr) }};
126 - {{ $schemaValue = 'schema' + $lvl; }}
127 - {{??}}
128 - {{ $schemaValue = $schema; }}
129 - {{?}}
130 -#}}
131 -
132 -
133 -{{## def.$dataNotType:_type:
134 - {{?$isData}} ({{=$schemaValue}} !== undefined && typeof {{=$schemaValue}} != _type) || {{?}}
135 -#}}
136 -
137 -
138 -{{## def.check$dataIsArray:
139 - if (schema{{=$lvl}} === undefined) {{=$valid}} = true;
140 - else if (!Array.isArray(schema{{=$lvl}})) {{=$valid}} = false;
141 - else {
142 -#}}
143 -
144 -
145 -{{## def.beginDefOut:
146 - {{
147 - var $$outStack = $$outStack || [];
148 - $$outStack.push(out);
149 - out = '';
150 - }}
151 -#}}
152 -
153 -
154 -{{## def.storeDefOut:_variable:
155 - {{
156 - var _variable = out;
157 - out = $$outStack.pop();
158 - }}
159 -#}}
160 -
161 -
162 -{{## def.dataPath:(dataPath || ''){{? it.errorPath != '""'}} + {{= it.errorPath }}{{?}}#}}
163 -
164 -{{## def.setParentData:
165 - {{
166 - var $parentData = $dataLvl ? 'data' + (($dataLvl-1)||'') : 'parentData'
167 - , $parentDataProperty = $dataLvl ? it.dataPathArr[$dataLvl] : 'parentDataProperty';
168 - }}
169 -#}}
170 -
171 -{{## def.passParentData:
172 - {{# def.setParentData }}
173 - , {{= $parentData }}
174 - , {{= $parentDataProperty }}
175 -#}}
176 -
177 -
178 -{{## def.checkOwnProperty:
179 - {{? $ownProperties }}
180 - if (!Object.prototype.hasOwnProperty.call({{=$data}}, {{=$key}})) continue;
181 - {{?}}
182 -#}}
1 -{{# def.definitions }}
2 -{{# def.errors }}
3 -{{# def.missing }}
4 -{{# def.setupKeyword }}
5 -{{# def.setupNextLevel }}
6 -
7 -
8 -{{
9 - var $schemaDeps = {}
10 - , $propertyDeps = {};
11 -
12 - for ($property in $schema) {
13 - var $sch = $schema[$property];
14 - var $deps = Array.isArray($sch) ? $propertyDeps : $schemaDeps;
15 - $deps[$property] = $sch;
16 - }
17 -}}
18 -
19 -var {{=$errs}} = errors;
20 -
21 -{{ var $currentErrorPath = it.errorPath; }}
22 -
23 -var missing{{=$lvl}};
24 -{{ for (var $property in $propertyDeps) { }}
25 - {{ $deps = $propertyDeps[$property]; }}
26 - if ({{=$data}}{{= it.util.getProperty($property) }} !== undefined
27 - {{? $breakOnError }}
28 - && ({{# def.checkMissingProperty:$deps }})) {
29 - {{# def.errorMissingProperty:'dependencies' }}
30 - {{??}}
31 - ) {
32 - {{~ $deps:$reqProperty }}
33 - {{# def.allErrorsMissingProperty:'dependencies' }}
34 - {{~}}
35 - {{?}}
36 - } {{# def.elseIfValid }}
37 -{{ } }}
38 -
39 -{{
40 - it.errorPath = $currentErrorPath;
41 - var $currentBaseId = $it.baseId;
42 -}}
43 -
44 -
45 -{{ for (var $property in $schemaDeps) { }}
46 - {{ var $sch = $schemaDeps[$property]; }}
47 - {{? {{# def.nonEmptySchema:$sch }} }}
48 - {{=$nextValid}} = true;
49 -
50 - if ({{=$data}}{{= it.util.getProperty($property) }} !== undefined) {
51 - {{
52 - $it.schema = $sch;
53 - $it.schemaPath = $schemaPath + it.util.getProperty($property);
54 - $it.errSchemaPath = $errSchemaPath + '/' + it.util.escapeFragment($property);
55 - }}
56 -
57 - {{# def.insertSubschemaCode }}
58 - }
59 -
60 - {{# def.ifResultValid }}
61 - {{?}}
62 -{{ } }}
63 -
64 -{{? $breakOnError }}
65 - {{= $closingBraces }}
66 - if ({{=$errs}} == errors) {
67 -{{?}}
68 -
69 -{{# def.cleanUp }}
1 -{{# def.definitions }}
2 -{{# def.errors }}
3 -{{# def.setupKeyword }}
4 -{{# def.$data }}
5 -
6 -{{
7 - var $i = 'i' + $lvl
8 - , $vSchema = 'schema' + $lvl;
9 -}}
10 -
11 -{{? !$isData }}
12 - var {{=$vSchema}} = validate.schema{{=$schemaPath}};
13 -{{?}}
14 -var {{=$valid}};
15 -
16 -{{?$isData}}{{# def.check$dataIsArray }}{{?}}
17 -
18 -{{=$valid}} = false;
19 -
20 -for (var {{=$i}}=0; {{=$i}}<{{=$vSchema}}.length; {{=$i}}++)
21 - if (equal({{=$data}}, {{=$vSchema}}[{{=$i}}])) {
22 - {{=$valid}} = true;
23 - break;
24 - }
25 -
26 -{{? $isData }} } {{?}}
27 -
28 -{{# def.checkError:'enum' }}
29 -
30 -{{? $breakOnError }} else { {{?}}
1 -{{# def.definitions }}
2 -
3 -{{## def._error:_rule:
4 - {{ 'istanbul ignore else'; }}
5 - {{? it.createErrors !== false }}
6 - {
7 - keyword: '{{= $errorKeyword || _rule }}'
8 - , dataPath: (dataPath || '') + {{= it.errorPath }}
9 - , schemaPath: {{=it.util.toQuotedString($errSchemaPath)}}
10 - , params: {{# def._errorParams[_rule] }}
11 - {{? it.opts.messages !== false }}
12 - , message: {{# def._errorMessages[_rule] }}
13 - {{?}}
14 - {{? it.opts.verbose }}
15 - , schema: {{# def._errorSchemas[_rule] }}
16 - , parentSchema: validate.schema{{=it.schemaPath}}
17 - , data: {{=$data}}
18 - {{?}}
19 - }
20 - {{??}}
21 - {}
22 - {{?}}
23 -#}}
24 -
25 -
26 -{{## def._addError:_rule:
27 - if (vErrors === null) vErrors = [err];
28 - else vErrors.push(err);
29 - errors++;
30 -#}}
31 -
32 -
33 -{{## def.addError:_rule:
34 - var err = {{# def._error:_rule }};
35 - {{# def._addError:_rule }}
36 -#}}
37 -
38 -
39 -{{## def.error:_rule:
40 - {{# def.beginDefOut}}
41 - {{# def._error:_rule }}
42 - {{# def.storeDefOut:__err }}
43 -
44 - {{? !it.compositeRule && $breakOnError }}
45 - {{ 'istanbul ignore if'; }}
46 - {{? it.async }}
47 - throw new ValidationError([{{=__err}}]);
48 - {{??}}
49 - validate.errors = [{{=__err}}];
50 - return false;
51 - {{?}}
52 - {{??}}
53 - var err = {{=__err}};
54 - {{# def._addError:_rule }}
55 - {{?}}
56 -#}}
57 -
58 -
59 -{{## def.extraError:_rule:
60 - {{# def.addError:_rule}}
61 - {{? !it.compositeRule && $breakOnError }}
62 - {{ 'istanbul ignore if'; }}
63 - {{? it.async }}
64 - throw new ValidationError(vErrors);
65 - {{??}}
66 - validate.errors = vErrors;
67 - return false;
68 - {{?}}
69 - {{?}}
70 -#}}
71 -
72 -
73 -{{## def.checkError:_rule:
74 - if (!{{=$valid}}) {
75 - {{# def.error:_rule }}
76 - }
77 -#}}
78 -
79 -
80 -{{## def.resetErrors:
81 - errors = {{=$errs}};
82 - if (vErrors !== null) {
83 - if ({{=$errs}}) vErrors.length = {{=$errs}};
84 - else vErrors = null;
85 - }
86 -#}}
87 -
88 -
89 -{{## def.concatSchema:{{?$isData}}' + {{=$schemaValue}} + '{{??}}{{=$schema}}{{?}}#}}
90 -{{## def.appendSchema:{{?$isData}}' + {{=$schemaValue}}{{??}}{{=$schema}}'{{?}}#}}
91 -{{## def.concatSchemaEQ:{{?$isData}}' + {{=$schemaValue}} + '{{??}}{{=it.util.escapeQuotes($schema)}}{{?}}#}}
92 -
93 -{{## def._errorMessages = {
94 - $ref: "'can\\\'t resolve reference {{=it.util.escapeQuotes($schema)}}'",
95 - additionalItems: "'should NOT have more than {{=$schema.length}} items'",
96 - additionalProperties: "'should NOT have additional properties'",
97 - anyOf: "'should match some schema in anyOf'",
98 - dependencies: "'should have {{? $deps.length == 1 }}property {{= it.util.escapeQuotes($deps[0]) }}{{??}}properties {{= it.util.escapeQuotes($deps.join(\", \")) }}{{?}} when property {{= it.util.escapeQuotes($property) }} is present'",
99 - 'enum': "'should be equal to one of the allowed values'",
100 - format: "'should match format \"{{#def.concatSchemaEQ}}\"'",
101 - _limit: "'should be {{=$opStr}} {{#def.appendSchema}}",
102 - _exclusiveLimit: "'{{=$exclusiveKeyword}} should be boolean'",
103 - _limitItems: "'should NOT have {{?$keyword=='maxItems'}}more{{??}}less{{?}} than {{#def.concatSchema}} items'",
104 - _limitLength: "'should NOT be {{?$keyword=='maxLength'}}longer{{??}}shorter{{?}} than {{#def.concatSchema}} characters'",
105 - _limitProperties:"'should NOT have {{?$keyword=='maxProperties'}}more{{??}}less{{?}} than {{#def.concatSchema}} properties'",
106 - multipleOf: "'should be multiple of {{#def.appendSchema}}",
107 - not: "'should NOT be valid'",
108 - oneOf: "'should match exactly one schema in oneOf'",
109 - pattern: "'should match pattern \"{{#def.concatSchemaEQ}}\"'",
110 - required: "'{{? it.opts._errorDataPathProperty }}is a required property{{??}}should have required property \\'{{=$missingProperty}}\\'{{?}}'",
111 - type: "'should be {{? $typeIsArray }}{{= $typeSchema.join(\",\") }}{{??}}{{=$typeSchema}}{{?}}'",
112 - uniqueItems: "'should NOT have duplicate items (items ## ' + j + ' and ' + i + ' are identical)'",
113 - custom: "'should pass \"{{=$rule.keyword}}\" keyword validation'",
114 - patternGroups: "'should NOT have {{=$moreOrLess}} than {{=$limit}} properties matching pattern \"{{=it.util.escapeQuotes($pgProperty)}}\"'",
115 - patternRequired: "'should have property matching pattern \\'{{=$missingPattern}}\\''",
116 - switch: "'should pass \"switch\" keyword validation'",
117 - constant: "'should be equal to constant'",
118 - _formatLimit: "'should be {{=$opStr}} \"{{#def.concatSchemaEQ}}\"'",
119 - _formatExclusiveLimit: "'{{=$exclusiveKeyword}} should be boolean'"
120 -} #}}
121 -
122 -
123 -{{## def.schemaRefOrVal: {{?$isData}}validate.schema{{=$schemaPath}}{{??}}{{=$schema}}{{?}} #}}
124 -{{## def.schemaRefOrQS: {{?$isData}}validate.schema{{=$schemaPath}}{{??}}{{=it.util.toQuotedString($schema)}}{{?}} #}}
125 -
126 -{{## def._errorSchemas = {
127 - $ref: "{{=it.util.toQuotedString($schema)}}",
128 - additionalItems: "false",
129 - additionalProperties: "false",
130 - anyOf: "validate.schema{{=$schemaPath}}",
131 - dependencies: "validate.schema{{=$schemaPath}}",
132 - 'enum': "validate.schema{{=$schemaPath}}",
133 - format: "{{#def.schemaRefOrQS}}",
134 - _limit: "{{#def.schemaRefOrVal}}",
135 - _exclusiveLimit: "validate.schema{{=$schemaPath}}",
136 - _limitItems: "{{#def.schemaRefOrVal}}",
137 - _limitLength: "{{#def.schemaRefOrVal}}",
138 - _limitProperties:"{{#def.schemaRefOrVal}}",
139 - multipleOf: "{{#def.schemaRefOrVal}}",
140 - not: "validate.schema{{=$schemaPath}}",
141 - oneOf: "validate.schema{{=$schemaPath}}",
142 - pattern: "{{#def.schemaRefOrQS}}",
143 - required: "validate.schema{{=$schemaPath}}",
144 - type: "validate.schema{{=$schemaPath}}",
145 - uniqueItems: "{{#def.schemaRefOrVal}}",
146 - custom: "validate.schema{{=$schemaPath}}",
147 - patternGroups: "validate.schema{{=$schemaPath}}",
148 - patternRequired: "validate.schema{{=$schemaPath}}",
149 - switch: "validate.schema{{=$schemaPath}}",
150 - constant: "validate.schema{{=$schemaPath}}",
151 - _formatLimit: "{{#def.schemaRefOrQS}}",
152 - _formatExclusiveLimit: "validate.schema{{=$schemaPath}}"
153 -} #}}
154 -
155 -
156 -{{## def.schemaValueQS: {{?$isData}}{{=$schemaValue}}{{??}}{{=it.util.toQuotedString($schema)}}{{?}} #}}
157 -
158 -{{## def._errorParams = {
159 - $ref: "{ ref: '{{=it.util.escapeQuotes($schema)}}' }",
160 - additionalItems: "{ limit: {{=$schema.length}} }",
161 - additionalProperties: "{ additionalProperty: '{{=$additionalProperty}}' }",
162 - anyOf: "{}",
163 - dependencies: "{ property: '{{= it.util.escapeQuotes($property) }}', missingProperty: '{{=$missingProperty}}', depsCount: {{=$deps.length}}, deps: '{{= it.util.escapeQuotes($deps.length==1 ? $deps[0] : $deps.join(\", \")) }}' }",
164 - 'enum': "{ allowedValues: schema{{=$lvl}} }",
165 - format: "{ format: {{#def.schemaValueQS}} }",
166 - _limit: "{ comparison: {{=$opExpr}}, limit: {{=$schemaValue}}, exclusive: {{=$exclusive}} }",
167 - _exclusiveLimit: "{}",
168 - _limitItems: "{ limit: {{=$schemaValue}} }",
169 - _limitLength: "{ limit: {{=$schemaValue}} }",
170 - _limitProperties:"{ limit: {{=$schemaValue}} }",
171 - multipleOf: "{ multipleOf: {{=$schemaValue}} }",
172 - not: "{}",
173 - oneOf: "{}",
174 - pattern: "{ pattern: {{#def.schemaValueQS}} }",
175 - required: "{ missingProperty: '{{=$missingProperty}}' }",
176 - type: "{ type: '{{? $typeIsArray }}{{= $typeSchema.join(\",\") }}{{??}}{{=$typeSchema}}{{?}}' }",
177 - uniqueItems: "{ i: i, j: j }",
178 - custom: "{ keyword: '{{=$rule.keyword}}' }",
179 - patternGroups: "{ reason: '{{=$reason}}', limit: {{=$limit}}, pattern: '{{=it.util.escapeQuotes($pgProperty)}}' }",
180 - patternRequired: "{ missingPattern: '{{=$missingPattern}}' }",
181 - switch: "{ caseIndex: {{=$caseIndex}} }",
182 - constant: "{}",
183 - _formatLimit: "{ comparison: {{=$opExpr}}, limit: {{#def.schemaValueQS}}, exclusive: {{=$exclusive}} }",
184 - _formatExclusiveLimit: "{}"
185 -} #}}
1 -{{# def.definitions }}
2 -{{# def.errors }}
3 -{{# def.setupKeyword }}
4 -
5 -{{## def.skipFormat:
6 - {{? $breakOnError }} if (true) { {{?}}
7 - {{ return out; }}
8 -#}}
9 -
10 -{{? it.opts.format === false }}{{# def.skipFormat }}{{?}}
11 -
12 -
13 -{{# def.$data }}
14 -
15 -
16 -{{## def.$dataCheckFormat:
17 - {{# def.$dataNotType:'string' }}
18 - ({{? $unknownFormats === true || $allowUnknown }}
19 - ({{=$schemaValue}} && !{{=$format}}
20 - {{? $allowUnknown }}
21 - && self._opts.unknownFormats.indexOf({{=$schemaValue}}) == -1
22 - {{?}}) ||
23 - {{?}}
24 - ({{=$format}} && !(typeof {{=$format}} == 'function'
25 - ? {{? it.async}}
26 - (async{{=$lvl}} ? {{=it.yieldAwait}} {{=$format}}({{=$data}}) : {{=$format}}({{=$data}}))
27 - {{??}}
28 - {{=$format}}({{=$data}})
29 - {{?}}
30 - : {{=$format}}.test({{=$data}}))))
31 -#}}
32 -
33 -{{## def.checkFormat:
34 - {{
35 - var $formatRef = 'formats' + it.util.getProperty($schema);
36 - if ($isObject) $formatRef += '.validate';
37 - }}
38 - {{? typeof $format == 'function' }}
39 - {{=$formatRef}}({{=$data}})
40 - {{??}}
41 - {{=$formatRef}}.test({{=$data}})
42 - {{?}}
43 -#}}
44 -
45 -
46 -{{
47 - var $unknownFormats = it.opts.unknownFormats
48 - , $allowUnknown = Array.isArray($unknownFormats);
49 -}}
50 -
51 -{{? $isData }}
52 - {{ var $format = 'format' + $lvl; }}
53 - var {{=$format}} = formats[{{=$schemaValue}}];
54 - var isObject{{=$lvl}} = typeof {{=$format}} == 'object'
55 - && !({{=$format}} instanceof RegExp)
56 - && {{=$format}}.validate;
57 - if (isObject{{=$lvl}}) {
58 - {{? it.async}}
59 - var async{{=$lvl}} = {{=$format}}.async;
60 - {{?}}
61 - {{=$format}} = {{=$format}}.validate;
62 - }
63 - if ({{# def.$dataCheckFormat }}) {
64 -{{??}}
65 - {{ var $format = it.formats[$schema]; }}
66 - {{? !$format }}
67 - {{? $unknownFormats === true || ($allowUnknown && $unknownFormats.indexOf($schema) == -1) }}
68 - {{ throw new Error('unknown format "' + $schema + '" is used in schema at path "' + it.errSchemaPath + '"'); }}
69 - {{??}}
70 - {{
71 - if (!$allowUnknown) {
72 - console.warn('unknown format "' + $schema + '" ignored in schema at path "' + it.errSchemaPath + '"');
73 - if ($unknownFormats !== 'ignore')
74 - console.warn('In the next major version it will throw exception. See option unknownFormats for more information');
75 - }
76 - }}
77 - {{# def.skipFormat }}
78 - {{?}}
79 - {{?}}
80 - {{
81 - var $isObject = typeof $format == 'object'
82 - && !($format instanceof RegExp)
83 - && $format.validate;
84 - if ($isObject) {
85 - var $async = $format.async === true;
86 - $format = $format.validate;
87 - }
88 - }}
89 - {{? $async }}
90 - {{
91 - if (!it.async) throw new Error('async format in sync schema');
92 - var $formatRef = 'formats' + it.util.getProperty($schema) + '.validate';
93 - }}
94 - if (!({{=it.yieldAwait}} {{=$formatRef}}({{=$data}}))) {
95 - {{??}}
96 - if (!{{# def.checkFormat }}) {
97 - {{?}}
98 -{{?}}
99 - {{# def.error:'format' }}
100 - } {{? $breakOnError }} else { {{?}}
1 -{{# def.definitions }}
2 -{{# def.errors }}
3 -{{# def.setupKeyword }}
4 -{{# def.setupNextLevel }}
5 -
6 -
7 -{{## def.validateItems:startFrom:
8 - for (var {{=$idx}} = {{=startFrom}}; {{=$idx}} < {{=$data}}.length; {{=$idx}}++) {
9 - {{
10 - $it.errorPath = it.util.getPathExpr(it.errorPath, $idx, it.opts.jsonPointers, true);
11 - var $passData = $data + '[' + $idx + ']';
12 - $it.dataPathArr[$dataNxt] = $idx;
13 - }}
14 -
15 - {{# def.generateSubschemaCode }}
16 - {{# def.optimizeValidate }}
17 -
18 - {{? $breakOnError }}
19 - if (!{{=$nextValid}}) break;
20 - {{?}}
21 - }
22 -#}}
23 -
24 -{{
25 - var $idx = 'i' + $lvl
26 - , $dataNxt = $it.dataLevel = it.dataLevel + 1
27 - , $nextData = 'data' + $dataNxt
28 - , $currentBaseId = it.baseId;
29 -}}
30 -
31 -var {{=$errs}} = errors;
32 -var {{=$valid}};
33 -
34 -{{? Array.isArray($schema) }}
35 - {{ /* 'items' is an array of schemas */}}
36 - {{ var $additionalItems = it.schema.additionalItems; }}
37 - {{? $additionalItems === false }}
38 - {{=$valid}} = {{=$data}}.length <= {{= $schema.length }};
39 - {{
40 - var $currErrSchemaPath = $errSchemaPath;
41 - $errSchemaPath = it.errSchemaPath + '/additionalItems';
42 - }}
43 - {{# def.checkError:'additionalItems' }}
44 - {{ $errSchemaPath = $currErrSchemaPath; }}
45 - {{# def.elseIfValid}}
46 - {{?}}
47 -
48 - {{~ $schema:$sch:$i }}
49 - {{? {{# def.nonEmptySchema:$sch }} }}
50 - {{=$nextValid}} = true;
51 -
52 - if ({{=$data}}.length > {{=$i}}) {
53 - {{
54 - var $passData = $data + '[' + $i + ']';
55 - $it.schema = $sch;
56 - $it.schemaPath = $schemaPath + '[' + $i + ']';
57 - $it.errSchemaPath = $errSchemaPath + '/' + $i;
58 - $it.errorPath = it.util.getPathExpr(it.errorPath, $i, it.opts.jsonPointers, true);
59 - $it.dataPathArr[$dataNxt] = $i;
60 - }}
61 -
62 - {{# def.generateSubschemaCode }}
63 - {{# def.optimizeValidate }}
64 - }
65 -
66 - {{# def.ifResultValid }}
67 - {{?}}
68 - {{~}}
69 -
70 - {{? typeof $additionalItems == 'object' && {{# def.nonEmptySchema:$additionalItems }} }}
71 - {{
72 - $it.schema = $additionalItems;
73 - $it.schemaPath = it.schemaPath + '.additionalItems';
74 - $it.errSchemaPath = it.errSchemaPath + '/additionalItems';
75 - }}
76 - {{=$nextValid}} = true;
77 -
78 - if ({{=$data}}.length > {{= $schema.length }}) {
79 - {{# def.validateItems: $schema.length }}
80 - }
81 -
82 - {{# def.ifResultValid }}
83 - {{?}}
84 -
85 -{{?? {{# def.nonEmptySchema:$schema }} }}
86 - {{ /* 'items' is a single schema */}}
87 - {{
88 - $it.schema = $schema;
89 - $it.schemaPath = $schemaPath;
90 - $it.errSchemaPath = $errSchemaPath;
91 - }}
92 - {{# def.validateItems: 0 }}
93 - {{# def.ifResultValid }}
94 -{{?}}
95 -
96 -{{? $breakOnError }}
97 - {{= $closingBraces }}
98 - if ({{=$errs}} == errors) {
99 -{{?}}
100 -
101 -{{# def.cleanUp }}
1 -{{## def.checkMissingProperty:_properties:
2 - {{~ _properties:_$property:$i }}
3 - {{?$i}} || {{?}}
4 - {{ var $prop = it.util.getProperty(_$property); }}
5 - ( {{=$data}}{{=$prop}} === undefined && (missing{{=$lvl}} = {{= it.util.toQuotedString(it.opts.jsonPointers ? _$property : $prop) }}) )
6 - {{~}}
7 -#}}
8 -
9 -
10 -{{## def.errorMissingProperty:_error:
11 - {{
12 - var $propertyPath = 'missing' + $lvl
13 - , $missingProperty = '\' + ' + $propertyPath + ' + \'';
14 - if (it.opts._errorDataPathProperty) {
15 - it.errorPath = it.opts.jsonPointers
16 - ? it.util.getPathExpr($currentErrorPath, $propertyPath, true)
17 - : $currentErrorPath + ' + ' + $propertyPath;
18 - }
19 - }}
20 - {{# def.error:_error }}
21 -#}}
22 -
23 -{{## def.allErrorsMissingProperty:_error:
24 - {{
25 - var $prop = it.util.getProperty($reqProperty)
26 - , $missingProperty = it.util.escapeQuotes($reqProperty);
27 - if (it.opts._errorDataPathProperty) {
28 - it.errorPath = it.util.getPath($currentErrorPath, $reqProperty, it.opts.jsonPointers);
29 - }
30 - }}
31 - if ({{=$data}}{{=$prop}} === undefined) {
32 - {{# def.addError:_error }}
33 - }
34 -#}}
1 -{{# def.definitions }}
2 -{{# def.errors }}
3 -{{# def.setupKeyword }}
4 -{{# def.$data }}
5 -
6 -var division{{=$lvl}};
7 -if ({{?$isData}}
8 - {{=$schemaValue}} !== undefined && (
9 - typeof {{=$schemaValue}} != 'number' ||
10 - {{?}}
11 - (division{{=$lvl}} = {{=$data}} / {{=$schemaValue}},
12 - {{? it.opts.multipleOfPrecision }}
13 - Math.abs(Math.round(division{{=$lvl}}) - division{{=$lvl}}) > 1e-{{=it.opts.multipleOfPrecision}}
14 - {{??}}
15 - division{{=$lvl}} !== parseInt(division{{=$lvl}})
16 - {{?}}
17 - )
18 - {{?$isData}} ) {{?}} ) {
19 - {{# def.error:'multipleOf' }}
20 -} {{? $breakOnError }} else { {{?}}
1 -{{# def.definitions }}
2 -{{# def.errors }}
3 -{{# def.setupKeyword }}
4 -{{# def.setupNextLevel }}
5 -
6 -{{? {{# def.nonEmptySchema:$schema }} }}
7 - {{
8 - $it.schema = $schema;
9 - $it.schemaPath = $schemaPath;
10 - $it.errSchemaPath = $errSchemaPath;
11 - }}
12 -
13 - var {{=$errs}} = errors;
14 -
15 - {{# def.setCompositeRule }}
16 -
17 - {{
18 - $it.createErrors = false;
19 - var $allErrorsOption;
20 - if ($it.opts.allErrors) {
21 - $allErrorsOption = $it.opts.allErrors;
22 - $it.opts.allErrors = false;
23 - }
24 - }}
25 - {{= it.validate($it) }}
26 - {{
27 - $it.createErrors = true;
28 - if ($allErrorsOption) $it.opts.allErrors = $allErrorsOption;
29 - }}
30 -
31 - {{# def.resetCompositeRule }}
32 -
33 - if ({{=$nextValid}}) {
34 - {{# def.error:'not' }}
35 - } else {
36 - {{# def.resetErrors }}
37 - {{? it.opts.allErrors }} } {{?}}
38 -{{??}}
39 - {{# def.addError:'not' }}
40 - {{? $breakOnError}}
41 - if (false) {
42 - {{?}}
43 -{{?}}
1 -{{# def.definitions }}
2 -{{# def.errors }}
3 -{{# def.setupKeyword }}
4 -{{# def.setupNextLevel }}
5 -
6 -var {{=$errs}} = errors;
7 -var prevValid{{=$lvl}} = false;
8 -var {{=$valid}} = false;
9 -
10 -{{ var $currentBaseId = $it.baseId; }}
11 -{{# def.setCompositeRule }}
12 -
13 -{{~ $schema:$sch:$i }}
14 - {{? {{# def.nonEmptySchema:$sch }} }}
15 - {{
16 - $it.schema = $sch;
17 - $it.schemaPath = $schemaPath + '[' + $i + ']';
18 - $it.errSchemaPath = $errSchemaPath + '/' + $i;
19 - }}
20 -
21 - {{# def.insertSubschemaCode }}
22 - {{??}}
23 - var {{=$nextValid}} = true;
24 - {{?}}
25 -
26 - {{? $i }}
27 - if ({{=$nextValid}} && prevValid{{=$lvl}})
28 - {{=$valid}} = false;
29 - else {
30 - {{ $closingBraces += '}'; }}
31 - {{?}}
32 -
33 - if ({{=$nextValid}}) {{=$valid}} = prevValid{{=$lvl}} = true;
34 -{{~}}
35 -
36 -{{# def.resetCompositeRule }}
37 -
38 -{{= $closingBraces }}
39 -
40 -if (!{{=$valid}}) {
41 - {{# def.error:'oneOf' }}
42 -} else {
43 - {{# def.resetErrors }}
44 -{{? it.opts.allErrors }} } {{?}}
1 -{{# def.definitions }}
2 -{{# def.errors }}
3 -{{# def.setupKeyword }}
4 -{{# def.$data }}
5 -
6 -{{
7 - var $regexp = $isData
8 - ? '(new RegExp(' + $schemaValue + '))'
9 - : it.usePattern($schema);
10 -}}
11 -
12 -if ({{# def.$dataNotType:'string' }} !{{=$regexp}}.test({{=$data}}) ) {
13 - {{# def.error:'pattern' }}
14 -} {{? $breakOnError }} else { {{?}}
1 -{{# def.definitions }}
2 -{{# def.errors }}
3 -{{# def.setupKeyword }}
4 -{{# def.setupNextLevel }}
5 -
6 -
7 -{{## def.validateAdditional:
8 - {{ /* additionalProperties is schema */
9 - $it.schema = $aProperties;
10 - $it.schemaPath = it.schemaPath + '.additionalProperties';
11 - $it.errSchemaPath = it.errSchemaPath + '/additionalProperties';
12 - $it.errorPath = it.opts._errorDataPathProperty
13 - ? it.errorPath
14 - : it.util.getPathExpr(it.errorPath, $key, it.opts.jsonPointers);
15 - var $passData = $data + '[' + $key + ']';
16 - $it.dataPathArr[$dataNxt] = $key;
17 - }}
18 -
19 - {{# def.generateSubschemaCode }}
20 - {{# def.optimizeValidate }}
21 -#}}
22 -
23 -
24 -{{
25 - var $key = 'key' + $lvl
26 - , $dataNxt = $it.dataLevel = it.dataLevel + 1
27 - , $nextData = 'data' + $dataNxt;
28 -
29 - var $schemaKeys = Object.keys($schema || {})
30 - , $pProperties = it.schema.patternProperties || {}
31 - , $pPropertyKeys = Object.keys($pProperties)
32 - , $aProperties = it.schema.additionalProperties
33 - , $someProperties = $schemaKeys.length || $pPropertyKeys.length
34 - , $noAdditional = $aProperties === false
35 - , $additionalIsSchema = typeof $aProperties == 'object'
36 - && Object.keys($aProperties).length
37 - , $removeAdditional = it.opts.removeAdditional
38 - , $checkAdditional = $noAdditional || $additionalIsSchema || $removeAdditional
39 - , $ownProperties = it.opts.ownProperties
40 - , $currentBaseId = it.baseId;
41 -
42 - var $required = it.schema.required;
43 - if ($required && !(it.opts.v5 && $required.$data) && $required.length < it.opts.loopRequired)
44 - var $requiredHash = it.util.toHash($required);
45 -
46 - if (it.opts.v5) {
47 - var $pgProperties = it.schema.patternGroups || {}
48 - , $pgPropertyKeys = Object.keys($pgProperties);
49 - }
50 -}}
51 -
52 -
53 -var {{=$errs}} = errors;
54 -var {{=$nextValid}} = true;
55 -
56 -{{? $checkAdditional }}
57 - for (var {{=$key}} in {{=$data}}) {
58 - {{# def.checkOwnProperty }}
59 - {{? $someProperties }}
60 - var isAdditional{{=$lvl}} = !(false
61 - {{? $schemaKeys.length }}
62 - {{? $schemaKeys.length > 5 }}
63 - || validate.schema{{=$schemaPath}}[{{=$key}}]
64 - {{??}}
65 - {{~ $schemaKeys:$propertyKey }}
66 - || {{=$key}} == {{= it.util.toQuotedString($propertyKey) }}
67 - {{~}}
68 - {{?}}
69 - {{?}}
70 - {{? $pPropertyKeys.length }}
71 - {{~ $pPropertyKeys:$pProperty:$i }}
72 - || {{= it.usePattern($pProperty) }}.test({{=$key}})
73 - {{~}}
74 - {{?}}
75 - {{? it.opts.v5 && $pgPropertyKeys && $pgPropertyKeys.length }}
76 - {{~ $pgPropertyKeys:$pgProperty:$i }}
77 - || {{= it.usePattern($pgProperty) }}.test({{=$key}})
78 - {{~}}
79 - {{?}}
80 - );
81 -
82 - if (isAdditional{{=$lvl}}) {
83 - {{?}}
84 - {{? $removeAdditional == 'all' }}
85 - delete {{=$data}}[{{=$key}}];
86 - {{??}}
87 - {{
88 - var $currentErrorPath = it.errorPath;
89 - var $additionalProperty = '\' + ' + $key + ' + \'';
90 - if (it.opts._errorDataPathProperty) {
91 - it.errorPath = it.util.getPathExpr(it.errorPath, $key, it.opts.jsonPointers);
92 - }
93 - }}
94 - {{? $noAdditional }}
95 - {{? $removeAdditional }}
96 - delete {{=$data}}[{{=$key}}];
97 - {{??}}
98 - {{=$nextValid}} = false;
99 - {{
100 - var $currErrSchemaPath = $errSchemaPath;
101 - $errSchemaPath = it.errSchemaPath + '/additionalProperties';
102 - }}
103 - {{# def.error:'additionalProperties' }}
104 - {{ $errSchemaPath = $currErrSchemaPath; }}
105 - {{? $breakOnError }} break; {{?}}
106 - {{?}}
107 - {{?? $additionalIsSchema }}
108 - {{? $removeAdditional == 'failing' }}
109 - var {{=$errs}} = errors;
110 - {{# def.setCompositeRule }}
111 -
112 - {{# def.validateAdditional }}
113 -
114 - if (!{{=$nextValid}}) {
115 - errors = {{=$errs}};
116 - if (validate.errors !== null) {
117 - if (errors) validate.errors.length = errors;
118 - else validate.errors = null;
119 - }
120 - delete {{=$data}}[{{=$key}}];
121 - }
122 -
123 - {{# def.resetCompositeRule }}
124 - {{??}}
125 - {{# def.validateAdditional }}
126 - {{? $breakOnError }} if (!{{=$nextValid}}) break; {{?}}
127 - {{?}}
128 - {{?}}
129 - {{ it.errorPath = $currentErrorPath; }}
130 - {{?}}
131 - {{? $someProperties }}
132 - }
133 - {{?}}
134 - }
135 -
136 - {{# def.ifResultValid }}
137 -{{?}}
138 -
139 -{{ var $useDefaults = it.opts.useDefaults && !it.compositeRule; }}
140 -
141 -{{? $schemaKeys.length }}
142 - {{~ $schemaKeys:$propertyKey }}
143 - {{ var $sch = $schema[$propertyKey]; }}
144 -
145 - {{? {{# def.nonEmptySchema:$sch}} }}
146 - {{
147 - var $prop = it.util.getProperty($propertyKey)
148 - , $passData = $data + $prop
149 - , $hasDefault = $useDefaults && $sch.default !== undefined;
150 - $it.schema = $sch;
151 - $it.schemaPath = $schemaPath + $prop;
152 - $it.errSchemaPath = $errSchemaPath + '/' + it.util.escapeFragment($propertyKey);
153 - $it.errorPath = it.util.getPath(it.errorPath, $propertyKey, it.opts.jsonPointers);
154 - $it.dataPathArr[$dataNxt] = it.util.toQuotedString($propertyKey);
155 - }}
156 -
157 - {{# def.generateSubschemaCode }}
158 -
159 - {{? {{# def.willOptimize }} }}
160 - {{
161 - $code = {{# def._optimizeValidate }};
162 - var $useData = $passData;
163 - }}
164 - {{??}}
165 - {{ var $useData = $nextData; }}
166 - var {{=$nextData}} = {{=$passData}};
167 - {{?}}
168 -
169 - {{? $hasDefault }}
170 - {{= $code }}
171 - {{??}}
172 - {{? $requiredHash && $requiredHash[$propertyKey] }}
173 - if ({{=$useData}} === undefined) {
174 - {{=$nextValid}} = false;
175 - {{
176 - var $currentErrorPath = it.errorPath
177 - , $currErrSchemaPath = $errSchemaPath
178 - , $missingProperty = it.util.escapeQuotes($propertyKey);
179 - if (it.opts._errorDataPathProperty) {
180 - it.errorPath = it.util.getPath($currentErrorPath, $propertyKey, it.opts.jsonPointers);
181 - }
182 - $errSchemaPath = it.errSchemaPath + '/required';
183 - }}
184 - {{# def.error:'required' }}
185 - {{ $errSchemaPath = $currErrSchemaPath; }}
186 - {{ it.errorPath = $currentErrorPath; }}
187 - } else {
188 - {{??}}
189 - {{? $breakOnError }}
190 - if ({{=$useData}} === undefined) {
191 - {{=$nextValid}} = true;
192 - } else {
193 - {{??}}
194 - if ({{=$useData}} !== undefined) {
195 - {{?}}
196 - {{?}}
197 -
198 - {{= $code }}
199 - }
200 - {{?}} {{ /* $hasDefault */ }}
201 - {{?}} {{ /* def.nonEmptySchema */ }}
202 -
203 - {{# def.ifResultValid }}
204 - {{~}}
205 -{{?}}
206 -
207 -{{~ $pPropertyKeys:$pProperty }}
208 - {{ var $sch = $pProperties[$pProperty]; }}
209 -
210 - {{? {{# def.nonEmptySchema:$sch}} }}
211 - {{
212 - $it.schema = $sch;
213 - $it.schemaPath = it.schemaPath + '.patternProperties' + it.util.getProperty($pProperty);
214 - $it.errSchemaPath = it.errSchemaPath + '/patternProperties/'
215 - + it.util.escapeFragment($pProperty);
216 - }}
217 -
218 - for (var {{=$key}} in {{=$data}}) {
219 - {{# def.checkOwnProperty }}
220 - if ({{= it.usePattern($pProperty) }}.test({{=$key}})) {
221 - {{
222 - $it.errorPath = it.util.getPathExpr(it.errorPath, $key, it.opts.jsonPointers);
223 - var $passData = $data + '[' + $key + ']';
224 - $it.dataPathArr[$dataNxt] = $key;
225 - }}
226 -
227 - {{# def.generateSubschemaCode }}
228 - {{# def.optimizeValidate }}
229 -
230 - {{? $breakOnError }} if (!{{=$nextValid}}) break; {{?}}
231 - }
232 - {{? $breakOnError }} else {{=$nextValid}} = true; {{?}}
233 - }
234 -
235 - {{# def.ifResultValid }}
236 - {{?}} {{ /* def.nonEmptySchema */ }}
237 -{{~}}
238 -
239 -
240 -{{? it.opts.v5 }}
241 - {{~ $pgPropertyKeys:$pgProperty }}
242 - {{
243 - var $pgSchema = $pgProperties[$pgProperty]
244 - , $sch = $pgSchema.schema;
245 - }}
246 -
247 - {{? {{# def.nonEmptySchema:$sch}} }}
248 - {{
249 - $it.schema = $sch;
250 - $it.schemaPath = it.schemaPath + '.patternGroups' + it.util.getProperty($pgProperty) + '.schema';
251 - $it.errSchemaPath = it.errSchemaPath + '/patternGroups/'
252 - + it.util.escapeFragment($pgProperty)
253 - + '/schema';
254 - }}
255 -
256 - var pgPropCount{{=$lvl}} = 0;
257 -
258 - for (var {{=$key}} in {{=$data}}) {
259 - {{# def.checkOwnProperty }}
260 - if ({{= it.usePattern($pgProperty) }}.test({{=$key}})) {
261 - pgPropCount{{=$lvl}}++;
262 -
263 - {{
264 - $it.errorPath = it.util.getPathExpr(it.errorPath, $key, it.opts.jsonPointers);
265 - var $passData = $data + '[' + $key + ']';
266 - $it.dataPathArr[$dataNxt] = $key;
267 - }}
268 -
269 - {{# def.generateSubschemaCode }}
270 - {{# def.optimizeValidate }}
271 -
272 - {{? $breakOnError }} if (!{{=$nextValid}}) break; {{?}}
273 - }
274 - {{? $breakOnError }} else {{=$nextValid}} = true; {{?}}
275 - }
276 -
277 - {{# def.ifResultValid }}
278 -
279 - {{
280 - var $pgMin = $pgSchema.minimum
281 - , $pgMax = $pgSchema.maximum;
282 - }}
283 - {{? $pgMin !== undefined || $pgMax !== undefined }}
284 - var {{=$valid}} = true;
285 -
286 - {{ var $currErrSchemaPath = $errSchemaPath; }}
287 -
288 - {{? $pgMin !== undefined }}
289 - {{ var $limit = $pgMin, $reason = 'minimum', $moreOrLess = 'less'; }}
290 - {{=$valid}} = pgPropCount{{=$lvl}} >= {{=$pgMin}};
291 - {{ $errSchemaPath = it.errSchemaPath + '/patternGroups/minimum'; }}
292 - {{# def.checkError:'patternGroups' }}
293 - {{? $pgMax !== undefined }}
294 - else
295 - {{?}}
296 - {{?}}
297 -
298 - {{? $pgMax !== undefined }}
299 - {{ var $limit = $pgMax, $reason = 'maximum', $moreOrLess = 'more'; }}
300 - {{=$valid}} = pgPropCount{{=$lvl}} <= {{=$pgMax}};
301 - {{ $errSchemaPath = it.errSchemaPath + '/patternGroups/maximum'; }}
302 - {{# def.checkError:'patternGroups' }}
303 - {{?}}
304 -
305 - {{ $errSchemaPath = $currErrSchemaPath; }}
306 -
307 - {{# def.ifValid }}
308 - {{?}}
309 - {{?}} {{ /* def.nonEmptySchema */ }}
310 - {{~}}
311 -{{?}}
312 -
313 -
314 -{{? $breakOnError }}
315 - {{= $closingBraces }}
316 - if ({{=$errs}} == errors) {
317 -{{?}}
318 -
319 -{{# def.cleanUp }}
1 -{{# def.definitions }}
2 -{{# def.errors }}
3 -{{# def.setupKeyword }}
4 -
5 -{{## def._validateRef:_v:
6 - {{? it.opts.passContext }}
7 - {{=_v}}.call(this,
8 - {{??}}
9 - {{=_v}}(
10 - {{?}}
11 - {{=$data}}, {{# def.dataPath }}{{# def.passParentData }}, rootData)
12 -#}}
13 -
14 -{{ var $async, $refCode; }}
15 -{{? $schema == '#' || $schema == '#/' }}
16 - {{
17 - if (it.isRoot) {
18 - $async = it.async;
19 - $refCode = 'validate';
20 - } else {
21 - $async = it.root.schema.$async === true;
22 - $refCode = 'root.refVal[0]';
23 - }
24 - }}
25 -{{??}}
26 - {{ var $refVal = it.resolveRef(it.baseId, $schema, it.isRoot); }}
27 - {{? $refVal === undefined }}
28 - {{ var $message = 'can\'t resolve reference ' + $schema + ' from id ' + it.baseId; }}
29 - {{? it.opts.missingRefs == 'fail' }}
30 - {{ console.log($message); }}
31 - {{# def.error:'$ref' }}
32 - {{? $breakOnError }} if (false) { {{?}}
33 - {{?? it.opts.missingRefs == 'ignore' }}
34 - {{ console.log($message); }}
35 - {{? $breakOnError }} if (true) { {{?}}
36 - {{??}}
37 - {{
38 - var $error = new Error($message);
39 - $error.missingRef = it.resolve.url(it.baseId, $schema);
40 - $error.missingSchema = it.resolve.normalizeId(it.resolve.fullPath($error.missingRef));
41 - throw $error;
42 - }}
43 - {{?}}
44 - {{?? $refVal.inline }}
45 - {{# def.setupNextLevel }}
46 - {{
47 - $it.schema = $refVal.schema;
48 - $it.schemaPath = '';
49 - $it.errSchemaPath = $schema;
50 - }}
51 - {{ var $code = it.validate($it).replace(/validate\.schema/g, $refVal.code); }}
52 - {{= $code }}
53 - {{? $breakOnError}}
54 - if ({{=$nextValid}}) {
55 - {{?}}
56 - {{??}}
57 - {{
58 - $async = $refVal.$async === true;
59 - $refCode = $refVal.code;
60 - }}
61 - {{?}}
62 -{{?}}
63 -
64 -{{? $refCode }}
65 - {{# def.beginDefOut}}
66 - {{# def._validateRef:$refCode }}
67 - {{# def.storeDefOut:__callValidate }}
68 -
69 - {{? $async }}
70 - {{ if (!it.async) throw new Error('async schema referenced by sync schema'); }}
71 - try { {{? $breakOnError }}var {{=$valid}} ={{?}} {{=it.yieldAwait}} {{=__callValidate}}; }
72 - catch (e) {
73 - if (!(e instanceof ValidationError)) throw e;
74 - if (vErrors === null) vErrors = e.errors;
75 - else vErrors = vErrors.concat(e.errors);
76 - errors = vErrors.length;
77 - }
78 - {{? $breakOnError }} if ({{=$valid}}) { {{?}}
79 - {{??}}
80 - if (!{{=__callValidate}}) {
81 - if (vErrors === null) vErrors = {{=$refCode}}.errors;
82 - else vErrors = vErrors.concat({{=$refCode}}.errors);
83 - errors = vErrors.length;
84 - } {{? $breakOnError }} else { {{?}}
85 - {{?}}
86 -{{?}}
1 -{{# def.definitions }}
2 -{{# def.errors }}
3 -{{# def.missing }}
4 -{{# def.setupKeyword }}
5 -{{# def.$data }}
6 -
7 -{{ var $vSchema = 'schema' + $lvl; }}
8 -
9 -{{## def.setupLoop:
10 - {{? !$isData }}
11 - var {{=$vSchema}} = validate.schema{{=$schemaPath}};
12 - {{?}}
13 -
14 - {{
15 - var $i = 'i' + $lvl
16 - , $propertyPath = 'schema' + $lvl + '[' + $i + ']'
17 - , $missingProperty = '\' + ' + $propertyPath + ' + \'';
18 - if (it.opts._errorDataPathProperty) {
19 - it.errorPath = it.util.getPathExpr($currentErrorPath, $propertyPath, it.opts.jsonPointers);
20 - }
21 - }}
22 -#}}
23 -
24 -
25 -{{? !$isData }}
26 - {{? $schema.length < it.opts.loopRequired &&
27 - it.schema.properties && Object.keys(it.schema.properties).length }}
28 - {{ var $required = []; }}
29 - {{~ $schema:$property }}
30 - {{ var $propertySch = it.schema.properties[$property]; }}
31 - {{? !($propertySch && {{# def.nonEmptySchema:$propertySch}}) }}
32 - {{ $required[$required.length] = $property; }}
33 - {{?}}
34 - {{~}}
35 - {{??}}
36 - {{ var $required = $schema; }}
37 - {{?}}
38 -{{?}}
39 -
40 -
41 -{{? $isData || $required.length }}
42 - {{
43 - var $currentErrorPath = it.errorPath
44 - , $loopRequired = $isData || $required.length >= it.opts.loopRequired;
45 - }}
46 -
47 - {{? $breakOnError }}
48 - var missing{{=$lvl}};
49 - {{? $loopRequired }}
50 - {{# def.setupLoop }}
51 - var {{=$valid}} = true;
52 -
53 - {{?$isData}}{{# def.check$dataIsArray }}{{?}}
54 -
55 - for (var {{=$i}} = 0; {{=$i}} < {{=$vSchema}}.length; {{=$i}}++) {
56 - {{=$valid}} = {{=$data}}[{{=$vSchema}}[{{=$i}}]] !== undefined;
57 - if (!{{=$valid}}) break;
58 - }
59 -
60 - {{? $isData }} } {{?}}
61 -
62 - {{# def.checkError:'required' }}
63 - else {
64 - {{??}}
65 - if ({{# def.checkMissingProperty:$required }}) {
66 - {{# def.errorMissingProperty:'required' }}
67 - } else {
68 - {{?}}
69 - {{??}}
70 - {{? $loopRequired }}
71 - {{# def.setupLoop }}
72 - {{? $isData }}
73 - if ({{=$vSchema}} && !Array.isArray({{=$vSchema}})) {
74 - {{# def.addError:'required' }}
75 - } else if ({{=$vSchema}} !== undefined) {
76 - {{?}}
77 -
78 - for (var {{=$i}} = 0; {{=$i}} < {{=$vSchema}}.length; {{=$i}}++) {
79 - if ({{=$data}}[{{=$vSchema}}[{{=$i}}]] === undefined) {
80 - {{# def.addError:'required' }}
81 - }
82 - }
83 -
84 - {{? $isData }} } {{?}}
85 - {{??}}
86 - {{~ $required:$reqProperty }}
87 - {{# def.allErrorsMissingProperty:'required' }}
88 - {{~}}
89 - {{?}}
90 - {{?}}
91 -
92 - {{ it.errorPath = $currentErrorPath; }}
93 -
94 -{{?? $breakOnError }}
95 - if (true) {
96 -{{?}}
1 -{{# def.definitions }}
2 -{{# def.errors }}
3 -{{# def.setupKeyword }}
4 -{{# def.$data }}
5 -
6 -
7 -{{? ($schema || $isData) && it.opts.uniqueItems !== false }}
8 - {{? $isData }}
9 - var {{=$valid}};
10 - if ({{=$schemaValue}} === false || {{=$schemaValue}} === undefined)
11 - {{=$valid}} = true;
12 - else if (typeof {{=$schemaValue}} != 'boolean')
13 - {{=$valid}} = false;
14 - else {
15 - {{?}}
16 -
17 - var {{=$valid}} = true;
18 - if ({{=$data}}.length > 1) {
19 - var i = {{=$data}}.length, j;
20 - outer:
21 - for (;i--;) {
22 - for (j = i; j--;) {
23 - if (equal({{=$data}}[i], {{=$data}}[j])) {
24 - {{=$valid}} = false;
25 - break outer;
26 - }
27 - }
28 - }
29 - }
30 -
31 - {{? $isData }} } {{?}}
32 -
33 - if (!{{=$valid}}) {
34 - {{# def.error:'uniqueItems' }}
35 - } {{? $breakOnError }} else { {{?}}
36 -{{??}}
37 - {{? $breakOnError }} if (true) { {{?}}
38 -{{?}}
1 -{{# def.definitions }}
2 -{{# def.errors }}
3 -{{# def.setupKeyword }}
4 -
5 -var {{=$valid}} = undefined;
6 -
7 -{{## def.skipFormatLimit:
8 - {{=$valid}} = true;
9 - {{ return out; }}
10 -#}}
11 -
12 -{{## def.compareFormat:
13 - {{? $isData }}
14 - if ({{=$schemaValue}} === undefined) {{=$valid}} = true;
15 - else if (typeof {{=$schemaValue}} != 'string') {{=$valid}} = false;
16 - else {
17 - {{ $closingBraces += '}'; }}
18 - {{?}}
19 -
20 - {{? $isDataFormat }}
21 - if (!{{=$compare}}) {{=$valid}} = true;
22 - else {
23 - {{ $closingBraces += '}'; }}
24 - {{?}}
25 -
26 - var {{=$result}} = {{=$compare}}({{=$data}}, {{# def.schemaValueQS }});
27 -
28 - if ({{=$result}} === undefined) {{=$valid}} = false;
29 -#}}
30 -
31 -
32 -{{? it.opts.format === false }}{{# def.skipFormatLimit }}{{?}}
33 -
34 -{{
35 - var $schemaFormat = it.schema.format
36 - , $isDataFormat = it.opts.v5 && $schemaFormat.$data
37 - , $closingBraces = '';
38 -}}
39 -
40 -{{? $isDataFormat }}
41 - {{
42 - var $schemaValueFormat = it.util.getData($schemaFormat.$data, $dataLvl, it.dataPathArr)
43 - , $format = 'format' + $lvl
44 - , $compare = 'compare' + $lvl;
45 - }}
46 -
47 - var {{=$format}} = formats[{{=$schemaValueFormat}}]
48 - , {{=$compare}} = {{=$format}} && {{=$format}}.compare;
49 -{{??}}
50 - {{ var $format = it.formats[$schemaFormat]; }}
51 - {{? !($format && $format.compare) }}
52 - {{# def.skipFormatLimit }}
53 - {{?}}
54 - {{ var $compare = 'formats' + it.util.getProperty($schemaFormat) + '.compare'; }}
55 -{{?}}
56 -
57 -{{
58 - var $isMax = $keyword == 'formatMaximum'
59 - , $exclusiveKeyword = 'formatExclusive' + ($isMax ? 'Maximum' : 'Minimum')
60 - , $schemaExcl = it.schema[$exclusiveKeyword]
61 - , $isDataExcl = it.opts.v5 && $schemaExcl && $schemaExcl.$data
62 - , $op = $isMax ? '<' : '>'
63 - , $result = 'result' + $lvl;
64 -}}
65 -
66 -{{# def.$data }}
67 -
68 -
69 -{{? $isDataExcl }}
70 - {{
71 - var $schemaValueExcl = it.util.getData($schemaExcl.$data, $dataLvl, it.dataPathArr)
72 - , $exclusive = 'exclusive' + $lvl
73 - , $opExpr = 'op' + $lvl
74 - , $opStr = '\' + ' + $opExpr + ' + \'';
75 - }}
76 - var schemaExcl{{=$lvl}} = {{=$schemaValueExcl}};
77 - {{ $schemaValueExcl = 'schemaExcl' + $lvl; }}
78 -
79 - if (typeof {{=$schemaValueExcl}} != 'boolean' && {{=$schemaValueExcl}} !== undefined) {
80 - {{=$valid}} = false;
81 - {{ var $errorKeyword = $exclusiveKeyword; }}
82 - {{# def.error:'_formatExclusiveLimit' }}
83 - }
84 -
85 - {{# def.elseIfValid }}
86 -
87 - {{# def.compareFormat }}
88 - var {{=$exclusive}} = {{=$schemaValueExcl}} === true;
89 -
90 - if ({{=$valid}} === undefined) {
91 - {{=$valid}} = {{=$exclusive}}
92 - ? {{=$result}} {{=$op}} 0
93 - : {{=$result}} {{=$op}}= 0;
94 - }
95 -
96 - if (!{{=$valid}}) var op{{=$lvl}} = {{=$exclusive}} ? '{{=$op}}' : '{{=$op}}=';
97 -{{??}}
98 - {{
99 - var $exclusive = $schemaExcl === true
100 - , $opStr = $op; /*used in error*/
101 - if (!$exclusive) $opStr += '=';
102 - var $opExpr = '\'' + $opStr + '\''; /*used in error*/
103 - }}
104 -
105 - {{# def.compareFormat }}
106 -
107 - if ({{=$valid}} === undefined)
108 - {{=$valid}} = {{=$result}} {{=$op}}{{?!$exclusive}}={{?}} 0;
109 -{{?}}
110 -
111 -{{= $closingBraces }}
112 -
113 -if (!{{=$valid}}) {
114 - {{ var $errorKeyword = $keyword; }}
115 - {{# def.error:'_formatLimit' }}
116 -}
1 -{{# def.definitions }}
2 -{{# def.errors }}
3 -{{# def.setupKeyword }}
4 -{{# def.$data }}
5 -
6 -{{? !$isData }}
7 - var schema{{=$lvl}} = validate.schema{{=$schemaPath}};
8 -{{?}}
9 -var {{=$valid}} = equal({{=$data}}, schema{{=$lvl}});
10 -{{# def.checkError:'constant' }}
1 -{{# def.definitions }}
2 -{{# def.errors }}
3 -{{# def.setupKeyword }}
4 -
5 -{{
6 - var $key = 'key' + $lvl
7 - , $matched = 'patternMatched' + $lvl
8 - , $closingBraces = ''
9 - , $ownProperties = it.opts.ownProperties;
10 -}}
11 -
12 -var {{=$valid}} = true;
13 -{{~ $schema:$pProperty }}
14 - var {{=$matched}} = false;
15 - for (var {{=$key}} in {{=$data}}) {
16 - {{# def.checkOwnProperty }}
17 - {{=$matched}} = {{= it.usePattern($pProperty) }}.test({{=$key}});
18 - if ({{=$matched}}) break;
19 - }
20 -
21 - {{ var $missingPattern = it.util.escapeQuotes($pProperty); }}
22 - if (!{{=$matched}}) {
23 - {{=$valid}} = false;
24 - {{# def.addError:'patternRequired' }}
25 - } {{# def.elseIfValid }}
26 -{{~}}
27 -
28 -{{= $closingBraces }}
1 -{{# def.definitions }}
2 -{{# def.errors }}
3 -{{# def.setupKeyword }}
4 -{{# def.setupNextLevel }}
5 -
6 -
7 -{{## def.validateIf:
8 - {{# def.setCompositeRule }}
9 - {{ $it.createErrors = false; }}
10 - {{# def._validateSwitchRule:if }}
11 - {{ $it.createErrors = true; }}
12 - {{# def.resetCompositeRule }}
13 - {{=$ifPassed}} = {{=$nextValid}};
14 -#}}
15 -
16 -{{## def.validateThen:
17 - {{? typeof $sch.then == 'boolean' }}
18 - {{? $sch.then === false }}
19 - {{# def.error:'switch' }}
20 - {{?}}
21 - var {{=$nextValid}} = {{= $sch.then }};
22 - {{??}}
23 - {{# def._validateSwitchRule:then }}
24 - {{?}}
25 -#}}
26 -
27 -{{## def._validateSwitchRule:_clause:
28 - {{
29 - $it.schema = $sch._clause;
30 - $it.schemaPath = $schemaPath + '[' + $caseIndex + ']._clause';
31 - $it.errSchemaPath = $errSchemaPath + '/' + $caseIndex + '/_clause';
32 - }}
33 - {{# def.insertSubschemaCode }}
34 -#}}
35 -
36 -{{## def.switchCase:
37 - {{? $sch.if && {{# def.nonEmptySchema:$sch.if }} }}
38 - var {{=$errs}} = errors;
39 - {{# def.validateIf }}
40 - if ({{=$ifPassed}}) {
41 - {{# def.validateThen }}
42 - } else {
43 - {{# def.resetErrors }}
44 - }
45 - {{??}}
46 - {{=$ifPassed}} = true;
47 - {{# def.validateThen }}
48 - {{?}}
49 -#}}
50 -
51 -
52 -{{
53 - var $ifPassed = 'ifPassed' + it.level
54 - , $currentBaseId = $it.baseId
55 - , $shouldContinue;
56 -}}
57 -var {{=$ifPassed}};
58 -
59 -{{~ $schema:$sch:$caseIndex }}
60 - {{? $caseIndex && !$shouldContinue }}
61 - if (!{{=$ifPassed}}) {
62 - {{ $closingBraces+= '}'; }}
63 - {{?}}
64 -
65 - {{# def.switchCase }}
66 - {{ $shouldContinue = $sch.continue }}
67 -{{~}}
68 -
69 -{{= $closingBraces }}
70 -
71 -var {{=$valid}} = {{=$nextValid}};
72 -
73 -{{# def.cleanUp }}
1 -{{# def.definitions }}
2 -{{# def.errors }}
3 -{{# def.defaults }}
4 -{{# def.coerce }}
5 -
6 -{{ /**
7 - * schema compilation (render) time:
8 - * it = { schema, RULES, _validate, opts }
9 - * it.validate - this template function,
10 - * it is used recursively to generate code for subschemas
11 - *
12 - * runtime:
13 - * "validate" is a variable name to which this function will be assigned
14 - * validateRef etc. are defined in the parent scope in index.js
15 - */ }}
16 -
17 -{{ var $async = it.schema.$async === true; }}
18 -
19 -{{? it.isTop}}
20 - {{
21 - var $top = it.isTop
22 - , $lvl = it.level = 0
23 - , $dataLvl = it.dataLevel = 0
24 - , $data = 'data';
25 - it.rootId = it.resolve.fullPath(it.root.schema.id);
26 - it.baseId = it.baseId || it.rootId;
27 - if ($async) {
28 - it.async = true;
29 - var $es7 = it.opts.async == 'es7';
30 - it.yieldAwait = $es7 ? 'await' : 'yield';
31 - }
32 - delete it.isTop;
33 -
34 - it.dataPathArr = [undefined];
35 - }}
36 -
37 - var validate =
38 - {{? $async }}
39 - {{? $es7 }}
40 - (async function
41 - {{??}}
42 - {{? it.opts.async == 'co*'}}co.wrap{{?}}(function*
43 - {{?}}
44 - {{??}}
45 - (function
46 - {{?}}
47 - (data, dataPath, parentData, parentDataProperty, rootData) {
48 - 'use strict';
49 - var vErrors = null; {{ /* don't edit, used in replace */ }}
50 - var errors = 0; {{ /* don't edit, used in replace */ }}
51 - if (rootData === undefined) rootData = data;
52 -{{??}}
53 - {{
54 - var $lvl = it.level
55 - , $dataLvl = it.dataLevel
56 - , $data = 'data' + ($dataLvl || '');
57 -
58 - if (it.schema.id) it.baseId = it.resolve.url(it.baseId, it.schema.id);
59 -
60 - if ($async && !it.async) throw new Error('async schema in sync schema');
61 - }}
62 -
63 - var errs_{{=$lvl}} = errors;
64 -{{?}}
65 -
66 -{{
67 - var $valid = 'valid' + $lvl
68 - , $breakOnError = !it.opts.allErrors
69 - , $closingBraces1 = ''
70 - , $closingBraces2 = '';
71 -
72 - var $errorKeyword;
73 - var $typeSchema = it.schema.type
74 - , $typeIsArray = Array.isArray($typeSchema);
75 -}}
76 -
77 -{{## def.checkType:
78 - {{
79 - var $schemaPath = it.schemaPath + '.type'
80 - , $errSchemaPath = it.errSchemaPath + '/type'
81 - , $method = $typeIsArray ? 'checkDataTypes' : 'checkDataType';
82 - }}
83 -
84 - if ({{= it.util[$method]($typeSchema, $data, true) }}) {
85 -#}}
86 -
87 -{{? $typeSchema && it.opts.coerceTypes }}
88 - {{ var $coerceToTypes = it.util.coerceToTypes(it.opts.coerceTypes, $typeSchema); }}
89 - {{? $coerceToTypes }}
90 - {{# def.checkType }}
91 - {{# def.coerceType }}
92 - }
93 - {{?}}
94 -{{?}}
95 -
96 -{{ var $refKeywords; }}
97 -{{? it.schema.$ref && ($refKeywords = it.util.schemaHasRulesExcept(it.schema, it.RULES.all, '$ref')) }}
98 - {{? it.opts.extendRefs == 'fail' }}
99 - {{ throw new Error('$ref: validation keywords used in schema at path "' + it.errSchemaPath + '"'); }}
100 - {{?? it.opts.extendRefs == 'ignore' }}
101 - {{
102 - $refKeywords = false;
103 - console.log('$ref: keywords ignored in schema at path "' + it.errSchemaPath + '"');
104 - }}
105 - {{?? it.opts.extendRefs !== true }}
106 - {{ console.log('$ref: all keywords used in schema at path "' + it.errSchemaPath + '". It will change in the next major version, see issue #260. Use option { extendRefs: true } to keep current behaviour'); }}
107 - {{?}}
108 -{{?}}
109 -
110 -{{? it.schema.$ref && !$refKeywords }}
111 - {{= it.RULES.all.$ref.code(it, '$ref') }}
112 - {{? $breakOnError }}
113 - }
114 - if (errors === {{?$top}}0{{??}}errs_{{=$lvl}}{{?}}) {
115 - {{ $closingBraces2 += '}'; }}
116 - {{?}}
117 -{{??}}
118 - {{~ it.RULES:$rulesGroup }}
119 - {{? $shouldUseGroup($rulesGroup) }}
120 - {{? $rulesGroup.type }}
121 - if ({{= it.util.checkDataType($rulesGroup.type, $data) }}) {
122 - {{?}}
123 - {{? it.opts.useDefaults && !it.compositeRule }}
124 - {{? $rulesGroup.type == 'object' && it.schema.properties }}
125 - {{# def.defaultProperties }}
126 - {{?? $rulesGroup.type == 'array' && Array.isArray(it.schema.items) }}
127 - {{# def.defaultItems }}
128 - {{?}}
129 - {{?}}
130 - {{~ $rulesGroup.rules:$rule }}
131 - {{? $shouldUseRule($rule) }}
132 - {{= $rule.code(it, $rule.keyword) }}
133 - {{? $breakOnError }}
134 - {{ $closingBraces1 += '}'; }}
135 - {{?}}
136 - {{?}}
137 - {{~}}
138 - {{? $breakOnError }}
139 - {{= $closingBraces1 }}
140 - {{ $closingBraces1 = ''; }}
141 - {{?}}
142 - {{? $rulesGroup.type }}
143 - }
144 - {{? $typeSchema && $typeSchema === $rulesGroup.type && !$coerceToTypes }}
145 - {{ var $typeChecked = true; }}
146 - else {
147 - {{
148 - var $schemaPath = it.schemaPath + '.type'
149 - , $errSchemaPath = it.errSchemaPath + '/type';
150 - }}
151 - {{# def.error:'type' }}
152 - }
153 - {{?}}
154 - {{?}}
155 -
156 - {{? $breakOnError }}
157 - if (errors === {{?$top}}0{{??}}errs_{{=$lvl}}{{?}}) {
158 - {{ $closingBraces2 += '}'; }}
159 - {{?}}
160 - {{?}}
161 - {{~}}
162 -{{?}}
163 -
164 -{{? $typeSchema && !$typeChecked && !$coerceToTypes }}
165 - {{# def.checkType }}
166 - {{# def.error:'type' }}
167 - }
168 -{{?}}
169 -
170 -{{? $breakOnError }} {{= $closingBraces2 }} {{?}}
171 -
172 -{{? $top }}
173 - {{? $async }}
174 - if (errors === 0) return true; {{ /* don't edit, used in replace */ }}
175 - else throw new ValidationError(vErrors); {{ /* don't edit, used in replace */ }}
176 - {{??}}
177 - validate.errors = vErrors; {{ /* don't edit, used in replace */ }}
178 - return errors === 0; {{ /* don't edit, used in replace */ }}
179 - {{?}}
180 - });
181 -
182 - return validate;
183 -{{??}}
184 - var {{=$valid}} = errors === errs_{{=$lvl}};
185 -{{?}}
186 -
187 -{{# def.cleanUp }}
188 -
189 -{{? $top && $breakOnError }}
190 - {{# def.cleanUpVarErrors }}
191 -{{?}}
192 -
193 -{{
194 - function $shouldUseGroup($rulesGroup) {
195 - for (var i=0; i < $rulesGroup.rules.length; i++)
196 - if ($shouldUseRule($rulesGroup.rules[i]))
197 - return true;
198 - }
199 -
200 - function $shouldUseRule($rule) {
201 - return it.schema[$rule.keyword] !== undefined ||
202 - ( $rule.keyword == 'properties' &&
203 - ( it.schema.additionalProperties === false ||
204 - typeof it.schema.additionalProperties == 'object'
205 - || ( it.schema.patternProperties &&
206 - Object.keys(it.schema.patternProperties).length )
207 - || ( it.opts.v5 && it.schema.patternGroups &&
208 - Object.keys(it.schema.patternGroups).length )));
209 - }
210 -}}
1 -These files are compiled dot templates from dot folder.
2 -
3 -Do NOT edit them directly, edit the templates and run `npm run build` from main ajv folder.
1 -'use strict';
2 -module.exports = function generate__formatLimit(it, $keyword) {
3 - var out = ' ';
4 - var $lvl = it.level;
5 - var $dataLvl = it.dataLevel;
6 - var $schema = it.schema[$keyword];
7 - var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
8 - var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
9 - var $breakOnError = !it.opts.allErrors;
10 - var $errorKeyword;
11 - var $data = 'data' + ($dataLvl || '');
12 - var $valid = 'valid' + $lvl;
13 - out += 'var ' + ($valid) + ' = undefined;';
14 - if (it.opts.format === false) {
15 - out += ' ' + ($valid) + ' = true; ';
16 - return out;
17 - }
18 - var $schemaFormat = it.schema.format,
19 - $isDataFormat = it.opts.v5 && $schemaFormat.$data,
20 - $closingBraces = '';
21 - if ($isDataFormat) {
22 - var $schemaValueFormat = it.util.getData($schemaFormat.$data, $dataLvl, it.dataPathArr),
23 - $format = 'format' + $lvl,
24 - $compare = 'compare' + $lvl;
25 - out += ' var ' + ($format) + ' = formats[' + ($schemaValueFormat) + '] , ' + ($compare) + ' = ' + ($format) + ' && ' + ($format) + '.compare;';
26 - } else {
27 - var $format = it.formats[$schemaFormat];
28 - if (!($format && $format.compare)) {
29 - out += ' ' + ($valid) + ' = true; ';
30 - return out;
31 - }
32 - var $compare = 'formats' + it.util.getProperty($schemaFormat) + '.compare';
33 - }
34 - var $isMax = $keyword == 'formatMaximum',
35 - $exclusiveKeyword = 'formatExclusive' + ($isMax ? 'Maximum' : 'Minimum'),
36 - $schemaExcl = it.schema[$exclusiveKeyword],
37 - $isDataExcl = it.opts.v5 && $schemaExcl && $schemaExcl.$data,
38 - $op = $isMax ? '<' : '>',
39 - $result = 'result' + $lvl;
40 - var $isData = it.opts.v5 && $schema && $schema.$data,
41 - $schemaValue;
42 - if ($isData) {
43 - out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; ';
44 - $schemaValue = 'schema' + $lvl;
45 - } else {
46 - $schemaValue = $schema;
47 - }
48 - if ($isDataExcl) {
49 - var $schemaValueExcl = it.util.getData($schemaExcl.$data, $dataLvl, it.dataPathArr),
50 - $exclusive = 'exclusive' + $lvl,
51 - $opExpr = 'op' + $lvl,
52 - $opStr = '\' + ' + $opExpr + ' + \'';
53 - out += ' var schemaExcl' + ($lvl) + ' = ' + ($schemaValueExcl) + '; ';
54 - $schemaValueExcl = 'schemaExcl' + $lvl;
55 - out += ' if (typeof ' + ($schemaValueExcl) + ' != \'boolean\' && ' + ($schemaValueExcl) + ' !== undefined) { ' + ($valid) + ' = false; ';
56 - var $errorKeyword = $exclusiveKeyword;
57 - var $$outStack = $$outStack || [];
58 - $$outStack.push(out);
59 - out = ''; /* istanbul ignore else */
60 - if (it.createErrors !== false) {
61 - out += ' { keyword: \'' + ($errorKeyword || '_formatExclusiveLimit') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: {} ';
62 - if (it.opts.messages !== false) {
63 - out += ' , message: \'' + ($exclusiveKeyword) + ' should be boolean\' ';
64 - }
65 - if (it.opts.verbose) {
66 - out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
67 - }
68 - out += ' } ';
69 - } else {
70 - out += ' {} ';
71 - }
72 - var __err = out;
73 - out = $$outStack.pop();
74 - if (!it.compositeRule && $breakOnError) { /* istanbul ignore if */
75 - if (it.async) {
76 - out += ' throw new ValidationError([' + (__err) + ']); ';
77 - } else {
78 - out += ' validate.errors = [' + (__err) + ']; return false; ';
79 - }
80 - } else {
81 - out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
82 - }
83 - out += ' } ';
84 - if ($breakOnError) {
85 - $closingBraces += '}';
86 - out += ' else { ';
87 - }
88 - if ($isData) {
89 - out += ' if (' + ($schemaValue) + ' === undefined) ' + ($valid) + ' = true; else if (typeof ' + ($schemaValue) + ' != \'string\') ' + ($valid) + ' = false; else { ';
90 - $closingBraces += '}';
91 - }
92 - if ($isDataFormat) {
93 - out += ' if (!' + ($compare) + ') ' + ($valid) + ' = true; else { ';
94 - $closingBraces += '}';
95 - }
96 - out += ' var ' + ($result) + ' = ' + ($compare) + '(' + ($data) + ', ';
97 - if ($isData) {
98 - out += '' + ($schemaValue);
99 - } else {
100 - out += '' + (it.util.toQuotedString($schema));
101 - }
102 - out += ' ); if (' + ($result) + ' === undefined) ' + ($valid) + ' = false; var ' + ($exclusive) + ' = ' + ($schemaValueExcl) + ' === true; if (' + ($valid) + ' === undefined) { ' + ($valid) + ' = ' + ($exclusive) + ' ? ' + ($result) + ' ' + ($op) + ' 0 : ' + ($result) + ' ' + ($op) + '= 0; } if (!' + ($valid) + ') var op' + ($lvl) + ' = ' + ($exclusive) + ' ? \'' + ($op) + '\' : \'' + ($op) + '=\';';
103 - } else {
104 - var $exclusive = $schemaExcl === true,
105 - $opStr = $op;
106 - if (!$exclusive) $opStr += '=';
107 - var $opExpr = '\'' + $opStr + '\'';
108 - if ($isData) {
109 - out += ' if (' + ($schemaValue) + ' === undefined) ' + ($valid) + ' = true; else if (typeof ' + ($schemaValue) + ' != \'string\') ' + ($valid) + ' = false; else { ';
110 - $closingBraces += '}';
111 - }
112 - if ($isDataFormat) {
113 - out += ' if (!' + ($compare) + ') ' + ($valid) + ' = true; else { ';
114 - $closingBraces += '}';
115 - }
116 - out += ' var ' + ($result) + ' = ' + ($compare) + '(' + ($data) + ', ';
117 - if ($isData) {
118 - out += '' + ($schemaValue);
119 - } else {
120 - out += '' + (it.util.toQuotedString($schema));
121 - }
122 - out += ' ); if (' + ($result) + ' === undefined) ' + ($valid) + ' = false; if (' + ($valid) + ' === undefined) ' + ($valid) + ' = ' + ($result) + ' ' + ($op);
123 - if (!$exclusive) {
124 - out += '=';
125 - }
126 - out += ' 0;';
127 - }
128 - out += '' + ($closingBraces) + 'if (!' + ($valid) + ') { ';
129 - var $errorKeyword = $keyword;
130 - var $$outStack = $$outStack || [];
131 - $$outStack.push(out);
132 - out = ''; /* istanbul ignore else */
133 - if (it.createErrors !== false) {
134 - out += ' { keyword: \'' + ($errorKeyword || '_formatLimit') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { comparison: ' + ($opExpr) + ', limit: ';
135 - if ($isData) {
136 - out += '' + ($schemaValue);
137 - } else {
138 - out += '' + (it.util.toQuotedString($schema));
139 - }
140 - out += ' , exclusive: ' + ($exclusive) + ' } ';
141 - if (it.opts.messages !== false) {
142 - out += ' , message: \'should be ' + ($opStr) + ' "';
143 - if ($isData) {
144 - out += '\' + ' + ($schemaValue) + ' + \'';
145 - } else {
146 - out += '' + (it.util.escapeQuotes($schema));
147 - }
148 - out += '"\' ';
149 - }
150 - if (it.opts.verbose) {
151 - out += ' , schema: ';
152 - if ($isData) {
153 - out += 'validate.schema' + ($schemaPath);
154 - } else {
155 - out += '' + (it.util.toQuotedString($schema));
156 - }
157 - out += ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
158 - }
159 - out += ' } ';
160 - } else {
161 - out += ' {} ';
162 - }
163 - var __err = out;
164 - out = $$outStack.pop();
165 - if (!it.compositeRule && $breakOnError) { /* istanbul ignore if */
166 - if (it.async) {
167 - out += ' throw new ValidationError([' + (__err) + ']); ';
168 - } else {
169 - out += ' validate.errors = [' + (__err) + ']; return false; ';
170 - }
171 - } else {
172 - out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
173 - }
174 - out += '}';
175 - return out;
176 -}
1 -'use strict';
2 -module.exports = function generate__limit(it, $keyword) {
3 - var out = ' ';
4 - var $lvl = it.level;
5 - var $dataLvl = it.dataLevel;
6 - var $schema = it.schema[$keyword];
7 - var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
8 - var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
9 - var $breakOnError = !it.opts.allErrors;
10 - var $errorKeyword;
11 - var $data = 'data' + ($dataLvl || '');
12 - var $isData = it.opts.v5 && $schema && $schema.$data,
13 - $schemaValue;
14 - if ($isData) {
15 - out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; ';
16 - $schemaValue = 'schema' + $lvl;
17 - } else {
18 - $schemaValue = $schema;
19 - }
20 - var $isMax = $keyword == 'maximum',
21 - $exclusiveKeyword = $isMax ? 'exclusiveMaximum' : 'exclusiveMinimum',
22 - $schemaExcl = it.schema[$exclusiveKeyword],
23 - $isDataExcl = it.opts.v5 && $schemaExcl && $schemaExcl.$data,
24 - $op = $isMax ? '<' : '>',
25 - $notOp = $isMax ? '>' : '<';
26 - if ($isDataExcl) {
27 - var $schemaValueExcl = it.util.getData($schemaExcl.$data, $dataLvl, it.dataPathArr),
28 - $exclusive = 'exclusive' + $lvl,
29 - $opExpr = 'op' + $lvl,
30 - $opStr = '\' + ' + $opExpr + ' + \'';
31 - out += ' var schemaExcl' + ($lvl) + ' = ' + ($schemaValueExcl) + '; ';
32 - $schemaValueExcl = 'schemaExcl' + $lvl;
33 - out += ' var exclusive' + ($lvl) + '; if (typeof ' + ($schemaValueExcl) + ' != \'boolean\' && typeof ' + ($schemaValueExcl) + ' != \'undefined\') { ';
34 - var $errorKeyword = $exclusiveKeyword;
35 - var $$outStack = $$outStack || [];
36 - $$outStack.push(out);
37 - out = ''; /* istanbul ignore else */
38 - if (it.createErrors !== false) {
39 - out += ' { keyword: \'' + ($errorKeyword || '_exclusiveLimit') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: {} ';
40 - if (it.opts.messages !== false) {
41 - out += ' , message: \'' + ($exclusiveKeyword) + ' should be boolean\' ';
42 - }
43 - if (it.opts.verbose) {
44 - out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
45 - }
46 - out += ' } ';
47 - } else {
48 - out += ' {} ';
49 - }
50 - var __err = out;
51 - out = $$outStack.pop();
52 - if (!it.compositeRule && $breakOnError) { /* istanbul ignore if */
53 - if (it.async) {
54 - out += ' throw new ValidationError([' + (__err) + ']); ';
55 - } else {
56 - out += ' validate.errors = [' + (__err) + ']; return false; ';
57 - }
58 - } else {
59 - out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
60 - }
61 - out += ' } else if( ';
62 - if ($isData) {
63 - out += ' (' + ($schemaValue) + ' !== undefined && typeof ' + ($schemaValue) + ' != \'number\') || ';
64 - }
65 - out += ' ((exclusive' + ($lvl) + ' = ' + ($schemaValueExcl) + ' === true) ? ' + ($data) + ' ' + ($notOp) + '= ' + ($schemaValue) + ' : ' + ($data) + ' ' + ($notOp) + ' ' + ($schemaValue) + ') || ' + ($data) + ' !== ' + ($data) + ') { var op' + ($lvl) + ' = exclusive' + ($lvl) + ' ? \'' + ($op) + '\' : \'' + ($op) + '=\';';
66 - } else {
67 - var $exclusive = $schemaExcl === true,
68 - $opStr = $op;
69 - if (!$exclusive) $opStr += '=';
70 - var $opExpr = '\'' + $opStr + '\'';
71 - out += ' if ( ';
72 - if ($isData) {
73 - out += ' (' + ($schemaValue) + ' !== undefined && typeof ' + ($schemaValue) + ' != \'number\') || ';
74 - }
75 - out += ' ' + ($data) + ' ' + ($notOp);
76 - if ($exclusive) {
77 - out += '=';
78 - }
79 - out += ' ' + ($schemaValue) + ' || ' + ($data) + ' !== ' + ($data) + ') {';
80 - }
81 - var $errorKeyword = $keyword;
82 - var $$outStack = $$outStack || [];
83 - $$outStack.push(out);
84 - out = ''; /* istanbul ignore else */
85 - if (it.createErrors !== false) {
86 - out += ' { keyword: \'' + ($errorKeyword || '_limit') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { comparison: ' + ($opExpr) + ', limit: ' + ($schemaValue) + ', exclusive: ' + ($exclusive) + ' } ';
87 - if (it.opts.messages !== false) {
88 - out += ' , message: \'should be ' + ($opStr) + ' ';
89 - if ($isData) {
90 - out += '\' + ' + ($schemaValue);
91 - } else {
92 - out += '' + ($schema) + '\'';
93 - }
94 - }
95 - if (it.opts.verbose) {
96 - out += ' , schema: ';
97 - if ($isData) {
98 - out += 'validate.schema' + ($schemaPath);
99 - } else {
100 - out += '' + ($schema);
101 - }
102 - out += ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
103 - }
104 - out += ' } ';
105 - } else {
106 - out += ' {} ';
107 - }
108 - var __err = out;
109 - out = $$outStack.pop();
110 - if (!it.compositeRule && $breakOnError) { /* istanbul ignore if */
111 - if (it.async) {
112 - out += ' throw new ValidationError([' + (__err) + ']); ';
113 - } else {
114 - out += ' validate.errors = [' + (__err) + ']; return false; ';
115 - }
116 - } else {
117 - out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
118 - }
119 - out += ' } ';
120 - if ($breakOnError) {
121 - out += ' else { ';
122 - }
123 - return out;
124 -}
1 -'use strict';
2 -module.exports = function generate__limitItems(it, $keyword) {
3 - var out = ' ';
4 - var $lvl = it.level;
5 - var $dataLvl = it.dataLevel;
6 - var $schema = it.schema[$keyword];
7 - var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
8 - var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
9 - var $breakOnError = !it.opts.allErrors;
10 - var $errorKeyword;
11 - var $data = 'data' + ($dataLvl || '');
12 - var $isData = it.opts.v5 && $schema && $schema.$data,
13 - $schemaValue;
14 - if ($isData) {
15 - out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; ';
16 - $schemaValue = 'schema' + $lvl;
17 - } else {
18 - $schemaValue = $schema;
19 - }
20 - var $op = $keyword == 'maxItems' ? '>' : '<';
21 - out += 'if ( ';
22 - if ($isData) {
23 - out += ' (' + ($schemaValue) + ' !== undefined && typeof ' + ($schemaValue) + ' != \'number\') || ';
24 - }
25 - out += ' ' + ($data) + '.length ' + ($op) + ' ' + ($schemaValue) + ') { ';
26 - var $errorKeyword = $keyword;
27 - var $$outStack = $$outStack || [];
28 - $$outStack.push(out);
29 - out = ''; /* istanbul ignore else */
30 - if (it.createErrors !== false) {
31 - out += ' { keyword: \'' + ($errorKeyword || '_limitItems') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { limit: ' + ($schemaValue) + ' } ';
32 - if (it.opts.messages !== false) {
33 - out += ' , message: \'should NOT have ';
34 - if ($keyword == 'maxItems') {
35 - out += 'more';
36 - } else {
37 - out += 'less';
38 - }
39 - out += ' than ';
40 - if ($isData) {
41 - out += '\' + ' + ($schemaValue) + ' + \'';
42 - } else {
43 - out += '' + ($schema);
44 - }
45 - out += ' items\' ';
46 - }
47 - if (it.opts.verbose) {
48 - out += ' , schema: ';
49 - if ($isData) {
50 - out += 'validate.schema' + ($schemaPath);
51 - } else {
52 - out += '' + ($schema);
53 - }
54 - out += ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
55 - }
56 - out += ' } ';
57 - } else {
58 - out += ' {} ';
59 - }
60 - var __err = out;
61 - out = $$outStack.pop();
62 - if (!it.compositeRule && $breakOnError) { /* istanbul ignore if */
63 - if (it.async) {
64 - out += ' throw new ValidationError([' + (__err) + ']); ';
65 - } else {
66 - out += ' validate.errors = [' + (__err) + ']; return false; ';
67 - }
68 - } else {
69 - out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
70 - }
71 - out += '} ';
72 - if ($breakOnError) {
73 - out += ' else { ';
74 - }
75 - return out;
76 -}
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.