성준영

Remove cached directory

Showing 983 changed files with 0 additions and 4935 deletions
1 -node_modules/
...\ No newline at end of file ...\ No newline at end of file
1 -MIT License
2 -
3 -Copyright (c) 2017 Junyoung, Sung
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.
1 -# klas-file-downloader
2 -Project that download lecture reference files from Klas
3 -
4 -> If your KLAS password include Exclamation mark, You must write your password like `\!`. for example,
5 -
6 -```
7 -klasFileDownloader -i 2012104095 -p \!123123123
8 -```
...\ No newline at end of file ...\ No newline at end of file
1 -/**
2 - * Created by junyoung on 2017. 4. 2..
3 - */
4 -
5 -var request = require('request');
6 -var cheerio = require('cheerio');
7 -var Promise = require('promise');
8 -const readline = require('readline');
9 -var https = require('https');
10 -var querystring = require('querystring');
11 -
12 -var Iconv = require('iconv').Iconv;
13 -var iconv = new Iconv('euc-kr', 'utf-8//translit//ignore');
14 -
15 -
16 -var j = request.jar();
17 -request = request.defaults({jar: j});
18 -
19 -exports.login = function (id, pw) {
20 - return new Promise(function (resolve, reject) {
21 - request({
22 - url: "https://klas.khu.ac.kr/user/loginUser.do",
23 - method: "POST",
24 - form: {USER_ID: id, PASSWORD: pw}
25 - }, function (err, res, body) {
26 -
27 - if (err) {
28 - reject('ERROR');
29 - } else {
30 - resolve(body);
31 - }
32 - })
33 - });
34 -};
35 -
36 -
37 -exports.getLecture = function () {
38 -
39 - return new Promise(function (resolve, reject) {
40 - request({
41 - url: "https://klas.khu.ac.kr/classroom/viewClassroomCourseMoreList.do?courseType=ing",
42 - method: "GET"
43 - }, function (err, res, body) {
44 - if (err) {
45 - reject(err);
46 - } else {
47 - resolve(body);
48 - }
49 - })
50 - })
51 -};
52 -
53 -exports.getLectureLink = function (getLectureBody) {
54 -
55 - return new Promise(function (resolve, reject) {
56 - var $ = cheerio.load(getLectureBody);
57 - var lectureLinks = $('.gomy_class');
58 - var tableTrs = $('#tbl > tbody > tr > td');
59 -
60 - var lectureLinkList = [];
61 -
62 - tableTrs.each(function (i) {
63 - if (i % 7 === 1) {
64 - lectureLinkList.push({lectureName: $(this).text()});
65 - }
66 - });
67 -
68 -
69 - lectureLinks.each(function (i) {
70 - // lectureLinkList[i].link = $(this).attr('href')
71 - lectureLinkList[i].link = 'https://klas.khu.ac.kr' + $(this).attr('href')
72 - });
73 -
74 - resolve(lectureLinkList);
75 -
76 - })
77 -};
78 -
79 -exports.selectLecture = function (lectureLinkList) {
80 -
81 - const rl = readline.createInterface({
82 - input: process.stdin,
83 - output: process.stdout
84 - });
85 - var selectQuestion = '';
86 - selectQuestion += '\n 강의자료를 다운받을 강의를 선택해 주세요 \n';
87 - var count = 0;
88 -
89 - return new Promise(function (resolve, reject) {
90 -
91 - for (var i in lectureLinkList) {
92 - count += 1;
93 - selectQuestion += ' ' + count + '. ' + lectureLinkList[i].lectureName + '\n';
94 - }
95 - selectQuestion += '\n';
96 - selectQuestion += ' 입력 (1 ~ ' + count + ') : ';
97 -
98 -
99 - rl.question(selectQuestion, (answer) => {
100 -
101 - answer = parseInt(answer) - 1;
102 - resolve(lectureLinkList[answer]);
103 -
104 - rl.close();
105 - });
106 - });
107 -
108 -};
109 -
110 -exports.getClassPageBody = function (lectureLink) {
111 -
112 - return new Promise(function (resolve, reject) {
113 -
114 - var url = lectureLink.link;
115 -
116 - var headers = {
117 - 'Cookie': 'COURSE_MENU_NAME=%uAC15%uC758%uC2E4',
118 - 'User-Agent': 'request'
119 - };
120 -
121 - request({
122 - url: url,
123 - mothod: 'GET',
124 - jar: j,
125 - headers: headers
126 - }, function (err, res, body) {
127 - if (err) {
128 - reject(err);
129 - } else {
130 - resolve(body);
131 - }
132 - })
133 - })
134 -};
135 -
136 -exports.findFiles = function (classPageBody) {
137 -
138 - return new Promise(function (resolve, reject) {
139 - var $ = cheerio.load(classPageBody);
140 - var fileDownAnchors = $('.file-downbox-list > ul > li > a');
141 -
142 - fileDownAnchors.each(function (i) {
143 - console.log($(this).attr('href'));
144 - });
145 - })
146 -};
...\ No newline at end of file ...\ No newline at end of file
1 -#!/usr/bin/env node
2 -
3 -var args = require('args');
4 -var functions = require('./functions');
5 -
6 -args
7 - .option('id', 'Your Student ID of KHU, Required')
8 - .option('pw', 'Your Password of KHU, It is never exploited, Required')
9 - .option('lectureBefore', '0 is default, 1 2 .. wil download past lecture reference files')
10 - .option('downloadPath', 'default ~/Downlaod/Klas, will determine download location')
11 -
12 -const flags = args.parse(process.argv);
13 -
14 -if (!flags.id) {
15 - console.log('id is required!');
16 - return;
17 -} else if (!flags.pw) {
18 - console.log('pw is required!');
19 - return;
20 -}
21 -
22 -
23 -functions.login(flags.id, flags.pw)
24 - .then(functions.getLecture)
25 - .then(functions.getLectureLink)
26 - .then(functions.selectLecture)
27 - .then(functions.getClassPageBody)
28 - .then(functions.findFiles)
29 - .then(function(result){
30 - console.log(result);
31 - })
32 - .catch(function (err) {
33 - console.log(err);
34 - });
35 -
36 -
1 -../sshpk/bin/sshpk-conv
...\ No newline at end of file ...\ No newline at end of file
1 -../sshpk/bin/sshpk-sign
...\ No newline at end of file ...\ No newline at end of file
1 -../sshpk/bin/sshpk-verify
...\ No newline at end of file ...\ No newline at end of file
1 -../uuid/bin/uuid
...\ No newline at end of file ...\ No newline at end of file
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 - loadSchema?: (uri: string, cb: (err: Error, schema: Object) => any) => any;
129 - removeAdditional?: boolean | string;
130 - useDefaults?: boolean | string;
131 - coerceTypes?: boolean | string;
132 - async?: boolean | string;
133 - transpile?: string | ((code: string) => string);
134 - meta?: boolean | Object;
135 - validateSchema?: boolean | string;
136 - addUsedSchema?: boolean;
137 - inlineRefs?: boolean | number;
138 - passContext?: boolean;
139 - loopRequired?: number;
140 - multipleOfPrecision?: number;
141 - errorDataPath?: string;
142 - messages?: boolean;
143 - beautify?: boolean | Object;
144 - cache?: Object;
145 - }
146 -
147 - type FormatValidator = string | RegExp | ((data: string) => boolean);
148 -
149 - interface FormatDefinition {
150 - validate: FormatValidator;
151 - compare: (data1: string, data2: string) => number;
152 - async?: boolean;
153 - }
154 -
155 - interface KeywordDefinition {
156 - type?: string | Array<string>;
157 - async?: boolean;
158 - errors?: boolean | string;
159 - // schema: false makes validate not to expect schema (ValidateFunction)
160 - schema?: boolean;
161 - modifying?: boolean;
162 - valid?: boolean;
163 - // one and only one of the following properties should be present
164 - validate?: ValidateFunction | SchemaValidateFunction;
165 - compile?: (schema: Object, parentSchema: Object) => ValidateFunction;
166 - macro?: (schema: Object, parentSchema: Object) => Object;
167 - inline?: (it: Object, keyword: string, schema: Object, parentSchema: Object) => string;
168 - }
169 -
170 - interface SchemaValidateFunction {
171 - (
172 - schema: Object,
173 - data: any,
174 - parentSchema?: Object,
175 - dataPath?: string,
176 - parentData?: Object | Array<any>,
177 - parentDataProperty?: string | number
178 - ): boolean | Thenable<boolean>;
179 - errors?: Array<ErrorObject>;
180 - }
181 -
182 - interface ErrorsTextOptions {
183 - separator?: string;
184 - dataVar?: string;
185 - }
186 -
187 - interface ErrorObject {
188 - keyword: string;
189 - dataPath: string;
190 - schemaPath: string;
191 - params: ErrorParameters;
192 - // Excluded if messages set to false.
193 - message?: string;
194 - // These are added with the `verbose` option.
195 - schema?: Object;
196 - parentSchema?: Object;
197 - data?: any;
198 - }
199 -
200 - type ErrorParameters = RefParams | LimitParams | AdditionalPropertiesParams |
201 - DependenciesParams | FormatParams | ComparisonParams |
202 - MultipleOfParams | PatternParams | RequiredParams |
203 - TypeParams | UniqueItemsParams | CustomParams |
204 - PatternGroupsParams | PatternRequiredParams |
205 - SwitchParams | NoParams | EnumParams;
206 -
207 - interface RefParams {
208 - ref: string;
209 - }
210 -
211 - interface LimitParams {
212 - limit: number;
213 - }
214 -
215 - interface AdditionalPropertiesParams {
216 - additionalProperty: string;
217 - }
218 -
219 - interface DependenciesParams {
220 - property: string;
221 - missingProperty: string;
222 - depsCount: number;
223 - deps: string;
224 - }
225 -
226 - interface FormatParams {
227 - format: string
228 - }
229 -
230 - interface ComparisonParams {
231 - comparison: string;
232 - limit: number | string;
233 - exclusive: boolean;
234 - }
235 -
236 - interface MultipleOfParams {
237 - multipleOf: number;
238 - }
239 -
240 - interface PatternParams {
241 - pattern: string;
242 - }
243 -
244 - interface RequiredParams {
245 - missingProperty: string;
246 - }
247 -
248 - interface TypeParams {
249 - type: string;
250 - }
251 -
252 - interface UniqueItemsParams {
253 - i: number;
254 - j: number;
255 - }
256 -
257 - interface CustomParams {
258 - keyword: string;
259 - }
260 -
261 - interface PatternGroupsParams {
262 - reason: string;
263 - limit: number;
264 - pattern: string;
265 - }
266 -
267 - interface PatternRequiredParams {
268 - missingPattern: string;
269 - }
270 -
271 - interface SwitchParams {
272 - caseIndex: number;
273 - }
274 -
275 - interface NoParams {}
276 -
277 - interface EnumParams {
278 - allowedValues: Array<any>;
279 - }
280 -}
281 -
282 -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 = /^[0-9a-z](?:(?:[-0-9a-z]{0,61})?[0-9a-z])?(\.[0-9a-z](?:(?:[-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 - , $validate = $rDef.validate
11 - , $compile
12 - , $inline
13 - , $macro
14 - , $ruleValidate
15 - , $validateCode;
16 -}}
17 -
18 -{{? $isData && $rDef.$data }}
19 - {{
20 - $validateCode = 'keywordValidate' + $lvl;
21 - var $validateSchema = $rDef.validateSchema;
22 - }}
23 - var {{=$definition}} = RULES.custom['{{=$keyword}}'].definition;
24 - var {{=$validateCode}} = {{=$definition}}.validate;
25 -{{??}}
26 - {{
27 - $ruleValidate = it.useCustomRule($rule, $schema, it.schema, it);
28 - $schemaValue = 'validate.schema' + $schemaPath;
29 - $validateCode = $ruleValidate.code;
30 - $compile = $rDef.compile;
31 - $inline = $rDef.inline;
32 - $macro = $rDef.macro;
33 - }}
34 -{{?}}
35 -
36 -{{
37 - var $ruleErrs = $validateCode + '.errors'
38 - , $i = 'i' + $lvl
39 - , $ruleErr = 'ruleErr' + $lvl
40 - , $asyncKeyword = $rDef.async;
41 -
42 - if ($asyncKeyword && !it.async)
43 - throw new Error('async keyword in sync schema');
44 -}}
45 -
46 -
47 -{{? !($inline || $macro) }}{{=$ruleErrs}} = null;{{?}}
48 -var {{=$errs}} = errors;
49 -var {{=$valid}};
50 -
51 -{{## def.callRuleValidate:
52 - {{=$validateCode}}.call(
53 - {{? it.opts.passContext }}this{{??}}self{{?}}
54 - {{? $compile || $rDef.schema === false }}
55 - , {{=$data}}
56 - {{??}}
57 - , {{=$schemaValue}}
58 - , {{=$data}}
59 - , validate.schema{{=it.schemaPath}}
60 - {{?}}
61 - , {{# def.dataPath }}
62 - {{# def.passParentData }}
63 - , rootData
64 - )
65 -#}}
66 -
67 -{{## def.extendErrors:_inline:
68 - for (var {{=$i}}={{=$errs}}; {{=$i}}<errors; {{=$i}}++) {
69 - var {{=$ruleErr}} = vErrors[{{=$i}}];
70 - if ({{=$ruleErr}}.dataPath === undefined)
71 - {{=$ruleErr}}.dataPath = (dataPath || '') + {{= it.errorPath }};
72 - {{# _inline ? 'if (\{\{=$ruleErr\}\}.schemaPath === undefined) {' : '' }}
73 - {{=$ruleErr}}.schemaPath = "{{=$errSchemaPath}}";
74 - {{# _inline ? '}' : '' }}
75 - {{? it.opts.verbose }}
76 - {{=$ruleErr}}.schema = {{=$schemaValue}};
77 - {{=$ruleErr}}.data = {{=$data}};
78 - {{?}}
79 - }
80 -#}}
81 -
82 -
83 -{{? $validateSchema }}
84 - {{=$valid}} = {{=$definition}}.validateSchema({{=$schemaValue}});
85 - if ({{=$valid}}) {
86 -{{?}}
87 -
88 -{{? $inline }}
89 - {{? $rDef.statements }}
90 - {{= $ruleValidate.validate }}
91 - {{??}}
92 - {{=$valid}} = {{= $ruleValidate.validate }};
93 - {{?}}
94 -{{?? $macro }}
95 - {{# def.setupNextLevel }}
96 - {{
97 - $it.schema = $ruleValidate.validate;
98 - $it.schemaPath = '';
99 - }}
100 - {{# def.setCompositeRule }}
101 - {{ var $code = it.validate($it).replace(/validate\.schema/g, $validateCode); }}
102 - {{# def.resetCompositeRule }}
103 - {{= $code }}
104 -{{??}}
105 - {{# def.beginDefOut}}
106 - {{# def.callRuleValidate }}
107 - {{# def.storeDefOut:def_callRuleValidate }}
108 -
109 - {{? $rDef.errors === false }}
110 - {{=$valid}} = {{? $asyncKeyword }}{{=it.yieldAwait}}{{?}}{{= def_callRuleValidate }};
111 - {{??}}
112 - {{? $asyncKeyword }}
113 - {{ $ruleErrs = 'customErrors' + $lvl; }}
114 - var {{=$ruleErrs}} = null;
115 - try {
116 - {{=$valid}} = {{=it.yieldAwait}}{{= def_callRuleValidate }};
117 - } catch (e) {
118 - {{=$valid}} = false;
119 - if (e instanceof ValidationError) {{=$ruleErrs}} = e.errors;
120 - else throw e;
121 - }
122 - {{??}}
123 - {{=$ruleErrs}} = null;
124 - {{=$valid}} = {{= def_callRuleValidate }};
125 - {{?}}
126 - {{?}}
127 -{{?}}
128 -
129 -{{? $rDef.modifying }}
130 - {{=$data}} = {{=$parentData}}[{{=$parentDataProperty}}];
131 -{{?}}
132 -
133 -{{? $validateSchema }}
134 - }
135 -{{?}}
136 -
137 -{{## def.notValidationResult:
138 - {{? $rDef.valid === undefined }}
139 - !{{? $macro }}{{=$nextValid}}{{??}}{{=$valid}}{{?}}
140 - {{??}}
141 - {{= !$rDef.valid }}
142 - {{?}}
143 -#}}
144 -
145 -{{? $rDef.valid }}
146 - {{? $breakOnError }} if (true) { {{?}}
147 -{{??}}
148 - if ({{# def.notValidationResult }}) {
149 - {{ $errorKeyword = $rule.keyword; }}
150 - {{# def.beginDefOut}}
151 - {{# def.error:'custom' }}
152 - {{# def.storeDefOut:def_customError }}
153 -
154 - {{? $inline }}
155 - {{? $rDef.errors }}
156 - {{? $rDef.errors != 'full' }}
157 - {{# def.extendErrors:true }}
158 - {{?}}
159 - {{??}}
160 - {{? $rDef.errors === false}}
161 - {{= def_customError }}
162 - {{??}}
163 - if ({{=$errs}} == errors) {
164 - {{= def_customError }}
165 - } else {
166 - {{# def.extendErrors:true }}
167 - }
168 - {{?}}
169 - {{?}}
170 - {{?? $macro }}
171 - {{# def.extraError:'custom' }}
172 - {{??}}
173 - {{? $rDef.errors === false}}
174 - {{= def_customError }}
175 - {{??}}
176 - if (Array.isArray({{=$ruleErrs}})) {
177 - if (vErrors === null) vErrors = {{=$ruleErrs}};
178 - else vErrors = vErrors.concat({{=$ruleErrs}});
179 - errors = vErrors.length;
180 - {{# def.extendErrors:false }}
181 - } else {
182 - {{= def_customError }}
183 - }
184 - {{?}}
185 - {{?}}
186 -
187 - } {{? $breakOnError }} else { {{?}}
188 -{{?}}
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 - , $errorKeyword;
72 -
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 }}
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 && !(it.opts.coerceTypes && $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 -}
1 -'use strict';
2 -module.exports = function generate__limitLength(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 == 'maxLength' ? '>' : '<';
21 - out += 'if ( ';
22 - if ($isData) {
23 - out += ' (' + ($schemaValue) + ' !== undefined && typeof ' + ($schemaValue) + ' != \'number\') || ';
24 - }
25 - if (it.opts.unicode === false) {
26 - out += ' ' + ($data) + '.length ';
27 - } else {
28 - out += ' ucs2length(' + ($data) + ') ';
29 - }
30 - out += ' ' + ($op) + ' ' + ($schemaValue) + ') { ';
31 - var $errorKeyword = $keyword;
32 - var $$outStack = $$outStack || [];
33 - $$outStack.push(out);
34 - out = ''; /* istanbul ignore else */
35 - if (it.createErrors !== false) {
36 - out += ' { keyword: \'' + ($errorKeyword || '_limitLength') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { limit: ' + ($schemaValue) + ' } ';
37 - if (it.opts.messages !== false) {
38 - out += ' , message: \'should NOT be ';
39 - if ($keyword == 'maxLength') {
40 - out += 'longer';
41 - } else {
42 - out += 'shorter';
43 - }
44 - out += ' than ';
45 - if ($isData) {
46 - out += '\' + ' + ($schemaValue) + ' + \'';
47 - } else {
48 - out += '' + ($schema);
49 - }
50 - out += ' characters\' ';
51 - }
52 - if (it.opts.verbose) {
53 - out += ' , schema: ';
54 - if ($isData) {
55 - out += 'validate.schema' + ($schemaPath);
56 - } else {
57 - out += '' + ($schema);
58 - }
59 - out += ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
60 - }
61 - out += ' } ';
62 - } else {
63 - out += ' {} ';
64 - }
65 - var __err = out;
66 - out = $$outStack.pop();
67 - if (!it.compositeRule && $breakOnError) { /* istanbul ignore if */
68 - if (it.async) {
69 - out += ' throw new ValidationError([' + (__err) + ']); ';
70 - } else {
71 - out += ' validate.errors = [' + (__err) + ']; return false; ';
72 - }
73 - } else {
74 - out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
75 - }
76 - out += '} ';
77 - if ($breakOnError) {
78 - out += ' else { ';
79 - }
80 - return out;
81 -}
1 -'use strict';
2 -module.exports = function generate__limitProperties(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 == 'maxProperties' ? '>' : '<';
21 - out += 'if ( ';
22 - if ($isData) {
23 - out += ' (' + ($schemaValue) + ' !== undefined && typeof ' + ($schemaValue) + ' != \'number\') || ';
24 - }
25 - out += ' Object.keys(' + ($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 || '_limitProperties') + '\' , 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 == 'maxProperties') {
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 += ' properties\' ';
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 -}
1 -'use strict';
2 -module.exports = function generate_allOf(it, $keyword) {
3 - var out = ' ';
4 - var $schema = it.schema[$keyword];
5 - var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
6 - var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
7 - var $breakOnError = !it.opts.allErrors;
8 - var $it = it.util.copy(it);
9 - var $closingBraces = '';
10 - $it.level++;
11 - var $nextValid = 'valid' + $it.level;
12 - var $currentBaseId = $it.baseId,
13 - $allSchemasEmpty = true;
14 - var arr1 = $schema;
15 - if (arr1) {
16 - var $sch, $i = -1,
17 - l1 = arr1.length - 1;
18 - while ($i < l1) {
19 - $sch = arr1[$i += 1];
20 - if (it.util.schemaHasRules($sch, it.RULES.all)) {
21 - $allSchemasEmpty = false;
22 - $it.schema = $sch;
23 - $it.schemaPath = $schemaPath + '[' + $i + ']';
24 - $it.errSchemaPath = $errSchemaPath + '/' + $i;
25 - out += ' ' + (it.validate($it)) + ' ';
26 - $it.baseId = $currentBaseId;
27 - if ($breakOnError) {
28 - out += ' if (' + ($nextValid) + ') { ';
29 - $closingBraces += '}';
30 - }
31 - }
32 - }
33 - }
34 - if ($breakOnError) {
35 - if ($allSchemasEmpty) {
36 - out += ' if (true) { ';
37 - } else {
38 - out += ' ' + ($closingBraces.slice(0, -1)) + ' ';
39 - }
40 - }
41 - out = it.util.cleanUpCode(out);
42 - return out;
43 -}
1 -'use strict';
2 -module.exports = function generate_anyOf(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 - var $errs = 'errs__' + $lvl;
14 - var $it = it.util.copy(it);
15 - var $closingBraces = '';
16 - $it.level++;
17 - var $nextValid = 'valid' + $it.level;
18 - var $noEmptySchema = $schema.every(function($sch) {
19 - return it.util.schemaHasRules($sch, it.RULES.all);
20 - });
21 - if ($noEmptySchema) {
22 - var $currentBaseId = $it.baseId;
23 - out += ' var ' + ($errs) + ' = errors; var ' + ($valid) + ' = false; ';
24 - var $wasComposite = it.compositeRule;
25 - it.compositeRule = $it.compositeRule = true;
26 - var arr1 = $schema;
27 - if (arr1) {
28 - var $sch, $i = -1,
29 - l1 = arr1.length - 1;
30 - while ($i < l1) {
31 - $sch = arr1[$i += 1];
32 - $it.schema = $sch;
33 - $it.schemaPath = $schemaPath + '[' + $i + ']';
34 - $it.errSchemaPath = $errSchemaPath + '/' + $i;
35 - out += ' ' + (it.validate($it)) + ' ';
36 - $it.baseId = $currentBaseId;
37 - out += ' ' + ($valid) + ' = ' + ($valid) + ' || ' + ($nextValid) + '; if (!' + ($valid) + ') { ';
38 - $closingBraces += '}';
39 - }
40 - }
41 - it.compositeRule = $it.compositeRule = $wasComposite;
42 - out += ' ' + ($closingBraces) + ' if (!' + ($valid) + ') { var err = '; /* istanbul ignore else */
43 - if (it.createErrors !== false) {
44 - out += ' { keyword: \'' + ($errorKeyword || 'anyOf') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: {} ';
45 - if (it.opts.messages !== false) {
46 - out += ' , message: \'should match some schema in anyOf\' ';
47 - }
48 - if (it.opts.verbose) {
49 - out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
50 - }
51 - out += ' } ';
52 - } else {
53 - out += ' {} ';
54 - }
55 - out += '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } else { errors = ' + ($errs) + '; if (vErrors !== null) { if (' + ($errs) + ') vErrors.length = ' + ($errs) + '; else vErrors = null; } ';
56 - if (it.opts.allErrors) {
57 - out += ' } ';
58 - }
59 - out = it.util.cleanUpCode(out);
60 - } else {
61 - if ($breakOnError) {
62 - out += ' if (true) { ';
63 - }
64 - }
65 - return out;
66 -}
1 -'use strict';
2 -module.exports = function generate_constant(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 - var $isData = it.opts.v5 && $schema && $schema.$data,
14 - $schemaValue;
15 - if ($isData) {
16 - out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; ';
17 - $schemaValue = 'schema' + $lvl;
18 - } else {
19 - $schemaValue = $schema;
20 - }
21 - if (!$isData) {
22 - out += ' var schema' + ($lvl) + ' = validate.schema' + ($schemaPath) + ';';
23 - }
24 - out += 'var ' + ($valid) + ' = equal(' + ($data) + ', schema' + ($lvl) + '); if (!' + ($valid) + ') { ';
25 - var $$outStack = $$outStack || [];
26 - $$outStack.push(out);
27 - out = ''; /* istanbul ignore else */
28 - if (it.createErrors !== false) {
29 - out += ' { keyword: \'' + ($errorKeyword || 'constant') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: {} ';
30 - if (it.opts.messages !== false) {
31 - out += ' , message: \'should be equal to constant\' ';
32 - }
33 - if (it.opts.verbose) {
34 - out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
35 - }
36 - out += ' } ';
37 - } else {
38 - out += ' {} ';
39 - }
40 - var __err = out;
41 - out = $$outStack.pop();
42 - if (!it.compositeRule && $breakOnError) { /* istanbul ignore if */
43 - if (it.async) {
44 - out += ' throw new ValidationError([' + (__err) + ']); ';
45 - } else {
46 - out += ' validate.errors = [' + (__err) + ']; return false; ';
47 - }
48 - } else {
49 - out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
50 - }
51 - out += ' }';
52 - return out;
53 -}
1 -'use strict';
2 -module.exports = function generate_custom(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 - var $errs = 'errs__' + $lvl;
14 - var $isData = it.opts.v5 && $schema && $schema.$data,
15 - $schemaValue;
16 - if ($isData) {
17 - out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; ';
18 - $schemaValue = 'schema' + $lvl;
19 - } else {
20 - $schemaValue = $schema;
21 - }
22 - var $rule = this,
23 - $definition = 'definition' + $lvl,
24 - $rDef = $rule.definition,
25 - $validate = $rDef.validate,
26 - $compile, $inline, $macro, $ruleValidate, $validateCode;
27 - if ($isData && $rDef.$data) {
28 - $validateCode = 'keywordValidate' + $lvl;
29 - var $validateSchema = $rDef.validateSchema;
30 - out += ' var ' + ($definition) + ' = RULES.custom[\'' + ($keyword) + '\'].definition; var ' + ($validateCode) + ' = ' + ($definition) + '.validate;';
31 - } else {
32 - $ruleValidate = it.useCustomRule($rule, $schema, it.schema, it);
33 - $schemaValue = 'validate.schema' + $schemaPath;
34 - $validateCode = $ruleValidate.code;
35 - $compile = $rDef.compile;
36 - $inline = $rDef.inline;
37 - $macro = $rDef.macro;
38 - }
39 - var $ruleErrs = $validateCode + '.errors',
40 - $i = 'i' + $lvl,
41 - $ruleErr = 'ruleErr' + $lvl,
42 - $asyncKeyword = $rDef.async;
43 - if ($asyncKeyword && !it.async) throw new Error('async keyword in sync schema');
44 - if (!($inline || $macro)) {
45 - out += '' + ($ruleErrs) + ' = null;';
46 - }
47 - out += 'var ' + ($errs) + ' = errors;var ' + ($valid) + ';';
48 - if ($validateSchema) {
49 - out += ' ' + ($valid) + ' = ' + ($definition) + '.validateSchema(' + ($schemaValue) + '); if (' + ($valid) + ') {';
50 - }
51 - if ($inline) {
52 - if ($rDef.statements) {
53 - out += ' ' + ($ruleValidate.validate) + ' ';
54 - } else {
55 - out += ' ' + ($valid) + ' = ' + ($ruleValidate.validate) + '; ';
56 - }
57 - } else if ($macro) {
58 - var $it = it.util.copy(it);
59 - $it.level++;
60 - var $nextValid = 'valid' + $it.level;
61 - $it.schema = $ruleValidate.validate;
62 - $it.schemaPath = '';
63 - var $wasComposite = it.compositeRule;
64 - it.compositeRule = $it.compositeRule = true;
65 - var $code = it.validate($it).replace(/validate\.schema/g, $validateCode);
66 - it.compositeRule = $it.compositeRule = $wasComposite;
67 - out += ' ' + ($code);
68 - } else {
69 - var $$outStack = $$outStack || [];
70 - $$outStack.push(out);
71 - out = '';
72 - out += ' ' + ($validateCode) + '.call( ';
73 - if (it.opts.passContext) {
74 - out += 'this';
75 - } else {
76 - out += 'self';
77 - }
78 - if ($compile || $rDef.schema === false) {
79 - out += ' , ' + ($data) + ' ';
80 - } else {
81 - out += ' , ' + ($schemaValue) + ' , ' + ($data) + ' , validate.schema' + (it.schemaPath) + ' ';
82 - }
83 - out += ' , (dataPath || \'\')';
84 - if (it.errorPath != '""') {
85 - out += ' + ' + (it.errorPath);
86 - }
87 - var $parentData = $dataLvl ? 'data' + (($dataLvl - 1) || '') : 'parentData',
88 - $parentDataProperty = $dataLvl ? it.dataPathArr[$dataLvl] : 'parentDataProperty';
89 - out += ' , ' + ($parentData) + ' , ' + ($parentDataProperty) + ' , rootData ) ';
90 - var def_callRuleValidate = out;
91 - out = $$outStack.pop();
92 - if ($rDef.errors === false) {
93 - out += ' ' + ($valid) + ' = ';
94 - if ($asyncKeyword) {
95 - out += '' + (it.yieldAwait);
96 - }
97 - out += '' + (def_callRuleValidate) + '; ';
98 - } else {
99 - if ($asyncKeyword) {
100 - $ruleErrs = 'customErrors' + $lvl;
101 - out += ' var ' + ($ruleErrs) + ' = null; try { ' + ($valid) + ' = ' + (it.yieldAwait) + (def_callRuleValidate) + '; } catch (e) { ' + ($valid) + ' = false; if (e instanceof ValidationError) ' + ($ruleErrs) + ' = e.errors; else throw e; } ';
102 - } else {
103 - out += ' ' + ($ruleErrs) + ' = null; ' + ($valid) + ' = ' + (def_callRuleValidate) + '; ';
104 - }
105 - }
106 - }
107 - if ($rDef.modifying) {
108 - out += ' ' + ($data) + ' = ' + ($parentData) + '[' + ($parentDataProperty) + '];';
109 - }
110 - if ($validateSchema) {
111 - out += ' }';
112 - }
113 - if ($rDef.valid) {
114 - if ($breakOnError) {
115 - out += ' if (true) { ';
116 - }
117 - } else {
118 - out += ' if ( ';
119 - if ($rDef.valid === undefined) {
120 - out += ' !';
121 - if ($macro) {
122 - out += '' + ($nextValid);
123 - } else {
124 - out += '' + ($valid);
125 - }
126 - } else {
127 - out += ' ' + (!$rDef.valid) + ' ';
128 - }
129 - out += ') { ';
130 - $errorKeyword = $rule.keyword;
131 - var $$outStack = $$outStack || [];
132 - $$outStack.push(out);
133 - out = '';
134 - var $$outStack = $$outStack || [];
135 - $$outStack.push(out);
136 - out = ''; /* istanbul ignore else */
137 - if (it.createErrors !== false) {
138 - out += ' { keyword: \'' + ($errorKeyword || 'custom') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { keyword: \'' + ($rule.keyword) + '\' } ';
139 - if (it.opts.messages !== false) {
140 - out += ' , message: \'should pass "' + ($rule.keyword) + '" keyword validation\' ';
141 - }
142 - if (it.opts.verbose) {
143 - out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
144 - }
145 - out += ' } ';
146 - } else {
147 - out += ' {} ';
148 - }
149 - var __err = out;
150 - out = $$outStack.pop();
151 - if (!it.compositeRule && $breakOnError) { /* istanbul ignore if */
152 - if (it.async) {
153 - out += ' throw new ValidationError([' + (__err) + ']); ';
154 - } else {
155 - out += ' validate.errors = [' + (__err) + ']; return false; ';
156 - }
157 - } else {
158 - out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
159 - }
160 - var def_customError = out;
161 - out = $$outStack.pop();
162 - if ($inline) {
163 - if ($rDef.errors) {
164 - if ($rDef.errors != 'full') {
165 - out += ' for (var ' + ($i) + '=' + ($errs) + '; ' + ($i) + '<errors; ' + ($i) + '++) { var ' + ($ruleErr) + ' = vErrors[' + ($i) + ']; if (' + ($ruleErr) + '.dataPath === undefined) ' + ($ruleErr) + '.dataPath = (dataPath || \'\') + ' + (it.errorPath) + '; if (' + ($ruleErr) + '.schemaPath === undefined) { ' + ($ruleErr) + '.schemaPath = "' + ($errSchemaPath) + '"; } ';
166 - if (it.opts.verbose) {
167 - out += ' ' + ($ruleErr) + '.schema = ' + ($schemaValue) + '; ' + ($ruleErr) + '.data = ' + ($data) + '; ';
168 - }
169 - out += ' } ';
170 - }
171 - } else {
172 - if ($rDef.errors === false) {
173 - out += ' ' + (def_customError) + ' ';
174 - } else {
175 - out += ' if (' + ($errs) + ' == errors) { ' + (def_customError) + ' } else { for (var ' + ($i) + '=' + ($errs) + '; ' + ($i) + '<errors; ' + ($i) + '++) { var ' + ($ruleErr) + ' = vErrors[' + ($i) + ']; if (' + ($ruleErr) + '.dataPath === undefined) ' + ($ruleErr) + '.dataPath = (dataPath || \'\') + ' + (it.errorPath) + '; if (' + ($ruleErr) + '.schemaPath === undefined) { ' + ($ruleErr) + '.schemaPath = "' + ($errSchemaPath) + '"; } ';
176 - if (it.opts.verbose) {
177 - out += ' ' + ($ruleErr) + '.schema = ' + ($schemaValue) + '; ' + ($ruleErr) + '.data = ' + ($data) + '; ';
178 - }
179 - out += ' } } ';
180 - }
181 - }
182 - } else if ($macro) {
183 - out += ' var err = '; /* istanbul ignore else */
184 - if (it.createErrors !== false) {
185 - out += ' { keyword: \'' + ($errorKeyword || 'custom') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { keyword: \'' + ($rule.keyword) + '\' } ';
186 - if (it.opts.messages !== false) {
187 - out += ' , message: \'should pass "' + ($rule.keyword) + '" keyword validation\' ';
188 - }
189 - if (it.opts.verbose) {
190 - out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
191 - }
192 - out += ' } ';
193 - } else {
194 - out += ' {} ';
195 - }
196 - out += '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
197 - if (!it.compositeRule && $breakOnError) { /* istanbul ignore if */
198 - if (it.async) {
199 - out += ' throw new ValidationError(vErrors); ';
200 - } else {
201 - out += ' validate.errors = vErrors; return false; ';
202 - }
203 - }
204 - } else {
205 - if ($rDef.errors === false) {
206 - out += ' ' + (def_customError) + ' ';
207 - } else {
208 - out += ' if (Array.isArray(' + ($ruleErrs) + ')) { if (vErrors === null) vErrors = ' + ($ruleErrs) + '; else vErrors = vErrors.concat(' + ($ruleErrs) + '); errors = vErrors.length; for (var ' + ($i) + '=' + ($errs) + '; ' + ($i) + '<errors; ' + ($i) + '++) { var ' + ($ruleErr) + ' = vErrors[' + ($i) + ']; if (' + ($ruleErr) + '.dataPath === undefined) ' + ($ruleErr) + '.dataPath = (dataPath || \'\') + ' + (it.errorPath) + '; ' + ($ruleErr) + '.schemaPath = "' + ($errSchemaPath) + '"; ';
209 - if (it.opts.verbose) {
210 - out += ' ' + ($ruleErr) + '.schema = ' + ($schemaValue) + '; ' + ($ruleErr) + '.data = ' + ($data) + '; ';
211 - }
212 - out += ' } } else { ' + (def_customError) + ' } ';
213 - }
214 - }
215 - out += ' } ';
216 - if ($breakOnError) {
217 - out += ' else { ';
218 - }
219 - }
220 - return out;
221 -}
1 -'use strict';
2 -module.exports = function generate_dependencies(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 $errs = 'errs__' + $lvl;
13 - var $it = it.util.copy(it);
14 - var $closingBraces = '';
15 - $it.level++;
16 - var $nextValid = 'valid' + $it.level;
17 - var $schemaDeps = {},
18 - $propertyDeps = {};
19 - for ($property in $schema) {
20 - var $sch = $schema[$property];
21 - var $deps = Array.isArray($sch) ? $propertyDeps : $schemaDeps;
22 - $deps[$property] = $sch;
23 - }
24 - out += 'var ' + ($errs) + ' = errors;';
25 - var $currentErrorPath = it.errorPath;
26 - out += 'var missing' + ($lvl) + ';';
27 - for (var $property in $propertyDeps) {
28 - $deps = $propertyDeps[$property];
29 - out += ' if (' + ($data) + (it.util.getProperty($property)) + ' !== undefined ';
30 - if ($breakOnError) {
31 - out += ' && ( ';
32 - var arr1 = $deps;
33 - if (arr1) {
34 - var _$property, $i = -1,
35 - l1 = arr1.length - 1;
36 - while ($i < l1) {
37 - _$property = arr1[$i += 1];
38 - if ($i) {
39 - out += ' || ';
40 - }
41 - var $prop = it.util.getProperty(_$property);
42 - out += ' ( ' + ($data) + ($prop) + ' === undefined && (missing' + ($lvl) + ' = ' + (it.util.toQuotedString(it.opts.jsonPointers ? _$property : $prop)) + ') ) ';
43 - }
44 - }
45 - out += ')) { ';
46 - var $propertyPath = 'missing' + $lvl,
47 - $missingProperty = '\' + ' + $propertyPath + ' + \'';
48 - if (it.opts._errorDataPathProperty) {
49 - it.errorPath = it.opts.jsonPointers ? it.util.getPathExpr($currentErrorPath, $propertyPath, true) : $currentErrorPath + ' + ' + $propertyPath;
50 - }
51 - var $$outStack = $$outStack || [];
52 - $$outStack.push(out);
53 - out = ''; /* istanbul ignore else */
54 - if (it.createErrors !== false) {
55 - out += ' { keyword: \'' + ($errorKeyword || 'dependencies') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { property: \'' + (it.util.escapeQuotes($property)) + '\', missingProperty: \'' + ($missingProperty) + '\', depsCount: ' + ($deps.length) + ', deps: \'' + (it.util.escapeQuotes($deps.length == 1 ? $deps[0] : $deps.join(", "))) + '\' } ';
56 - if (it.opts.messages !== false) {
57 - out += ' , message: \'should have ';
58 - if ($deps.length == 1) {
59 - out += 'property ' + (it.util.escapeQuotes($deps[0]));
60 - } else {
61 - out += 'properties ' + (it.util.escapeQuotes($deps.join(", ")));
62 - }
63 - out += ' when property ' + (it.util.escapeQuotes($property)) + ' is present\' ';
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 - } else {
84 - out += ' ) { ';
85 - var arr2 = $deps;
86 - if (arr2) {
87 - var $reqProperty, i2 = -1,
88 - l2 = arr2.length - 1;
89 - while (i2 < l2) {
90 - $reqProperty = arr2[i2 += 1];
91 - var $prop = it.util.getProperty($reqProperty),
92 - $missingProperty = it.util.escapeQuotes($reqProperty);
93 - if (it.opts._errorDataPathProperty) {
94 - it.errorPath = it.util.getPath($currentErrorPath, $reqProperty, it.opts.jsonPointers);
95 - }
96 - out += ' if (' + ($data) + ($prop) + ' === undefined) { var err = '; /* istanbul ignore else */
97 - if (it.createErrors !== false) {
98 - out += ' { keyword: \'' + ($errorKeyword || 'dependencies') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { property: \'' + (it.util.escapeQuotes($property)) + '\', missingProperty: \'' + ($missingProperty) + '\', depsCount: ' + ($deps.length) + ', deps: \'' + (it.util.escapeQuotes($deps.length == 1 ? $deps[0] : $deps.join(", "))) + '\' } ';
99 - if (it.opts.messages !== false) {
100 - out += ' , message: \'should have ';
101 - if ($deps.length == 1) {
102 - out += 'property ' + (it.util.escapeQuotes($deps[0]));
103 - } else {
104 - out += 'properties ' + (it.util.escapeQuotes($deps.join(", ")));
105 - }
106 - out += ' when property ' + (it.util.escapeQuotes($property)) + ' is present\' ';
107 - }
108 - if (it.opts.verbose) {
109 - out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
110 - }
111 - out += ' } ';
112 - } else {
113 - out += ' {} ';
114 - }
115 - out += '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } ';
116 - }
117 - }
118 - }
119 - out += ' } ';
120 - if ($breakOnError) {
121 - $closingBraces += '}';
122 - out += ' else { ';
123 - }
124 - }
125 - it.errorPath = $currentErrorPath;
126 - var $currentBaseId = $it.baseId;
127 - for (var $property in $schemaDeps) {
128 - var $sch = $schemaDeps[$property];
129 - if (it.util.schemaHasRules($sch, it.RULES.all)) {
130 - out += ' ' + ($nextValid) + ' = true; if (' + ($data) + (it.util.getProperty($property)) + ' !== undefined) { ';
131 - $it.schema = $sch;
132 - $it.schemaPath = $schemaPath + it.util.getProperty($property);
133 - $it.errSchemaPath = $errSchemaPath + '/' + it.util.escapeFragment($property);
134 - out += ' ' + (it.validate($it)) + ' ';
135 - $it.baseId = $currentBaseId;
136 - out += ' } ';
137 - if ($breakOnError) {
138 - out += ' if (' + ($nextValid) + ') { ';
139 - $closingBraces += '}';
140 - }
141 - }
142 - }
143 - if ($breakOnError) {
144 - out += ' ' + ($closingBraces) + ' if (' + ($errs) + ' == errors) {';
145 - }
146 - out = it.util.cleanUpCode(out);
147 - return out;
148 -}
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff 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 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.