Actualizacion maquina principal
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / ajv / dist / ajv.bundle.js
1 (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Ajv = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
2 'use strict';
3
4
5 var Cache = module.exports = function Cache() {
6   this._cache = {};
7 };
8
9
10 Cache.prototype.put = function Cache_put(key, value) {
11   this._cache[key] = value;
12 };
13
14
15 Cache.prototype.get = function Cache_get(key) {
16   return this._cache[key];
17 };
18
19
20 Cache.prototype.del = function Cache_del(key) {
21   delete this._cache[key];
22 };
23
24
25 Cache.prototype.clear = function Cache_clear() {
26   this._cache = {};
27 };
28
29 },{}],2:[function(require,module,exports){
30 'use strict';
31
32 var MissingRefError = require('./error_classes').MissingRef;
33
34 module.exports = compileAsync;
35
36
37 /**
38  * Creates validating function for passed schema with asynchronous loading of missing schemas.
39  * `loadSchema` option should be a function that accepts schema uri and returns promise that resolves with the schema.
40  * @this  Ajv
41  * @param {Object}   schema schema object
42  * @param {Boolean}  meta optional true to compile meta-schema; this parameter can be skipped
43  * @param {Function} callback an optional node-style callback, it is called with 2 parameters: error (or null) and validating function.
44  * @return {Promise} promise that resolves with a validating function.
45  */
46 function compileAsync(schema, meta, callback) {
47   /* eslint no-shadow: 0 */
48   /* global Promise */
49   /* jshint validthis: true */
50   var self = this;
51   if (typeof this._opts.loadSchema != 'function')
52     throw new Error('options.loadSchema should be a function');
53
54   if (typeof meta == 'function') {
55     callback = meta;
56     meta = undefined;
57   }
58
59   var p = loadMetaSchemaOf(schema).then(function () {
60     var schemaObj = self._addSchema(schema, undefined, meta);
61     return schemaObj.validate || _compileAsync(schemaObj);
62   });
63
64   if (callback) {
65     p.then(
66       function(v) { callback(null, v); },
67       callback
68     );
69   }
70
71   return p;
72
73
74   function loadMetaSchemaOf(sch) {
75     var $schema = sch.$schema;
76     return $schema && !self.getSchema($schema)
77             ? compileAsync.call(self, { $ref: $schema }, true)
78             : Promise.resolve();
79   }
80
81
82   function _compileAsync(schemaObj) {
83     try { return self._compile(schemaObj); }
84     catch(e) {
85       if (e instanceof MissingRefError) return loadMissingSchema(e);
86       throw e;
87     }
88
89
90     function loadMissingSchema(e) {
91       var ref = e.missingSchema;
92       if (added(ref)) throw new Error('Schema ' + ref + ' is loaded but ' + e.missingRef + ' cannot be resolved');
93
94       var schemaPromise = self._loadingSchemas[ref];
95       if (!schemaPromise) {
96         schemaPromise = self._loadingSchemas[ref] = self._opts.loadSchema(ref);
97         schemaPromise.then(removePromise, removePromise);
98       }
99
100       return schemaPromise.then(function (sch) {
101         if (!added(ref)) {
102           return loadMetaSchemaOf(sch).then(function () {
103             if (!added(ref)) self.addSchema(sch, ref, undefined, meta);
104           });
105         }
106       }).then(function() {
107         return _compileAsync(schemaObj);
108       });
109
110       function removePromise() {
111         delete self._loadingSchemas[ref];
112       }
113
114       function added(ref) {
115         return self._refs[ref] || self._schemas[ref];
116       }
117     }
118   }
119 }
120
121 },{"./error_classes":3}],3:[function(require,module,exports){
122 'use strict';
123
124 var resolve = require('./resolve');
125
126 module.exports = {
127   Validation: errorSubclass(ValidationError),
128   MissingRef: errorSubclass(MissingRefError)
129 };
130
131
132 function ValidationError(errors) {
133   this.message = 'validation failed';
134   this.errors = errors;
135   this.ajv = this.validation = true;
136 }
137
138
139 MissingRefError.message = function (baseId, ref) {
140   return 'can\'t resolve reference ' + ref + ' from id ' + baseId;
141 };
142
143
144 function MissingRefError(baseId, ref, message) {
145   this.message = message || MissingRefError.message(baseId, ref);
146   this.missingRef = resolve.url(baseId, ref);
147   this.missingSchema = resolve.normalizeId(resolve.fullPath(this.missingRef));
148 }
149
150
151 function errorSubclass(Subclass) {
152   Subclass.prototype = Object.create(Error.prototype);
153   Subclass.prototype.constructor = Subclass;
154   return Subclass;
155 }
156
157 },{"./resolve":6}],4:[function(require,module,exports){
158 'use strict';
159
160 var util = require('./util');
161
162 var DATE = /^(\d\d\d\d)-(\d\d)-(\d\d)$/;
163 var DAYS = [0,31,28,31,30,31,30,31,31,30,31,30,31];
164 var TIME = /^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i;
165 var HOSTNAME = /^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i;
166 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;
167 var URIREF = /^(?:[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;
168 // uri-template: https://tools.ietf.org/html/rfc6570
169 var URITEMPLATE = /^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i;
170 // For the source: https://gist.github.com/dperini/729294
171 // For test cases: https://mathiasbynens.be/demo/url-regex
172 // @todo Delete current URL in favour of the commented out URL rule when this issue is fixed https://github.com/eslint/eslint/issues/7983.
173 // var URL = /^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)(?:\.(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu;
174 var URL = /^(?:(?:http[s\u017F]?|ftp):\/\/)(?:(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+(?::(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)?@)?(?:(?!10(?:\.[0-9]{1,3}){3})(?!127(?:\.[0-9]{1,3}){3})(?!169\.254(?:\.[0-9]{1,3}){2})(?!192\.168(?:\.[0-9]{1,3}){2})(?!172\.(?:1[6-9]|2[0-9]|3[01])(?:\.[0-9]{1,3}){2})(?:[1-9][0-9]?|1[0-9][0-9]|2[01][0-9]|22[0-3])(?:\.(?:1?[0-9]{1,2}|2[0-4][0-9]|25[0-5])){2}(?:\.(?:[1-9][0-9]?|1[0-9][0-9]|2[0-4][0-9]|25[0-4]))|(?:(?:(?:[0-9KSa-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+-?)*(?:[0-9KSa-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+)(?:\.(?:(?:[0-9KSa-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+-?)*(?:[0-9KSa-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+)*(?:\.(?:(?:[KSa-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]){2,})))(?::[0-9]{2,5})?(?:\/(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)?$/i;
175 var UUID = /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i;
176 var JSON_POINTER = /^(?:\/(?:[^~/]|~0|~1)*)*$/;
177 var JSON_POINTER_URI_FRAGMENT = /^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i;
178 var RELATIVE_JSON_POINTER = /^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/;
179
180
181 module.exports = formats;
182
183 function formats(mode) {
184   mode = mode == 'full' ? 'full' : 'fast';
185   return util.copy(formats[mode]);
186 }
187
188
189 formats.fast = {
190   // date: http://tools.ietf.org/html/rfc3339#section-5.6
191   date: /^\d\d\d\d-[0-1]\d-[0-3]\d$/,
192   // date-time: http://tools.ietf.org/html/rfc3339#section-5.6
193   time: /^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,
194   'date-time': /^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,
195   // uri: https://github.com/mafintosh/is-my-json-valid/blob/master/formats.js
196   uri: /^(?:[a-z][a-z0-9+-.]*:)(?:\/?\/)?[^\s]*$/i,
197   'uri-reference': /^(?:(?:[a-z][a-z0-9+-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,
198   'uri-template': URITEMPLATE,
199   url: URL,
200   // email (sources from jsen validator):
201   // http://stackoverflow.com/questions/201323/using-a-regular-expression-to-validate-an-email-address#answer-8829363
202   // http://www.w3.org/TR/html5/forms.html#valid-e-mail-address (search for 'willful violation')
203   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,
204   hostname: HOSTNAME,
205   // optimized https://www.safaribooksonline.com/library/view/regular-expressions-cookbook/9780596802837/ch07s16.html
206   ipv4: /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,
207   // optimized http://stackoverflow.com/questions/53497/regular-expression-that-matches-valid-ipv6-addresses
208   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,
209   regex: regex,
210   // uuid: http://tools.ietf.org/html/rfc4122
211   uuid: UUID,
212   // JSON-pointer: https://tools.ietf.org/html/rfc6901
213   // uri fragment: https://tools.ietf.org/html/rfc3986#appendix-A
214   'json-pointer': JSON_POINTER,
215   'json-pointer-uri-fragment': JSON_POINTER_URI_FRAGMENT,
216   // relative JSON-pointer: http://tools.ietf.org/html/draft-luff-relative-json-pointer-00
217   'relative-json-pointer': RELATIVE_JSON_POINTER
218 };
219
220
221 formats.full = {
222   date: date,
223   time: time,
224   'date-time': date_time,
225   uri: uri,
226   'uri-reference': URIREF,
227   'uri-template': URITEMPLATE,
228   url: URL,
229   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,
230   hostname: HOSTNAME,
231   ipv4: /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,
232   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,
233   regex: regex,
234   uuid: UUID,
235   'json-pointer': JSON_POINTER,
236   'json-pointer-uri-fragment': JSON_POINTER_URI_FRAGMENT,
237   'relative-json-pointer': RELATIVE_JSON_POINTER
238 };
239
240
241 function isLeapYear(year) {
242   // https://tools.ietf.org/html/rfc3339#appendix-C
243   return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
244 }
245
246
247 function date(str) {
248   // full-date from http://tools.ietf.org/html/rfc3339#section-5.6
249   var matches = str.match(DATE);
250   if (!matches) return false;
251
252   var year = +matches[1];
253   var month = +matches[2];
254   var day = +matches[3];
255
256   return month >= 1 && month <= 12 && day >= 1 &&
257           day <= (month == 2 && isLeapYear(year) ? 29 : DAYS[month]);
258 }
259
260
261 function time(str, full) {
262   var matches = str.match(TIME);
263   if (!matches) return false;
264
265   var hour = matches[1];
266   var minute = matches[2];
267   var second = matches[3];
268   var timeZone = matches[5];
269   return ((hour <= 23 && minute <= 59 && second <= 59) ||
270           (hour == 23 && minute == 59 && second == 60)) &&
271          (!full || timeZone);
272 }
273
274
275 var DATE_TIME_SEPARATOR = /t|\s/i;
276 function date_time(str) {
277   // http://tools.ietf.org/html/rfc3339#section-5.6
278   var dateTime = str.split(DATE_TIME_SEPARATOR);
279   return dateTime.length == 2 && date(dateTime[0]) && time(dateTime[1], true);
280 }
281
282
283 var NOT_URI_FRAGMENT = /\/|:/;
284 function uri(str) {
285   // http://jmrware.com/articles/2009/uri_regexp/URI_regex.html + optional protocol + required "."
286   return NOT_URI_FRAGMENT.test(str) && URI.test(str);
287 }
288
289
290 var Z_ANCHOR = /[^\\]\\Z/;
291 function regex(str) {
292   if (Z_ANCHOR.test(str)) return false;
293   try {
294     new RegExp(str);
295     return true;
296   } catch(e) {
297     return false;
298   }
299 }
300
301 },{"./util":10}],5:[function(require,module,exports){
302 'use strict';
303
304 var resolve = require('./resolve')
305   , util = require('./util')
306   , errorClasses = require('./error_classes')
307   , stableStringify = require('fast-json-stable-stringify');
308
309 var validateGenerator = require('../dotjs/validate');
310
311 /**
312  * Functions below are used inside compiled validations function
313  */
314
315 var ucs2length = util.ucs2length;
316 var equal = require('fast-deep-equal');
317
318 // this error is thrown by async schemas to return validation errors via exception
319 var ValidationError = errorClasses.Validation;
320
321 module.exports = compile;
322
323
324 /**
325  * Compiles schema to validation function
326  * @this   Ajv
327  * @param  {Object} schema schema object
328  * @param  {Object} root object with information about the root schema for this schema
329  * @param  {Object} localRefs the hash of local references inside the schema (created by resolve.id), used for inline resolution
330  * @param  {String} baseId base ID for IDs in the schema
331  * @return {Function} validation function
332  */
333 function compile(schema, root, localRefs, baseId) {
334   /* jshint validthis: true, evil: true */
335   /* eslint no-shadow: 0 */
336   var self = this
337     , opts = this._opts
338     , refVal = [ undefined ]
339     , refs = {}
340     , patterns = []
341     , patternsHash = {}
342     , defaults = []
343     , defaultsHash = {}
344     , customRules = [];
345
346   root = root || { schema: schema, refVal: refVal, refs: refs };
347
348   var c = checkCompiling.call(this, schema, root, baseId);
349   var compilation = this._compilations[c.index];
350   if (c.compiling) return (compilation.callValidate = callValidate);
351
352   var formats = this._formats;
353   var RULES = this.RULES;
354
355   try {
356     var v = localCompile(schema, root, localRefs, baseId);
357     compilation.validate = v;
358     var cv = compilation.callValidate;
359     if (cv) {
360       cv.schema = v.schema;
361       cv.errors = null;
362       cv.refs = v.refs;
363       cv.refVal = v.refVal;
364       cv.root = v.root;
365       cv.$async = v.$async;
366       if (opts.sourceCode) cv.source = v.source;
367     }
368     return v;
369   } finally {
370     endCompiling.call(this, schema, root, baseId);
371   }
372
373   /* @this   {*} - custom context, see passContext option */
374   function callValidate() {
375     /* jshint validthis: true */
376     var validate = compilation.validate;
377     var result = validate.apply(this, arguments);
378     callValidate.errors = validate.errors;
379     return result;
380   }
381
382   function localCompile(_schema, _root, localRefs, baseId) {
383     var isRoot = !_root || (_root && _root.schema == _schema);
384     if (_root.schema != root.schema)
385       return compile.call(self, _schema, _root, localRefs, baseId);
386
387     var $async = _schema.$async === true;
388
389     var sourceCode = validateGenerator({
390       isTop: true,
391       schema: _schema,
392       isRoot: isRoot,
393       baseId: baseId,
394       root: _root,
395       schemaPath: '',
396       errSchemaPath: '#',
397       errorPath: '""',
398       MissingRefError: errorClasses.MissingRef,
399       RULES: RULES,
400       validate: validateGenerator,
401       util: util,
402       resolve: resolve,
403       resolveRef: resolveRef,
404       usePattern: usePattern,
405       useDefault: useDefault,
406       useCustomRule: useCustomRule,
407       opts: opts,
408       formats: formats,
409       logger: self.logger,
410       self: self
411     });
412
413     sourceCode = vars(refVal, refValCode) + vars(patterns, patternCode)
414                    + vars(defaults, defaultCode) + vars(customRules, customRuleCode)
415                    + sourceCode;
416
417     if (opts.processCode) sourceCode = opts.processCode(sourceCode, _schema);
418     // console.log('\n\n\n *** \n', JSON.stringify(sourceCode));
419     var validate;
420     try {
421       var makeValidate = new Function(
422         'self',
423         'RULES',
424         'formats',
425         'root',
426         'refVal',
427         'defaults',
428         'customRules',
429         'equal',
430         'ucs2length',
431         'ValidationError',
432         sourceCode
433       );
434
435       validate = makeValidate(
436         self,
437         RULES,
438         formats,
439         root,
440         refVal,
441         defaults,
442         customRules,
443         equal,
444         ucs2length,
445         ValidationError
446       );
447
448       refVal[0] = validate;
449     } catch(e) {
450       self.logger.error('Error compiling schema, function code:', sourceCode);
451       throw e;
452     }
453
454     validate.schema = _schema;
455     validate.errors = null;
456     validate.refs = refs;
457     validate.refVal = refVal;
458     validate.root = isRoot ? validate : _root;
459     if ($async) validate.$async = true;
460     if (opts.sourceCode === true) {
461       validate.source = {
462         code: sourceCode,
463         patterns: patterns,
464         defaults: defaults
465       };
466     }
467
468     return validate;
469   }
470
471   function resolveRef(baseId, ref, isRoot) {
472     ref = resolve.url(baseId, ref);
473     var refIndex = refs[ref];
474     var _refVal, refCode;
475     if (refIndex !== undefined) {
476       _refVal = refVal[refIndex];
477       refCode = 'refVal[' + refIndex + ']';
478       return resolvedRef(_refVal, refCode);
479     }
480     if (!isRoot && root.refs) {
481       var rootRefId = root.refs[ref];
482       if (rootRefId !== undefined) {
483         _refVal = root.refVal[rootRefId];
484         refCode = addLocalRef(ref, _refVal);
485         return resolvedRef(_refVal, refCode);
486       }
487     }
488
489     refCode = addLocalRef(ref);
490     var v = resolve.call(self, localCompile, root, ref);
491     if (v === undefined) {
492       var localSchema = localRefs && localRefs[ref];
493       if (localSchema) {
494         v = resolve.inlineRef(localSchema, opts.inlineRefs)
495             ? localSchema
496             : compile.call(self, localSchema, root, localRefs, baseId);
497       }
498     }
499
500     if (v === undefined) {
501       removeLocalRef(ref);
502     } else {
503       replaceLocalRef(ref, v);
504       return resolvedRef(v, refCode);
505     }
506   }
507
508   function addLocalRef(ref, v) {
509     var refId = refVal.length;
510     refVal[refId] = v;
511     refs[ref] = refId;
512     return 'refVal' + refId;
513   }
514
515   function removeLocalRef(ref) {
516     delete refs[ref];
517   }
518
519   function replaceLocalRef(ref, v) {
520     var refId = refs[ref];
521     refVal[refId] = v;
522   }
523
524   function resolvedRef(refVal, code) {
525     return typeof refVal == 'object' || typeof refVal == 'boolean'
526             ? { code: code, schema: refVal, inline: true }
527             : { code: code, $async: refVal && !!refVal.$async };
528   }
529
530   function usePattern(regexStr) {
531     var index = patternsHash[regexStr];
532     if (index === undefined) {
533       index = patternsHash[regexStr] = patterns.length;
534       patterns[index] = regexStr;
535     }
536     return 'pattern' + index;
537   }
538
539   function useDefault(value) {
540     switch (typeof value) {
541       case 'boolean':
542       case 'number':
543         return '' + value;
544       case 'string':
545         return util.toQuotedString(value);
546       case 'object':
547         if (value === null) return 'null';
548         var valueStr = stableStringify(value);
549         var index = defaultsHash[valueStr];
550         if (index === undefined) {
551           index = defaultsHash[valueStr] = defaults.length;
552           defaults[index] = value;
553         }
554         return 'default' + index;
555     }
556   }
557
558   function useCustomRule(rule, schema, parentSchema, it) {
559     if (self._opts.validateSchema !== false) {
560       var deps = rule.definition.dependencies;
561       if (deps && !deps.every(function(keyword) {
562         return Object.prototype.hasOwnProperty.call(parentSchema, keyword);
563       }))
564         throw new Error('parent schema must have all required keywords: ' + deps.join(','));
565
566       var validateSchema = rule.definition.validateSchema;
567       if (validateSchema) {
568         var valid = validateSchema(schema);
569         if (!valid) {
570           var message = 'keyword schema is invalid: ' + self.errorsText(validateSchema.errors);
571           if (self._opts.validateSchema == 'log') self.logger.error(message);
572           else throw new Error(message);
573         }
574       }
575     }
576
577     var compile = rule.definition.compile
578       , inline = rule.definition.inline
579       , macro = rule.definition.macro;
580
581     var validate;
582     if (compile) {
583       validate = compile.call(self, schema, parentSchema, it);
584     } else if (macro) {
585       validate = macro.call(self, schema, parentSchema, it);
586       if (opts.validateSchema !== false) self.validateSchema(validate, true);
587     } else if (inline) {
588       validate = inline.call(self, it, rule.keyword, schema, parentSchema);
589     } else {
590       validate = rule.definition.validate;
591       if (!validate) return;
592     }
593
594     if (validate === undefined)
595       throw new Error('custom keyword "' + rule.keyword + '"failed to compile');
596
597     var index = customRules.length;
598     customRules[index] = validate;
599
600     return {
601       code: 'customRule' + index,
602       validate: validate
603     };
604   }
605 }
606
607
608 /**
609  * Checks if the schema is currently compiled
610  * @this   Ajv
611  * @param  {Object} schema schema to compile
612  * @param  {Object} root root object
613  * @param  {String} baseId base schema ID
614  * @return {Object} object with properties "index" (compilation index) and "compiling" (boolean)
615  */
616 function checkCompiling(schema, root, baseId) {
617   /* jshint validthis: true */
618   var index = compIndex.call(this, schema, root, baseId);
619   if (index >= 0) return { index: index, compiling: true };
620   index = this._compilations.length;
621   this._compilations[index] = {
622     schema: schema,
623     root: root,
624     baseId: baseId
625   };
626   return { index: index, compiling: false };
627 }
628
629
630 /**
631  * Removes the schema from the currently compiled list
632  * @this   Ajv
633  * @param  {Object} schema schema to compile
634  * @param  {Object} root root object
635  * @param  {String} baseId base schema ID
636  */
637 function endCompiling(schema, root, baseId) {
638   /* jshint validthis: true */
639   var i = compIndex.call(this, schema, root, baseId);
640   if (i >= 0) this._compilations.splice(i, 1);
641 }
642
643
644 /**
645  * Index of schema compilation in the currently compiled list
646  * @this   Ajv
647  * @param  {Object} schema schema to compile
648  * @param  {Object} root root object
649  * @param  {String} baseId base schema ID
650  * @return {Integer} compilation index
651  */
652 function compIndex(schema, root, baseId) {
653   /* jshint validthis: true */
654   for (var i=0; i<this._compilations.length; i++) {
655     var c = this._compilations[i];
656     if (c.schema == schema && c.root == root && c.baseId == baseId) return i;
657   }
658   return -1;
659 }
660
661
662 function patternCode(i, patterns) {
663   return 'var pattern' + i + ' = new RegExp(' + util.toQuotedString(patterns[i]) + ');';
664 }
665
666
667 function defaultCode(i) {
668   return 'var default' + i + ' = defaults[' + i + '];';
669 }
670
671
672 function refValCode(i, refVal) {
673   return refVal[i] === undefined ? '' : 'var refVal' + i + ' = refVal[' + i + '];';
674 }
675
676
677 function customRuleCode(i) {
678   return 'var customRule' + i + ' = customRules[' + i + '];';
679 }
680
681
682 function vars(arr, statement) {
683   if (!arr.length) return '';
684   var code = '';
685   for (var i=0; i<arr.length; i++)
686     code += statement(i, arr);
687   return code;
688 }
689
690 },{"../dotjs/validate":38,"./error_classes":3,"./resolve":6,"./util":10,"fast-deep-equal":42,"fast-json-stable-stringify":43}],6:[function(require,module,exports){
691 'use strict';
692
693 var URI = require('uri-js')
694   , equal = require('fast-deep-equal')
695   , util = require('./util')
696   , SchemaObject = require('./schema_obj')
697   , traverse = require('json-schema-traverse');
698
699 module.exports = resolve;
700
701 resolve.normalizeId = normalizeId;
702 resolve.fullPath = getFullPath;
703 resolve.url = resolveUrl;
704 resolve.ids = resolveIds;
705 resolve.inlineRef = inlineRef;
706 resolve.schema = resolveSchema;
707
708 /**
709  * [resolve and compile the references ($ref)]
710  * @this   Ajv
711  * @param  {Function} compile reference to schema compilation funciton (localCompile)
712  * @param  {Object} root object with information about the root schema for the current schema
713  * @param  {String} ref reference to resolve
714  * @return {Object|Function} schema object (if the schema can be inlined) or validation function
715  */
716 function resolve(compile, root, ref) {
717   /* jshint validthis: true */
718   var refVal = this._refs[ref];
719   if (typeof refVal == 'string') {
720     if (this._refs[refVal]) refVal = this._refs[refVal];
721     else return resolve.call(this, compile, root, refVal);
722   }
723
724   refVal = refVal || this._schemas[ref];
725   if (refVal instanceof SchemaObject) {
726     return inlineRef(refVal.schema, this._opts.inlineRefs)
727             ? refVal.schema
728             : refVal.validate || this._compile(refVal);
729   }
730
731   var res = resolveSchema.call(this, root, ref);
732   var schema, v, baseId;
733   if (res) {
734     schema = res.schema;
735     root = res.root;
736     baseId = res.baseId;
737   }
738
739   if (schema instanceof SchemaObject) {
740     v = schema.validate || compile.call(this, schema.schema, root, undefined, baseId);
741   } else if (schema !== undefined) {
742     v = inlineRef(schema, this._opts.inlineRefs)
743         ? schema
744         : compile.call(this, schema, root, undefined, baseId);
745   }
746
747   return v;
748 }
749
750
751 /**
752  * Resolve schema, its root and baseId
753  * @this Ajv
754  * @param  {Object} root root object with properties schema, refVal, refs
755  * @param  {String} ref  reference to resolve
756  * @return {Object} object with properties schema, root, baseId
757  */
758 function resolveSchema(root, ref) {
759   /* jshint validthis: true */
760   var p = URI.parse(ref)
761     , refPath = _getFullPath(p)
762     , baseId = getFullPath(this._getId(root.schema));
763   if (Object.keys(root.schema).length === 0 || refPath !== baseId) {
764     var id = normalizeId(refPath);
765     var refVal = this._refs[id];
766     if (typeof refVal == 'string') {
767       return resolveRecursive.call(this, root, refVal, p);
768     } else if (refVal instanceof SchemaObject) {
769       if (!refVal.validate) this._compile(refVal);
770       root = refVal;
771     } else {
772       refVal = this._schemas[id];
773       if (refVal instanceof SchemaObject) {
774         if (!refVal.validate) this._compile(refVal);
775         if (id == normalizeId(ref))
776           return { schema: refVal, root: root, baseId: baseId };
777         root = refVal;
778       } else {
779         return;
780       }
781     }
782     if (!root.schema) return;
783     baseId = getFullPath(this._getId(root.schema));
784   }
785   return getJsonPointer.call(this, p, baseId, root.schema, root);
786 }
787
788
789 /* @this Ajv */
790 function resolveRecursive(root, ref, parsedRef) {
791   /* jshint validthis: true */
792   var res = resolveSchema.call(this, root, ref);
793   if (res) {
794     var schema = res.schema;
795     var baseId = res.baseId;
796     root = res.root;
797     var id = this._getId(schema);
798     if (id) baseId = resolveUrl(baseId, id);
799     return getJsonPointer.call(this, parsedRef, baseId, schema, root);
800   }
801 }
802
803
804 var PREVENT_SCOPE_CHANGE = util.toHash(['properties', 'patternProperties', 'enum', 'dependencies', 'definitions']);
805 /* @this Ajv */
806 function getJsonPointer(parsedRef, baseId, schema, root) {
807   /* jshint validthis: true */
808   parsedRef.fragment = parsedRef.fragment || '';
809   if (parsedRef.fragment.slice(0,1) != '/') return;
810   var parts = parsedRef.fragment.split('/');
811
812   for (var i = 1; i < parts.length; i++) {
813     var part = parts[i];
814     if (part) {
815       part = util.unescapeFragment(part);
816       schema = schema[part];
817       if (schema === undefined) break;
818       var id;
819       if (!PREVENT_SCOPE_CHANGE[part]) {
820         id = this._getId(schema);
821         if (id) baseId = resolveUrl(baseId, id);
822         if (schema.$ref) {
823           var $ref = resolveUrl(baseId, schema.$ref);
824           var res = resolveSchema.call(this, root, $ref);
825           if (res) {
826             schema = res.schema;
827             root = res.root;
828             baseId = res.baseId;
829           }
830         }
831       }
832     }
833   }
834   if (schema !== undefined && schema !== root.schema)
835     return { schema: schema, root: root, baseId: baseId };
836 }
837
838
839 var SIMPLE_INLINED = util.toHash([
840   'type', 'format', 'pattern',
841   'maxLength', 'minLength',
842   'maxProperties', 'minProperties',
843   'maxItems', 'minItems',
844   'maximum', 'minimum',
845   'uniqueItems', 'multipleOf',
846   'required', 'enum'
847 ]);
848 function inlineRef(schema, limit) {
849   if (limit === false) return false;
850   if (limit === undefined || limit === true) return checkNoRef(schema);
851   else if (limit) return countKeys(schema) <= limit;
852 }
853
854
855 function checkNoRef(schema) {
856   var item;
857   if (Array.isArray(schema)) {
858     for (var i=0; i<schema.length; i++) {
859       item = schema[i];
860       if (typeof item == 'object' && !checkNoRef(item)) return false;
861     }
862   } else {
863     for (var key in schema) {
864       if (key == '$ref') return false;
865       item = schema[key];
866       if (typeof item == 'object' && !checkNoRef(item)) return false;
867     }
868   }
869   return true;
870 }
871
872
873 function countKeys(schema) {
874   var count = 0, item;
875   if (Array.isArray(schema)) {
876     for (var i=0; i<schema.length; i++) {
877       item = schema[i];
878       if (typeof item == 'object') count += countKeys(item);
879       if (count == Infinity) return Infinity;
880     }
881   } else {
882     for (var key in schema) {
883       if (key == '$ref') return Infinity;
884       if (SIMPLE_INLINED[key]) {
885         count++;
886       } else {
887         item = schema[key];
888         if (typeof item == 'object') count += countKeys(item) + 1;
889         if (count == Infinity) return Infinity;
890       }
891     }
892   }
893   return count;
894 }
895
896
897 function getFullPath(id, normalize) {
898   if (normalize !== false) id = normalizeId(id);
899   var p = URI.parse(id);
900   return _getFullPath(p);
901 }
902
903
904 function _getFullPath(p) {
905   return URI.serialize(p).split('#')[0] + '#';
906 }
907
908
909 var TRAILING_SLASH_HASH = /#\/?$/;
910 function normalizeId(id) {
911   return id ? id.replace(TRAILING_SLASH_HASH, '') : '';
912 }
913
914
915 function resolveUrl(baseId, id) {
916   id = normalizeId(id);
917   return URI.resolve(baseId, id);
918 }
919
920
921 /* @this Ajv */
922 function resolveIds(schema) {
923   var schemaId = normalizeId(this._getId(schema));
924   var baseIds = {'': schemaId};
925   var fullPaths = {'': getFullPath(schemaId, false)};
926   var localRefs = {};
927   var self = this;
928
929   traverse(schema, {allKeys: true}, function(sch, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex) {
930     if (jsonPtr === '') return;
931     var id = self._getId(sch);
932     var baseId = baseIds[parentJsonPtr];
933     var fullPath = fullPaths[parentJsonPtr] + '/' + parentKeyword;
934     if (keyIndex !== undefined)
935       fullPath += '/' + (typeof keyIndex == 'number' ? keyIndex : util.escapeFragment(keyIndex));
936
937     if (typeof id == 'string') {
938       id = baseId = normalizeId(baseId ? URI.resolve(baseId, id) : id);
939
940       var refVal = self._refs[id];
941       if (typeof refVal == 'string') refVal = self._refs[refVal];
942       if (refVal && refVal.schema) {
943         if (!equal(sch, refVal.schema))
944           throw new Error('id "' + id + '" resolves to more than one schema');
945       } else if (id != normalizeId(fullPath)) {
946         if (id[0] == '#') {
947           if (localRefs[id] && !equal(sch, localRefs[id]))
948             throw new Error('id "' + id + '" resolves to more than one schema');
949           localRefs[id] = sch;
950         } else {
951           self._refs[id] = fullPath;
952         }
953       }
954     }
955     baseIds[jsonPtr] = baseId;
956     fullPaths[jsonPtr] = fullPath;
957   });
958
959   return localRefs;
960 }
961
962 },{"./schema_obj":8,"./util":10,"fast-deep-equal":42,"json-schema-traverse":44,"uri-js":45}],7:[function(require,module,exports){
963 'use strict';
964
965 var ruleModules = require('../dotjs')
966   , toHash = require('./util').toHash;
967
968 module.exports = function rules() {
969   var RULES = [
970     { type: 'number',
971       rules: [ { 'maximum': ['exclusiveMaximum'] },
972                { 'minimum': ['exclusiveMinimum'] }, 'multipleOf', 'format'] },
973     { type: 'string',
974       rules: [ 'maxLength', 'minLength', 'pattern', 'format' ] },
975     { type: 'array',
976       rules: [ 'maxItems', 'minItems', 'items', 'contains', 'uniqueItems' ] },
977     { type: 'object',
978       rules: [ 'maxProperties', 'minProperties', 'required', 'dependencies', 'propertyNames',
979                { 'properties': ['additionalProperties', 'patternProperties'] } ] },
980     { rules: [ '$ref', 'const', 'enum', 'not', 'anyOf', 'oneOf', 'allOf', 'if' ] }
981   ];
982
983   var ALL = [ 'type', '$comment' ];
984   var KEYWORDS = [
985     '$schema', '$id', 'id', '$data', '$async', 'title',
986     'description', 'default', 'definitions',
987     'examples', 'readOnly', 'writeOnly',
988     'contentMediaType', 'contentEncoding',
989     'additionalItems', 'then', 'else'
990   ];
991   var TYPES = [ 'number', 'integer', 'string', 'array', 'object', 'boolean', 'null' ];
992   RULES.all = toHash(ALL);
993   RULES.types = toHash(TYPES);
994
995   RULES.forEach(function (group) {
996     group.rules = group.rules.map(function (keyword) {
997       var implKeywords;
998       if (typeof keyword == 'object') {
999         var key = Object.keys(keyword)[0];
1000         implKeywords = keyword[key];
1001         keyword = key;
1002         implKeywords.forEach(function (k) {
1003           ALL.push(k);
1004           RULES.all[k] = true;
1005         });
1006       }
1007       ALL.push(keyword);
1008       var rule = RULES.all[keyword] = {
1009         keyword: keyword,
1010         code: ruleModules[keyword],
1011         implements: implKeywords
1012       };
1013       return rule;
1014     });
1015
1016     RULES.all.$comment = {
1017       keyword: '$comment',
1018       code: ruleModules.$comment
1019     };
1020
1021     if (group.type) RULES.types[group.type] = group;
1022   });
1023
1024   RULES.keywords = toHash(ALL.concat(KEYWORDS));
1025   RULES.custom = {};
1026
1027   return RULES;
1028 };
1029
1030 },{"../dotjs":27,"./util":10}],8:[function(require,module,exports){
1031 'use strict';
1032
1033 var util = require('./util');
1034
1035 module.exports = SchemaObject;
1036
1037 function SchemaObject(obj) {
1038   util.copy(obj, this);
1039 }
1040
1041 },{"./util":10}],9:[function(require,module,exports){
1042 'use strict';
1043
1044 // https://mathiasbynens.be/notes/javascript-encoding
1045 // https://github.com/bestiejs/punycode.js - punycode.ucs2.decode
1046 module.exports = function ucs2length(str) {
1047   var length = 0
1048     , len = str.length
1049     , pos = 0
1050     , value;
1051   while (pos < len) {
1052     length++;
1053     value = str.charCodeAt(pos++);
1054     if (value >= 0xD800 && value <= 0xDBFF && pos < len) {
1055       // high surrogate, and there is a next character
1056       value = str.charCodeAt(pos);
1057       if ((value & 0xFC00) == 0xDC00) pos++; // low surrogate
1058     }
1059   }
1060   return length;
1061 };
1062
1063 },{}],10:[function(require,module,exports){
1064 'use strict';
1065
1066
1067 module.exports = {
1068   copy: copy,
1069   checkDataType: checkDataType,
1070   checkDataTypes: checkDataTypes,
1071   coerceToTypes: coerceToTypes,
1072   toHash: toHash,
1073   getProperty: getProperty,
1074   escapeQuotes: escapeQuotes,
1075   equal: require('fast-deep-equal'),
1076   ucs2length: require('./ucs2length'),
1077   varOccurences: varOccurences,
1078   varReplace: varReplace,
1079   schemaHasRules: schemaHasRules,
1080   schemaHasRulesExcept: schemaHasRulesExcept,
1081   schemaUnknownRules: schemaUnknownRules,
1082   toQuotedString: toQuotedString,
1083   getPathExpr: getPathExpr,
1084   getPath: getPath,
1085   getData: getData,
1086   unescapeFragment: unescapeFragment,
1087   unescapeJsonPointer: unescapeJsonPointer,
1088   escapeFragment: escapeFragment,
1089   escapeJsonPointer: escapeJsonPointer
1090 };
1091
1092
1093 function copy(o, to) {
1094   to = to || {};
1095   for (var key in o) to[key] = o[key];
1096   return to;
1097 }
1098
1099
1100 function checkDataType(dataType, data, strictNumbers, negate) {
1101   var EQUAL = negate ? ' !== ' : ' === '
1102     , AND = negate ? ' || ' : ' && '
1103     , OK = negate ? '!' : ''
1104     , NOT = negate ? '' : '!';
1105   switch (dataType) {
1106     case 'null': return data + EQUAL + 'null';
1107     case 'array': return OK + 'Array.isArray(' + data + ')';
1108     case 'object': return '(' + OK + data + AND +
1109                           'typeof ' + data + EQUAL + '"object"' + AND +
1110                           NOT + 'Array.isArray(' + data + '))';
1111     case 'integer': return '(typeof ' + data + EQUAL + '"number"' + AND +
1112                            NOT + '(' + data + ' % 1)' +
1113                            AND + data + EQUAL + data +
1114                            (strictNumbers ? (AND + OK + 'isFinite(' + data + ')') : '') + ')';
1115     case 'number': return '(typeof ' + data + EQUAL + '"' + dataType + '"' +
1116                           (strictNumbers ? (AND + OK + 'isFinite(' + data + ')') : '') + ')';
1117     default: return 'typeof ' + data + EQUAL + '"' + dataType + '"';
1118   }
1119 }
1120
1121
1122 function checkDataTypes(dataTypes, data, strictNumbers) {
1123   switch (dataTypes.length) {
1124     case 1: return checkDataType(dataTypes[0], data, strictNumbers, true);
1125     default:
1126       var code = '';
1127       var types = toHash(dataTypes);
1128       if (types.array && types.object) {
1129         code = types.null ? '(': '(!' + data + ' || ';
1130         code += 'typeof ' + data + ' !== "object")';
1131         delete types.null;
1132         delete types.array;
1133         delete types.object;
1134       }
1135       if (types.number) delete types.integer;
1136       for (var t in types)
1137         code += (code ? ' && ' : '' ) + checkDataType(t, data, strictNumbers, true);
1138
1139       return code;
1140   }
1141 }
1142
1143
1144 var COERCE_TO_TYPES = toHash([ 'string', 'number', 'integer', 'boolean', 'null' ]);
1145 function coerceToTypes(optionCoerceTypes, dataTypes) {
1146   if (Array.isArray(dataTypes)) {
1147     var types = [];
1148     for (var i=0; i<dataTypes.length; i++) {
1149       var t = dataTypes[i];
1150       if (COERCE_TO_TYPES[t]) types[types.length] = t;
1151       else if (optionCoerceTypes === 'array' && t === 'array') types[types.length] = t;
1152     }
1153     if (types.length) return types;
1154   } else if (COERCE_TO_TYPES[dataTypes]) {
1155     return [dataTypes];
1156   } else if (optionCoerceTypes === 'array' && dataTypes === 'array') {
1157     return ['array'];
1158   }
1159 }
1160
1161
1162 function toHash(arr) {
1163   var hash = {};
1164   for (var i=0; i<arr.length; i++) hash[arr[i]] = true;
1165   return hash;
1166 }
1167
1168
1169 var IDENTIFIER = /^[a-z$_][a-z$_0-9]*$/i;
1170 var SINGLE_QUOTE = /'|\\/g;
1171 function getProperty(key) {
1172   return typeof key == 'number'
1173           ? '[' + key + ']'
1174           : IDENTIFIER.test(key)
1175             ? '.' + key
1176             : "['" + escapeQuotes(key) + "']";
1177 }
1178
1179
1180 function escapeQuotes(str) {
1181   return str.replace(SINGLE_QUOTE, '\\$&')
1182             .replace(/\n/g, '\\n')
1183             .replace(/\r/g, '\\r')
1184             .replace(/\f/g, '\\f')
1185             .replace(/\t/g, '\\t');
1186 }
1187
1188
1189 function varOccurences(str, dataVar) {
1190   dataVar += '[^0-9]';
1191   var matches = str.match(new RegExp(dataVar, 'g'));
1192   return matches ? matches.length : 0;
1193 }
1194
1195
1196 function varReplace(str, dataVar, expr) {
1197   dataVar += '([^0-9])';
1198   expr = expr.replace(/\$/g, '$$$$');
1199   return str.replace(new RegExp(dataVar, 'g'), expr + '$1');
1200 }
1201
1202
1203 function schemaHasRules(schema, rules) {
1204   if (typeof schema == 'boolean') return !schema;
1205   for (var key in schema) if (rules[key]) return true;
1206 }
1207
1208
1209 function schemaHasRulesExcept(schema, rules, exceptKeyword) {
1210   if (typeof schema == 'boolean') return !schema && exceptKeyword != 'not';
1211   for (var key in schema) if (key != exceptKeyword && rules[key]) return true;
1212 }
1213
1214
1215 function schemaUnknownRules(schema, rules) {
1216   if (typeof schema == 'boolean') return;
1217   for (var key in schema) if (!rules[key]) return key;
1218 }
1219
1220
1221 function toQuotedString(str) {
1222   return '\'' + escapeQuotes(str) + '\'';
1223 }
1224
1225
1226 function getPathExpr(currentPath, expr, jsonPointers, isNumber) {
1227   var path = jsonPointers // false by default
1228               ? '\'/\' + ' + expr + (isNumber ? '' : '.replace(/~/g, \'~0\').replace(/\\//g, \'~1\')')
1229               : (isNumber ? '\'[\' + ' + expr + ' + \']\'' : '\'[\\\'\' + ' + expr + ' + \'\\\']\'');
1230   return joinPaths(currentPath, path);
1231 }
1232
1233
1234 function getPath(currentPath, prop, jsonPointers) {
1235   var path = jsonPointers // false by default
1236               ? toQuotedString('/' + escapeJsonPointer(prop))
1237               : toQuotedString(getProperty(prop));
1238   return joinPaths(currentPath, path);
1239 }
1240
1241
1242 var JSON_POINTER = /^\/(?:[^~]|~0|~1)*$/;
1243 var RELATIVE_JSON_POINTER = /^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;
1244 function getData($data, lvl, paths) {
1245   var up, jsonPointer, data, matches;
1246   if ($data === '') return 'rootData';
1247   if ($data[0] == '/') {
1248     if (!JSON_POINTER.test($data)) throw new Error('Invalid JSON-pointer: ' + $data);
1249     jsonPointer = $data;
1250     data = 'rootData';
1251   } else {
1252     matches = $data.match(RELATIVE_JSON_POINTER);
1253     if (!matches) throw new Error('Invalid JSON-pointer: ' + $data);
1254     up = +matches[1];
1255     jsonPointer = matches[2];
1256     if (jsonPointer == '#') {
1257       if (up >= lvl) throw new Error('Cannot access property/index ' + up + ' levels up, current level is ' + lvl);
1258       return paths[lvl - up];
1259     }
1260
1261     if (up > lvl) throw new Error('Cannot access data ' + up + ' levels up, current level is ' + lvl);
1262     data = 'data' + ((lvl - up) || '');
1263     if (!jsonPointer) return data;
1264   }
1265
1266   var expr = data;
1267   var segments = jsonPointer.split('/');
1268   for (var i=0; i<segments.length; i++) {
1269     var segment = segments[i];
1270     if (segment) {
1271       data += getProperty(unescapeJsonPointer(segment));
1272       expr += ' && ' + data;
1273     }
1274   }
1275   return expr;
1276 }
1277
1278
1279 function joinPaths (a, b) {
1280   if (a == '""') return b;
1281   return (a + ' + ' + b).replace(/([^\\])' \+ '/g, '$1');
1282 }
1283
1284
1285 function unescapeFragment(str) {
1286   return unescapeJsonPointer(decodeURIComponent(str));
1287 }
1288
1289
1290 function escapeFragment(str) {
1291   return encodeURIComponent(escapeJsonPointer(str));
1292 }
1293
1294
1295 function escapeJsonPointer(str) {
1296   return str.replace(/~/g, '~0').replace(/\//g, '~1');
1297 }
1298
1299
1300 function unescapeJsonPointer(str) {
1301   return str.replace(/~1/g, '/').replace(/~0/g, '~');
1302 }
1303
1304 },{"./ucs2length":9,"fast-deep-equal":42}],11:[function(require,module,exports){
1305 'use strict';
1306
1307 var KEYWORDS = [
1308   'multipleOf',
1309   'maximum',
1310   'exclusiveMaximum',
1311   'minimum',
1312   'exclusiveMinimum',
1313   'maxLength',
1314   'minLength',
1315   'pattern',
1316   'additionalItems',
1317   'maxItems',
1318   'minItems',
1319   'uniqueItems',
1320   'maxProperties',
1321   'minProperties',
1322   'required',
1323   'additionalProperties',
1324   'enum',
1325   'format',
1326   'const'
1327 ];
1328
1329 module.exports = function (metaSchema, keywordsJsonPointers) {
1330   for (var i=0; i<keywordsJsonPointers.length; i++) {
1331     metaSchema = JSON.parse(JSON.stringify(metaSchema));
1332     var segments = keywordsJsonPointers[i].split('/');
1333     var keywords = metaSchema;
1334     var j;
1335     for (j=1; j<segments.length; j++)
1336       keywords = keywords[segments[j]];
1337
1338     for (j=0; j<KEYWORDS.length; j++) {
1339       var key = KEYWORDS[j];
1340       var schema = keywords[key];
1341       if (schema) {
1342         keywords[key] = {
1343           anyOf: [
1344             schema,
1345             { $ref: 'https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#' }
1346           ]
1347         };
1348       }
1349     }
1350   }
1351
1352   return metaSchema;
1353 };
1354
1355 },{}],12:[function(require,module,exports){
1356 'use strict';
1357
1358 var metaSchema = require('./refs/json-schema-draft-07.json');
1359
1360 module.exports = {
1361   $id: 'https://github.com/ajv-validator/ajv/blob/master/lib/definition_schema.js',
1362   definitions: {
1363     simpleTypes: metaSchema.definitions.simpleTypes
1364   },
1365   type: 'object',
1366   dependencies: {
1367     schema: ['validate'],
1368     $data: ['validate'],
1369     statements: ['inline'],
1370     valid: {not: {required: ['macro']}}
1371   },
1372   properties: {
1373     type: metaSchema.properties.type,
1374     schema: {type: 'boolean'},
1375     statements: {type: 'boolean'},
1376     dependencies: {
1377       type: 'array',
1378       items: {type: 'string'}
1379     },
1380     metaSchema: {type: 'object'},
1381     modifying: {type: 'boolean'},
1382     valid: {type: 'boolean'},
1383     $data: {type: 'boolean'},
1384     async: {type: 'boolean'},
1385     errors: {
1386       anyOf: [
1387         {type: 'boolean'},
1388         {const: 'full'}
1389       ]
1390     }
1391   }
1392 };
1393
1394 },{"./refs/json-schema-draft-07.json":41}],13:[function(require,module,exports){
1395 'use strict';
1396 module.exports = function generate__limit(it, $keyword, $ruleType) {
1397   var out = ' ';
1398   var $lvl = it.level;
1399   var $dataLvl = it.dataLevel;
1400   var $schema = it.schema[$keyword];
1401   var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
1402   var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
1403   var $breakOnError = !it.opts.allErrors;
1404   var $errorKeyword;
1405   var $data = 'data' + ($dataLvl || '');
1406   var $isData = it.opts.$data && $schema && $schema.$data,
1407     $schemaValue;
1408   if ($isData) {
1409     out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; ';
1410     $schemaValue = 'schema' + $lvl;
1411   } else {
1412     $schemaValue = $schema;
1413   }
1414   var $isMax = $keyword == 'maximum',
1415     $exclusiveKeyword = $isMax ? 'exclusiveMaximum' : 'exclusiveMinimum',
1416     $schemaExcl = it.schema[$exclusiveKeyword],
1417     $isDataExcl = it.opts.$data && $schemaExcl && $schemaExcl.$data,
1418     $op = $isMax ? '<' : '>',
1419     $notOp = $isMax ? '>' : '<',
1420     $errorKeyword = undefined;
1421   if (!($isData || typeof $schema == 'number' || $schema === undefined)) {
1422     throw new Error($keyword + ' must be number');
1423   }
1424   if (!($isDataExcl || $schemaExcl === undefined || typeof $schemaExcl == 'number' || typeof $schemaExcl == 'boolean')) {
1425     throw new Error($exclusiveKeyword + ' must be number or boolean');
1426   }
1427   if ($isDataExcl) {
1428     var $schemaValueExcl = it.util.getData($schemaExcl.$data, $dataLvl, it.dataPathArr),
1429       $exclusive = 'exclusive' + $lvl,
1430       $exclType = 'exclType' + $lvl,
1431       $exclIsNumber = 'exclIsNumber' + $lvl,
1432       $opExpr = 'op' + $lvl,
1433       $opStr = '\' + ' + $opExpr + ' + \'';
1434     out += ' var schemaExcl' + ($lvl) + ' = ' + ($schemaValueExcl) + '; ';
1435     $schemaValueExcl = 'schemaExcl' + $lvl;
1436     out += ' var ' + ($exclusive) + '; var ' + ($exclType) + ' = typeof ' + ($schemaValueExcl) + '; if (' + ($exclType) + ' != \'boolean\' && ' + ($exclType) + ' != \'undefined\' && ' + ($exclType) + ' != \'number\') { ';
1437     var $errorKeyword = $exclusiveKeyword;
1438     var $$outStack = $$outStack || [];
1439     $$outStack.push(out);
1440     out = ''; /* istanbul ignore else */
1441     if (it.createErrors !== false) {
1442       out += ' { keyword: \'' + ($errorKeyword || '_exclusiveLimit') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: {} ';
1443       if (it.opts.messages !== false) {
1444         out += ' , message: \'' + ($exclusiveKeyword) + ' should be boolean\' ';
1445       }
1446       if (it.opts.verbose) {
1447         out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
1448       }
1449       out += ' } ';
1450     } else {
1451       out += ' {} ';
1452     }
1453     var __err = out;
1454     out = $$outStack.pop();
1455     if (!it.compositeRule && $breakOnError) {
1456       /* istanbul ignore if */
1457       if (it.async) {
1458         out += ' throw new ValidationError([' + (__err) + ']); ';
1459       } else {
1460         out += ' validate.errors = [' + (__err) + ']; return false; ';
1461       }
1462     } else {
1463       out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
1464     }
1465     out += ' } else if ( ';
1466     if ($isData) {
1467       out += ' (' + ($schemaValue) + ' !== undefined && typeof ' + ($schemaValue) + ' != \'number\') || ';
1468     }
1469     out += ' ' + ($exclType) + ' == \'number\' ? ( (' + ($exclusive) + ' = ' + ($schemaValue) + ' === undefined || ' + ($schemaValueExcl) + ' ' + ($op) + '= ' + ($schemaValue) + ') ? ' + ($data) + ' ' + ($notOp) + '= ' + ($schemaValueExcl) + ' : ' + ($data) + ' ' + ($notOp) + ' ' + ($schemaValue) + ' ) : ( (' + ($exclusive) + ' = ' + ($schemaValueExcl) + ' === true) ? ' + ($data) + ' ' + ($notOp) + '= ' + ($schemaValue) + ' : ' + ($data) + ' ' + ($notOp) + ' ' + ($schemaValue) + ' ) || ' + ($data) + ' !== ' + ($data) + ') { var op' + ($lvl) + ' = ' + ($exclusive) + ' ? \'' + ($op) + '\' : \'' + ($op) + '=\'; ';
1470     if ($schema === undefined) {
1471       $errorKeyword = $exclusiveKeyword;
1472       $errSchemaPath = it.errSchemaPath + '/' + $exclusiveKeyword;
1473       $schemaValue = $schemaValueExcl;
1474       $isData = $isDataExcl;
1475     }
1476   } else {
1477     var $exclIsNumber = typeof $schemaExcl == 'number',
1478       $opStr = $op;
1479     if ($exclIsNumber && $isData) {
1480       var $opExpr = '\'' + $opStr + '\'';
1481       out += ' if ( ';
1482       if ($isData) {
1483         out += ' (' + ($schemaValue) + ' !== undefined && typeof ' + ($schemaValue) + ' != \'number\') || ';
1484       }
1485       out += ' ( ' + ($schemaValue) + ' === undefined || ' + ($schemaExcl) + ' ' + ($op) + '= ' + ($schemaValue) + ' ? ' + ($data) + ' ' + ($notOp) + '= ' + ($schemaExcl) + ' : ' + ($data) + ' ' + ($notOp) + ' ' + ($schemaValue) + ' ) || ' + ($data) + ' !== ' + ($data) + ') { ';
1486     } else {
1487       if ($exclIsNumber && $schema === undefined) {
1488         $exclusive = true;
1489         $errorKeyword = $exclusiveKeyword;
1490         $errSchemaPath = it.errSchemaPath + '/' + $exclusiveKeyword;
1491         $schemaValue = $schemaExcl;
1492         $notOp += '=';
1493       } else {
1494         if ($exclIsNumber) $schemaValue = Math[$isMax ? 'min' : 'max']($schemaExcl, $schema);
1495         if ($schemaExcl === ($exclIsNumber ? $schemaValue : true)) {
1496           $exclusive = true;
1497           $errorKeyword = $exclusiveKeyword;
1498           $errSchemaPath = it.errSchemaPath + '/' + $exclusiveKeyword;
1499           $notOp += '=';
1500         } else {
1501           $exclusive = false;
1502           $opStr += '=';
1503         }
1504       }
1505       var $opExpr = '\'' + $opStr + '\'';
1506       out += ' if ( ';
1507       if ($isData) {
1508         out += ' (' + ($schemaValue) + ' !== undefined && typeof ' + ($schemaValue) + ' != \'number\') || ';
1509       }
1510       out += ' ' + ($data) + ' ' + ($notOp) + ' ' + ($schemaValue) + ' || ' + ($data) + ' !== ' + ($data) + ') { ';
1511     }
1512   }
1513   $errorKeyword = $errorKeyword || $keyword;
1514   var $$outStack = $$outStack || [];
1515   $$outStack.push(out);
1516   out = ''; /* istanbul ignore else */
1517   if (it.createErrors !== false) {
1518     out += ' { keyword: \'' + ($errorKeyword || '_limit') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { comparison: ' + ($opExpr) + ', limit: ' + ($schemaValue) + ', exclusive: ' + ($exclusive) + ' } ';
1519     if (it.opts.messages !== false) {
1520       out += ' , message: \'should be ' + ($opStr) + ' ';
1521       if ($isData) {
1522         out += '\' + ' + ($schemaValue);
1523       } else {
1524         out += '' + ($schemaValue) + '\'';
1525       }
1526     }
1527     if (it.opts.verbose) {
1528       out += ' , schema:  ';
1529       if ($isData) {
1530         out += 'validate.schema' + ($schemaPath);
1531       } else {
1532         out += '' + ($schema);
1533       }
1534       out += '         , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
1535     }
1536     out += ' } ';
1537   } else {
1538     out += ' {} ';
1539   }
1540   var __err = out;
1541   out = $$outStack.pop();
1542   if (!it.compositeRule && $breakOnError) {
1543     /* istanbul ignore if */
1544     if (it.async) {
1545       out += ' throw new ValidationError([' + (__err) + ']); ';
1546     } else {
1547       out += ' validate.errors = [' + (__err) + ']; return false; ';
1548     }
1549   } else {
1550     out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
1551   }
1552   out += ' } ';
1553   if ($breakOnError) {
1554     out += ' else { ';
1555   }
1556   return out;
1557 }
1558
1559 },{}],14:[function(require,module,exports){
1560 'use strict';
1561 module.exports = function generate__limitItems(it, $keyword, $ruleType) {
1562   var out = ' ';
1563   var $lvl = it.level;
1564   var $dataLvl = it.dataLevel;
1565   var $schema = it.schema[$keyword];
1566   var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
1567   var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
1568   var $breakOnError = !it.opts.allErrors;
1569   var $errorKeyword;
1570   var $data = 'data' + ($dataLvl || '');
1571   var $isData = it.opts.$data && $schema && $schema.$data,
1572     $schemaValue;
1573   if ($isData) {
1574     out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; ';
1575     $schemaValue = 'schema' + $lvl;
1576   } else {
1577     $schemaValue = $schema;
1578   }
1579   if (!($isData || typeof $schema == 'number')) {
1580     throw new Error($keyword + ' must be number');
1581   }
1582   var $op = $keyword == 'maxItems' ? '>' : '<';
1583   out += 'if ( ';
1584   if ($isData) {
1585     out += ' (' + ($schemaValue) + ' !== undefined && typeof ' + ($schemaValue) + ' != \'number\') || ';
1586   }
1587   out += ' ' + ($data) + '.length ' + ($op) + ' ' + ($schemaValue) + ') { ';
1588   var $errorKeyword = $keyword;
1589   var $$outStack = $$outStack || [];
1590   $$outStack.push(out);
1591   out = ''; /* istanbul ignore else */
1592   if (it.createErrors !== false) {
1593     out += ' { keyword: \'' + ($errorKeyword || '_limitItems') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { limit: ' + ($schemaValue) + ' } ';
1594     if (it.opts.messages !== false) {
1595       out += ' , message: \'should NOT have ';
1596       if ($keyword == 'maxItems') {
1597         out += 'more';
1598       } else {
1599         out += 'fewer';
1600       }
1601       out += ' than ';
1602       if ($isData) {
1603         out += '\' + ' + ($schemaValue) + ' + \'';
1604       } else {
1605         out += '' + ($schema);
1606       }
1607       out += ' items\' ';
1608     }
1609     if (it.opts.verbose) {
1610       out += ' , schema:  ';
1611       if ($isData) {
1612         out += 'validate.schema' + ($schemaPath);
1613       } else {
1614         out += '' + ($schema);
1615       }
1616       out += '         , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
1617     }
1618     out += ' } ';
1619   } else {
1620     out += ' {} ';
1621   }
1622   var __err = out;
1623   out = $$outStack.pop();
1624   if (!it.compositeRule && $breakOnError) {
1625     /* istanbul ignore if */
1626     if (it.async) {
1627       out += ' throw new ValidationError([' + (__err) + ']); ';
1628     } else {
1629       out += ' validate.errors = [' + (__err) + ']; return false; ';
1630     }
1631   } else {
1632     out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
1633   }
1634   out += '} ';
1635   if ($breakOnError) {
1636     out += ' else { ';
1637   }
1638   return out;
1639 }
1640
1641 },{}],15:[function(require,module,exports){
1642 'use strict';
1643 module.exports = function generate__limitLength(it, $keyword, $ruleType) {
1644   var out = ' ';
1645   var $lvl = it.level;
1646   var $dataLvl = it.dataLevel;
1647   var $schema = it.schema[$keyword];
1648   var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
1649   var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
1650   var $breakOnError = !it.opts.allErrors;
1651   var $errorKeyword;
1652   var $data = 'data' + ($dataLvl || '');
1653   var $isData = it.opts.$data && $schema && $schema.$data,
1654     $schemaValue;
1655   if ($isData) {
1656     out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; ';
1657     $schemaValue = 'schema' + $lvl;
1658   } else {
1659     $schemaValue = $schema;
1660   }
1661   if (!($isData || typeof $schema == 'number')) {
1662     throw new Error($keyword + ' must be number');
1663   }
1664   var $op = $keyword == 'maxLength' ? '>' : '<';
1665   out += 'if ( ';
1666   if ($isData) {
1667     out += ' (' + ($schemaValue) + ' !== undefined && typeof ' + ($schemaValue) + ' != \'number\') || ';
1668   }
1669   if (it.opts.unicode === false) {
1670     out += ' ' + ($data) + '.length ';
1671   } else {
1672     out += ' ucs2length(' + ($data) + ') ';
1673   }
1674   out += ' ' + ($op) + ' ' + ($schemaValue) + ') { ';
1675   var $errorKeyword = $keyword;
1676   var $$outStack = $$outStack || [];
1677   $$outStack.push(out);
1678   out = ''; /* istanbul ignore else */
1679   if (it.createErrors !== false) {
1680     out += ' { keyword: \'' + ($errorKeyword || '_limitLength') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { limit: ' + ($schemaValue) + ' } ';
1681     if (it.opts.messages !== false) {
1682       out += ' , message: \'should NOT be ';
1683       if ($keyword == 'maxLength') {
1684         out += 'longer';
1685       } else {
1686         out += 'shorter';
1687       }
1688       out += ' than ';
1689       if ($isData) {
1690         out += '\' + ' + ($schemaValue) + ' + \'';
1691       } else {
1692         out += '' + ($schema);
1693       }
1694       out += ' characters\' ';
1695     }
1696     if (it.opts.verbose) {
1697       out += ' , schema:  ';
1698       if ($isData) {
1699         out += 'validate.schema' + ($schemaPath);
1700       } else {
1701         out += '' + ($schema);
1702       }
1703       out += '         , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
1704     }
1705     out += ' } ';
1706   } else {
1707     out += ' {} ';
1708   }
1709   var __err = out;
1710   out = $$outStack.pop();
1711   if (!it.compositeRule && $breakOnError) {
1712     /* istanbul ignore if */
1713     if (it.async) {
1714       out += ' throw new ValidationError([' + (__err) + ']); ';
1715     } else {
1716       out += ' validate.errors = [' + (__err) + ']; return false; ';
1717     }
1718   } else {
1719     out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
1720   }
1721   out += '} ';
1722   if ($breakOnError) {
1723     out += ' else { ';
1724   }
1725   return out;
1726 }
1727
1728 },{}],16:[function(require,module,exports){
1729 'use strict';
1730 module.exports = function generate__limitProperties(it, $keyword, $ruleType) {
1731   var out = ' ';
1732   var $lvl = it.level;
1733   var $dataLvl = it.dataLevel;
1734   var $schema = it.schema[$keyword];
1735   var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
1736   var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
1737   var $breakOnError = !it.opts.allErrors;
1738   var $errorKeyword;
1739   var $data = 'data' + ($dataLvl || '');
1740   var $isData = it.opts.$data && $schema && $schema.$data,
1741     $schemaValue;
1742   if ($isData) {
1743     out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; ';
1744     $schemaValue = 'schema' + $lvl;
1745   } else {
1746     $schemaValue = $schema;
1747   }
1748   if (!($isData || typeof $schema == 'number')) {
1749     throw new Error($keyword + ' must be number');
1750   }
1751   var $op = $keyword == 'maxProperties' ? '>' : '<';
1752   out += 'if ( ';
1753   if ($isData) {
1754     out += ' (' + ($schemaValue) + ' !== undefined && typeof ' + ($schemaValue) + ' != \'number\') || ';
1755   }
1756   out += ' Object.keys(' + ($data) + ').length ' + ($op) + ' ' + ($schemaValue) + ') { ';
1757   var $errorKeyword = $keyword;
1758   var $$outStack = $$outStack || [];
1759   $$outStack.push(out);
1760   out = ''; /* istanbul ignore else */
1761   if (it.createErrors !== false) {
1762     out += ' { keyword: \'' + ($errorKeyword || '_limitProperties') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { limit: ' + ($schemaValue) + ' } ';
1763     if (it.opts.messages !== false) {
1764       out += ' , message: \'should NOT have ';
1765       if ($keyword == 'maxProperties') {
1766         out += 'more';
1767       } else {
1768         out += 'fewer';
1769       }
1770       out += ' than ';
1771       if ($isData) {
1772         out += '\' + ' + ($schemaValue) + ' + \'';
1773       } else {
1774         out += '' + ($schema);
1775       }
1776       out += ' properties\' ';
1777     }
1778     if (it.opts.verbose) {
1779       out += ' , schema:  ';
1780       if ($isData) {
1781         out += 'validate.schema' + ($schemaPath);
1782       } else {
1783         out += '' + ($schema);
1784       }
1785       out += '         , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
1786     }
1787     out += ' } ';
1788   } else {
1789     out += ' {} ';
1790   }
1791   var __err = out;
1792   out = $$outStack.pop();
1793   if (!it.compositeRule && $breakOnError) {
1794     /* istanbul ignore if */
1795     if (it.async) {
1796       out += ' throw new ValidationError([' + (__err) + ']); ';
1797     } else {
1798       out += ' validate.errors = [' + (__err) + ']; return false; ';
1799     }
1800   } else {
1801     out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
1802   }
1803   out += '} ';
1804   if ($breakOnError) {
1805     out += ' else { ';
1806   }
1807   return out;
1808 }
1809
1810 },{}],17:[function(require,module,exports){
1811 'use strict';
1812 module.exports = function generate_allOf(it, $keyword, $ruleType) {
1813   var out = ' ';
1814   var $schema = it.schema[$keyword];
1815   var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
1816   var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
1817   var $breakOnError = !it.opts.allErrors;
1818   var $it = it.util.copy(it);
1819   var $closingBraces = '';
1820   $it.level++;
1821   var $nextValid = 'valid' + $it.level;
1822   var $currentBaseId = $it.baseId,
1823     $allSchemasEmpty = true;
1824   var arr1 = $schema;
1825   if (arr1) {
1826     var $sch, $i = -1,
1827       l1 = arr1.length - 1;
1828     while ($i < l1) {
1829       $sch = arr1[$i += 1];
1830       if ((it.opts.strictKeywords ? typeof $sch == 'object' && Object.keys($sch).length > 0 : it.util.schemaHasRules($sch, it.RULES.all))) {
1831         $allSchemasEmpty = false;
1832         $it.schema = $sch;
1833         $it.schemaPath = $schemaPath + '[' + $i + ']';
1834         $it.errSchemaPath = $errSchemaPath + '/' + $i;
1835         out += '  ' + (it.validate($it)) + ' ';
1836         $it.baseId = $currentBaseId;
1837         if ($breakOnError) {
1838           out += ' if (' + ($nextValid) + ') { ';
1839           $closingBraces += '}';
1840         }
1841       }
1842     }
1843   }
1844   if ($breakOnError) {
1845     if ($allSchemasEmpty) {
1846       out += ' if (true) { ';
1847     } else {
1848       out += ' ' + ($closingBraces.slice(0, -1)) + ' ';
1849     }
1850   }
1851   return out;
1852 }
1853
1854 },{}],18:[function(require,module,exports){
1855 'use strict';
1856 module.exports = function generate_anyOf(it, $keyword, $ruleType) {
1857   var out = ' ';
1858   var $lvl = it.level;
1859   var $dataLvl = it.dataLevel;
1860   var $schema = it.schema[$keyword];
1861   var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
1862   var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
1863   var $breakOnError = !it.opts.allErrors;
1864   var $data = 'data' + ($dataLvl || '');
1865   var $valid = 'valid' + $lvl;
1866   var $errs = 'errs__' + $lvl;
1867   var $it = it.util.copy(it);
1868   var $closingBraces = '';
1869   $it.level++;
1870   var $nextValid = 'valid' + $it.level;
1871   var $noEmptySchema = $schema.every(function($sch) {
1872     return (it.opts.strictKeywords ? typeof $sch == 'object' && Object.keys($sch).length > 0 : it.util.schemaHasRules($sch, it.RULES.all));
1873   });
1874   if ($noEmptySchema) {
1875     var $currentBaseId = $it.baseId;
1876     out += ' var ' + ($errs) + ' = errors; var ' + ($valid) + ' = false;  ';
1877     var $wasComposite = it.compositeRule;
1878     it.compositeRule = $it.compositeRule = true;
1879     var arr1 = $schema;
1880     if (arr1) {
1881       var $sch, $i = -1,
1882         l1 = arr1.length - 1;
1883       while ($i < l1) {
1884         $sch = arr1[$i += 1];
1885         $it.schema = $sch;
1886         $it.schemaPath = $schemaPath + '[' + $i + ']';
1887         $it.errSchemaPath = $errSchemaPath + '/' + $i;
1888         out += '  ' + (it.validate($it)) + ' ';
1889         $it.baseId = $currentBaseId;
1890         out += ' ' + ($valid) + ' = ' + ($valid) + ' || ' + ($nextValid) + '; if (!' + ($valid) + ') { ';
1891         $closingBraces += '}';
1892       }
1893     }
1894     it.compositeRule = $it.compositeRule = $wasComposite;
1895     out += ' ' + ($closingBraces) + ' if (!' + ($valid) + ') {   var err =   '; /* istanbul ignore else */
1896     if (it.createErrors !== false) {
1897       out += ' { keyword: \'' + ('anyOf') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: {} ';
1898       if (it.opts.messages !== false) {
1899         out += ' , message: \'should match some schema in anyOf\' ';
1900       }
1901       if (it.opts.verbose) {
1902         out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
1903       }
1904       out += ' } ';
1905     } else {
1906       out += ' {} ';
1907     }
1908     out += ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
1909     if (!it.compositeRule && $breakOnError) {
1910       /* istanbul ignore if */
1911       if (it.async) {
1912         out += ' throw new ValidationError(vErrors); ';
1913       } else {
1914         out += ' validate.errors = vErrors; return false; ';
1915       }
1916     }
1917     out += ' } else {  errors = ' + ($errs) + '; if (vErrors !== null) { if (' + ($errs) + ') vErrors.length = ' + ($errs) + '; else vErrors = null; } ';
1918     if (it.opts.allErrors) {
1919       out += ' } ';
1920     }
1921   } else {
1922     if ($breakOnError) {
1923       out += ' if (true) { ';
1924     }
1925   }
1926   return out;
1927 }
1928
1929 },{}],19:[function(require,module,exports){
1930 'use strict';
1931 module.exports = function generate_comment(it, $keyword, $ruleType) {
1932   var out = ' ';
1933   var $schema = it.schema[$keyword];
1934   var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
1935   var $breakOnError = !it.opts.allErrors;
1936   var $comment = it.util.toQuotedString($schema);
1937   if (it.opts.$comment === true) {
1938     out += ' console.log(' + ($comment) + ');';
1939   } else if (typeof it.opts.$comment == 'function') {
1940     out += ' self._opts.$comment(' + ($comment) + ', ' + (it.util.toQuotedString($errSchemaPath)) + ', validate.root.schema);';
1941   }
1942   return out;
1943 }
1944
1945 },{}],20:[function(require,module,exports){
1946 'use strict';
1947 module.exports = function generate_const(it, $keyword, $ruleType) {
1948   var out = ' ';
1949   var $lvl = it.level;
1950   var $dataLvl = it.dataLevel;
1951   var $schema = it.schema[$keyword];
1952   var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
1953   var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
1954   var $breakOnError = !it.opts.allErrors;
1955   var $data = 'data' + ($dataLvl || '');
1956   var $valid = 'valid' + $lvl;
1957   var $isData = it.opts.$data && $schema && $schema.$data,
1958     $schemaValue;
1959   if ($isData) {
1960     out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; ';
1961     $schemaValue = 'schema' + $lvl;
1962   } else {
1963     $schemaValue = $schema;
1964   }
1965   if (!$isData) {
1966     out += ' var schema' + ($lvl) + ' = validate.schema' + ($schemaPath) + ';';
1967   }
1968   out += 'var ' + ($valid) + ' = equal(' + ($data) + ', schema' + ($lvl) + '); if (!' + ($valid) + ') {   ';
1969   var $$outStack = $$outStack || [];
1970   $$outStack.push(out);
1971   out = ''; /* istanbul ignore else */
1972   if (it.createErrors !== false) {
1973     out += ' { keyword: \'' + ('const') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { allowedValue: schema' + ($lvl) + ' } ';
1974     if (it.opts.messages !== false) {
1975       out += ' , message: \'should be equal to constant\' ';
1976     }
1977     if (it.opts.verbose) {
1978       out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
1979     }
1980     out += ' } ';
1981   } else {
1982     out += ' {} ';
1983   }
1984   var __err = out;
1985   out = $$outStack.pop();
1986   if (!it.compositeRule && $breakOnError) {
1987     /* istanbul ignore if */
1988     if (it.async) {
1989       out += ' throw new ValidationError([' + (__err) + ']); ';
1990     } else {
1991       out += ' validate.errors = [' + (__err) + ']; return false; ';
1992     }
1993   } else {
1994     out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
1995   }
1996   out += ' }';
1997   if ($breakOnError) {
1998     out += ' else { ';
1999   }
2000   return out;
2001 }
2002
2003 },{}],21:[function(require,module,exports){
2004 'use strict';
2005 module.exports = function generate_contains(it, $keyword, $ruleType) {
2006   var out = ' ';
2007   var $lvl = it.level;
2008   var $dataLvl = it.dataLevel;
2009   var $schema = it.schema[$keyword];
2010   var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
2011   var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
2012   var $breakOnError = !it.opts.allErrors;
2013   var $data = 'data' + ($dataLvl || '');
2014   var $valid = 'valid' + $lvl;
2015   var $errs = 'errs__' + $lvl;
2016   var $it = it.util.copy(it);
2017   var $closingBraces = '';
2018   $it.level++;
2019   var $nextValid = 'valid' + $it.level;
2020   var $idx = 'i' + $lvl,
2021     $dataNxt = $it.dataLevel = it.dataLevel + 1,
2022     $nextData = 'data' + $dataNxt,
2023     $currentBaseId = it.baseId,
2024     $nonEmptySchema = (it.opts.strictKeywords ? typeof $schema == 'object' && Object.keys($schema).length > 0 : it.util.schemaHasRules($schema, it.RULES.all));
2025   out += 'var ' + ($errs) + ' = errors;var ' + ($valid) + ';';
2026   if ($nonEmptySchema) {
2027     var $wasComposite = it.compositeRule;
2028     it.compositeRule = $it.compositeRule = true;
2029     $it.schema = $schema;
2030     $it.schemaPath = $schemaPath;
2031     $it.errSchemaPath = $errSchemaPath;
2032     out += ' var ' + ($nextValid) + ' = false; for (var ' + ($idx) + ' = 0; ' + ($idx) + ' < ' + ($data) + '.length; ' + ($idx) + '++) { ';
2033     $it.errorPath = it.util.getPathExpr(it.errorPath, $idx, it.opts.jsonPointers, true);
2034     var $passData = $data + '[' + $idx + ']';
2035     $it.dataPathArr[$dataNxt] = $idx;
2036     var $code = it.validate($it);
2037     $it.baseId = $currentBaseId;
2038     if (it.util.varOccurences($code, $nextData) < 2) {
2039       out += ' ' + (it.util.varReplace($code, $nextData, $passData)) + ' ';
2040     } else {
2041       out += ' var ' + ($nextData) + ' = ' + ($passData) + '; ' + ($code) + ' ';
2042     }
2043     out += ' if (' + ($nextValid) + ') break; }  ';
2044     it.compositeRule = $it.compositeRule = $wasComposite;
2045     out += ' ' + ($closingBraces) + ' if (!' + ($nextValid) + ') {';
2046   } else {
2047     out += ' if (' + ($data) + '.length == 0) {';
2048   }
2049   var $$outStack = $$outStack || [];
2050   $$outStack.push(out);
2051   out = ''; /* istanbul ignore else */
2052   if (it.createErrors !== false) {
2053     out += ' { keyword: \'' + ('contains') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: {} ';
2054     if (it.opts.messages !== false) {
2055       out += ' , message: \'should contain a valid item\' ';
2056     }
2057     if (it.opts.verbose) {
2058       out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
2059     }
2060     out += ' } ';
2061   } else {
2062     out += ' {} ';
2063   }
2064   var __err = out;
2065   out = $$outStack.pop();
2066   if (!it.compositeRule && $breakOnError) {
2067     /* istanbul ignore if */
2068     if (it.async) {
2069       out += ' throw new ValidationError([' + (__err) + ']); ';
2070     } else {
2071       out += ' validate.errors = [' + (__err) + ']; return false; ';
2072     }
2073   } else {
2074     out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
2075   }
2076   out += ' } else { ';
2077   if ($nonEmptySchema) {
2078     out += '  errors = ' + ($errs) + '; if (vErrors !== null) { if (' + ($errs) + ') vErrors.length = ' + ($errs) + '; else vErrors = null; } ';
2079   }
2080   if (it.opts.allErrors) {
2081     out += ' } ';
2082   }
2083   return out;
2084 }
2085
2086 },{}],22:[function(require,module,exports){
2087 'use strict';
2088 module.exports = function generate_custom(it, $keyword, $ruleType) {
2089   var out = ' ';
2090   var $lvl = it.level;
2091   var $dataLvl = it.dataLevel;
2092   var $schema = it.schema[$keyword];
2093   var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
2094   var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
2095   var $breakOnError = !it.opts.allErrors;
2096   var $errorKeyword;
2097   var $data = 'data' + ($dataLvl || '');
2098   var $valid = 'valid' + $lvl;
2099   var $errs = 'errs__' + $lvl;
2100   var $isData = it.opts.$data && $schema && $schema.$data,
2101     $schemaValue;
2102   if ($isData) {
2103     out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; ';
2104     $schemaValue = 'schema' + $lvl;
2105   } else {
2106     $schemaValue = $schema;
2107   }
2108   var $rule = this,
2109     $definition = 'definition' + $lvl,
2110     $rDef = $rule.definition,
2111     $closingBraces = '';
2112   var $compile, $inline, $macro, $ruleValidate, $validateCode;
2113   if ($isData && $rDef.$data) {
2114     $validateCode = 'keywordValidate' + $lvl;
2115     var $validateSchema = $rDef.validateSchema;
2116     out += ' var ' + ($definition) + ' = RULES.custom[\'' + ($keyword) + '\'].definition; var ' + ($validateCode) + ' = ' + ($definition) + '.validate;';
2117   } else {
2118     $ruleValidate = it.useCustomRule($rule, $schema, it.schema, it);
2119     if (!$ruleValidate) return;
2120     $schemaValue = 'validate.schema' + $schemaPath;
2121     $validateCode = $ruleValidate.code;
2122     $compile = $rDef.compile;
2123     $inline = $rDef.inline;
2124     $macro = $rDef.macro;
2125   }
2126   var $ruleErrs = $validateCode + '.errors',
2127     $i = 'i' + $lvl,
2128     $ruleErr = 'ruleErr' + $lvl,
2129     $asyncKeyword = $rDef.async;
2130   if ($asyncKeyword && !it.async) throw new Error('async keyword in sync schema');
2131   if (!($inline || $macro)) {
2132     out += '' + ($ruleErrs) + ' = null;';
2133   }
2134   out += 'var ' + ($errs) + ' = errors;var ' + ($valid) + ';';
2135   if ($isData && $rDef.$data) {
2136     $closingBraces += '}';
2137     out += ' if (' + ($schemaValue) + ' === undefined) { ' + ($valid) + ' = true; } else { ';
2138     if ($validateSchema) {
2139       $closingBraces += '}';
2140       out += ' ' + ($valid) + ' = ' + ($definition) + '.validateSchema(' + ($schemaValue) + '); if (' + ($valid) + ') { ';
2141     }
2142   }
2143   if ($inline) {
2144     if ($rDef.statements) {
2145       out += ' ' + ($ruleValidate.validate) + ' ';
2146     } else {
2147       out += ' ' + ($valid) + ' = ' + ($ruleValidate.validate) + '; ';
2148     }
2149   } else if ($macro) {
2150     var $it = it.util.copy(it);
2151     var $closingBraces = '';
2152     $it.level++;
2153     var $nextValid = 'valid' + $it.level;
2154     $it.schema = $ruleValidate.validate;
2155     $it.schemaPath = '';
2156     var $wasComposite = it.compositeRule;
2157     it.compositeRule = $it.compositeRule = true;
2158     var $code = it.validate($it).replace(/validate\.schema/g, $validateCode);
2159     it.compositeRule = $it.compositeRule = $wasComposite;
2160     out += ' ' + ($code);
2161   } else {
2162     var $$outStack = $$outStack || [];
2163     $$outStack.push(out);
2164     out = '';
2165     out += '  ' + ($validateCode) + '.call( ';
2166     if (it.opts.passContext) {
2167       out += 'this';
2168     } else {
2169       out += 'self';
2170     }
2171     if ($compile || $rDef.schema === false) {
2172       out += ' , ' + ($data) + ' ';
2173     } else {
2174       out += ' , ' + ($schemaValue) + ' , ' + ($data) + ' , validate.schema' + (it.schemaPath) + ' ';
2175     }
2176     out += ' , (dataPath || \'\')';
2177     if (it.errorPath != '""') {
2178       out += ' + ' + (it.errorPath);
2179     }
2180     var $parentData = $dataLvl ? 'data' + (($dataLvl - 1) || '') : 'parentData',
2181       $parentDataProperty = $dataLvl ? it.dataPathArr[$dataLvl] : 'parentDataProperty';
2182     out += ' , ' + ($parentData) + ' , ' + ($parentDataProperty) + ' , rootData )  ';
2183     var def_callRuleValidate = out;
2184     out = $$outStack.pop();
2185     if ($rDef.errors === false) {
2186       out += ' ' + ($valid) + ' = ';
2187       if ($asyncKeyword) {
2188         out += 'await ';
2189       }
2190       out += '' + (def_callRuleValidate) + '; ';
2191     } else {
2192       if ($asyncKeyword) {
2193         $ruleErrs = 'customErrors' + $lvl;
2194         out += ' var ' + ($ruleErrs) + ' = null; try { ' + ($valid) + ' = await ' + (def_callRuleValidate) + '; } catch (e) { ' + ($valid) + ' = false; if (e instanceof ValidationError) ' + ($ruleErrs) + ' = e.errors; else throw e; } ';
2195       } else {
2196         out += ' ' + ($ruleErrs) + ' = null; ' + ($valid) + ' = ' + (def_callRuleValidate) + '; ';
2197       }
2198     }
2199   }
2200   if ($rDef.modifying) {
2201     out += ' if (' + ($parentData) + ') ' + ($data) + ' = ' + ($parentData) + '[' + ($parentDataProperty) + '];';
2202   }
2203   out += '' + ($closingBraces);
2204   if ($rDef.valid) {
2205     if ($breakOnError) {
2206       out += ' if (true) { ';
2207     }
2208   } else {
2209     out += ' if ( ';
2210     if ($rDef.valid === undefined) {
2211       out += ' !';
2212       if ($macro) {
2213         out += '' + ($nextValid);
2214       } else {
2215         out += '' + ($valid);
2216       }
2217     } else {
2218       out += ' ' + (!$rDef.valid) + ' ';
2219     }
2220     out += ') { ';
2221     $errorKeyword = $rule.keyword;
2222     var $$outStack = $$outStack || [];
2223     $$outStack.push(out);
2224     out = '';
2225     var $$outStack = $$outStack || [];
2226     $$outStack.push(out);
2227     out = ''; /* istanbul ignore else */
2228     if (it.createErrors !== false) {
2229       out += ' { keyword: \'' + ($errorKeyword || 'custom') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { keyword: \'' + ($rule.keyword) + '\' } ';
2230       if (it.opts.messages !== false) {
2231         out += ' , message: \'should pass "' + ($rule.keyword) + '" keyword validation\' ';
2232       }
2233       if (it.opts.verbose) {
2234         out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
2235       }
2236       out += ' } ';
2237     } else {
2238       out += ' {} ';
2239     }
2240     var __err = out;
2241     out = $$outStack.pop();
2242     if (!it.compositeRule && $breakOnError) {
2243       /* istanbul ignore if */
2244       if (it.async) {
2245         out += ' throw new ValidationError([' + (__err) + ']); ';
2246       } else {
2247         out += ' validate.errors = [' + (__err) + ']; return false; ';
2248       }
2249     } else {
2250       out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
2251     }
2252     var def_customError = out;
2253     out = $$outStack.pop();
2254     if ($inline) {
2255       if ($rDef.errors) {
2256         if ($rDef.errors != 'full') {
2257           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) + '"; } ';
2258           if (it.opts.verbose) {
2259             out += ' ' + ($ruleErr) + '.schema = ' + ($schemaValue) + '; ' + ($ruleErr) + '.data = ' + ($data) + '; ';
2260           }
2261           out += ' } ';
2262         }
2263       } else {
2264         if ($rDef.errors === false) {
2265           out += ' ' + (def_customError) + ' ';
2266         } else {
2267           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) + '"; } ';
2268           if (it.opts.verbose) {
2269             out += ' ' + ($ruleErr) + '.schema = ' + ($schemaValue) + '; ' + ($ruleErr) + '.data = ' + ($data) + '; ';
2270           }
2271           out += ' } } ';
2272         }
2273       }
2274     } else if ($macro) {
2275       out += '   var err =   '; /* istanbul ignore else */
2276       if (it.createErrors !== false) {
2277         out += ' { keyword: \'' + ($errorKeyword || 'custom') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { keyword: \'' + ($rule.keyword) + '\' } ';
2278         if (it.opts.messages !== false) {
2279           out += ' , message: \'should pass "' + ($rule.keyword) + '" keyword validation\' ';
2280         }
2281         if (it.opts.verbose) {
2282           out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
2283         }
2284         out += ' } ';
2285       } else {
2286         out += ' {} ';
2287       }
2288       out += ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
2289       if (!it.compositeRule && $breakOnError) {
2290         /* istanbul ignore if */
2291         if (it.async) {
2292           out += ' throw new ValidationError(vErrors); ';
2293         } else {
2294           out += ' validate.errors = vErrors; return false; ';
2295         }
2296       }
2297     } else {
2298       if ($rDef.errors === false) {
2299         out += ' ' + (def_customError) + ' ';
2300       } else {
2301         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) + '";  ';
2302         if (it.opts.verbose) {
2303           out += ' ' + ($ruleErr) + '.schema = ' + ($schemaValue) + '; ' + ($ruleErr) + '.data = ' + ($data) + '; ';
2304         }
2305         out += ' } } else { ' + (def_customError) + ' } ';
2306       }
2307     }
2308     out += ' } ';
2309     if ($breakOnError) {
2310       out += ' else { ';
2311     }
2312   }
2313   return out;
2314 }
2315
2316 },{}],23:[function(require,module,exports){
2317 'use strict';
2318 module.exports = function generate_dependencies(it, $keyword, $ruleType) {
2319   var out = ' ';
2320   var $lvl = it.level;
2321   var $dataLvl = it.dataLevel;
2322   var $schema = it.schema[$keyword];
2323   var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
2324   var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
2325   var $breakOnError = !it.opts.allErrors;
2326   var $data = 'data' + ($dataLvl || '');
2327   var $errs = 'errs__' + $lvl;
2328   var $it = it.util.copy(it);
2329   var $closingBraces = '';
2330   $it.level++;
2331   var $nextValid = 'valid' + $it.level;
2332   var $schemaDeps = {},
2333     $propertyDeps = {},
2334     $ownProperties = it.opts.ownProperties;
2335   for ($property in $schema) {
2336     if ($property == '__proto__') continue;
2337     var $sch = $schema[$property];
2338     var $deps = Array.isArray($sch) ? $propertyDeps : $schemaDeps;
2339     $deps[$property] = $sch;
2340   }
2341   out += 'var ' + ($errs) + ' = errors;';
2342   var $currentErrorPath = it.errorPath;
2343   out += 'var missing' + ($lvl) + ';';
2344   for (var $property in $propertyDeps) {
2345     $deps = $propertyDeps[$property];
2346     if ($deps.length) {
2347       out += ' if ( ' + ($data) + (it.util.getProperty($property)) + ' !== undefined ';
2348       if ($ownProperties) {
2349         out += ' && Object.prototype.hasOwnProperty.call(' + ($data) + ', \'' + (it.util.escapeQuotes($property)) + '\') ';
2350       }
2351       if ($breakOnError) {
2352         out += ' && ( ';
2353         var arr1 = $deps;
2354         if (arr1) {
2355           var $propertyKey, $i = -1,
2356             l1 = arr1.length - 1;
2357           while ($i < l1) {
2358             $propertyKey = arr1[$i += 1];
2359             if ($i) {
2360               out += ' || ';
2361             }
2362             var $prop = it.util.getProperty($propertyKey),
2363               $useData = $data + $prop;
2364             out += ' ( ( ' + ($useData) + ' === undefined ';
2365             if ($ownProperties) {
2366               out += ' || ! Object.prototype.hasOwnProperty.call(' + ($data) + ', \'' + (it.util.escapeQuotes($propertyKey)) + '\') ';
2367             }
2368             out += ') && (missing' + ($lvl) + ' = ' + (it.util.toQuotedString(it.opts.jsonPointers ? $propertyKey : $prop)) + ') ) ';
2369           }
2370         }
2371         out += ')) {  ';
2372         var $propertyPath = 'missing' + $lvl,
2373           $missingProperty = '\' + ' + $propertyPath + ' + \'';
2374         if (it.opts._errorDataPathProperty) {
2375           it.errorPath = it.opts.jsonPointers ? it.util.getPathExpr($currentErrorPath, $propertyPath, true) : $currentErrorPath + ' + ' + $propertyPath;
2376         }
2377         var $$outStack = $$outStack || [];
2378         $$outStack.push(out);
2379         out = ''; /* istanbul ignore else */
2380         if (it.createErrors !== false) {
2381           out += ' { keyword: \'' + ('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(", "))) + '\' } ';
2382           if (it.opts.messages !== false) {
2383             out += ' , message: \'should have ';
2384             if ($deps.length == 1) {
2385               out += 'property ' + (it.util.escapeQuotes($deps[0]));
2386             } else {
2387               out += 'properties ' + (it.util.escapeQuotes($deps.join(", ")));
2388             }
2389             out += ' when property ' + (it.util.escapeQuotes($property)) + ' is present\' ';
2390           }
2391           if (it.opts.verbose) {
2392             out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
2393           }
2394           out += ' } ';
2395         } else {
2396           out += ' {} ';
2397         }
2398         var __err = out;
2399         out = $$outStack.pop();
2400         if (!it.compositeRule && $breakOnError) {
2401           /* istanbul ignore if */
2402           if (it.async) {
2403             out += ' throw new ValidationError([' + (__err) + ']); ';
2404           } else {
2405             out += ' validate.errors = [' + (__err) + ']; return false; ';
2406           }
2407         } else {
2408           out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
2409         }
2410       } else {
2411         out += ' ) { ';
2412         var arr2 = $deps;
2413         if (arr2) {
2414           var $propertyKey, i2 = -1,
2415             l2 = arr2.length - 1;
2416           while (i2 < l2) {
2417             $propertyKey = arr2[i2 += 1];
2418             var $prop = it.util.getProperty($propertyKey),
2419               $missingProperty = it.util.escapeQuotes($propertyKey),
2420               $useData = $data + $prop;
2421             if (it.opts._errorDataPathProperty) {
2422               it.errorPath = it.util.getPath($currentErrorPath, $propertyKey, it.opts.jsonPointers);
2423             }
2424             out += ' if ( ' + ($useData) + ' === undefined ';
2425             if ($ownProperties) {
2426               out += ' || ! Object.prototype.hasOwnProperty.call(' + ($data) + ', \'' + (it.util.escapeQuotes($propertyKey)) + '\') ';
2427             }
2428             out += ') {  var err =   '; /* istanbul ignore else */
2429             if (it.createErrors !== false) {
2430               out += ' { keyword: \'' + ('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(", "))) + '\' } ';
2431               if (it.opts.messages !== false) {
2432                 out += ' , message: \'should have ';
2433                 if ($deps.length == 1) {
2434                   out += 'property ' + (it.util.escapeQuotes($deps[0]));
2435                 } else {
2436                   out += 'properties ' + (it.util.escapeQuotes($deps.join(", ")));
2437                 }
2438                 out += ' when property ' + (it.util.escapeQuotes($property)) + ' is present\' ';
2439               }
2440               if (it.opts.verbose) {
2441                 out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
2442               }
2443               out += ' } ';
2444             } else {
2445               out += ' {} ';
2446             }
2447             out += ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } ';
2448           }
2449         }
2450       }
2451       out += ' }   ';
2452       if ($breakOnError) {
2453         $closingBraces += '}';
2454         out += ' else { ';
2455       }
2456     }
2457   }
2458   it.errorPath = $currentErrorPath;
2459   var $currentBaseId = $it.baseId;
2460   for (var $property in $schemaDeps) {
2461     var $sch = $schemaDeps[$property];
2462     if ((it.opts.strictKeywords ? typeof $sch == 'object' && Object.keys($sch).length > 0 : it.util.schemaHasRules($sch, it.RULES.all))) {
2463       out += ' ' + ($nextValid) + ' = true; if ( ' + ($data) + (it.util.getProperty($property)) + ' !== undefined ';
2464       if ($ownProperties) {
2465         out += ' && Object.prototype.hasOwnProperty.call(' + ($data) + ', \'' + (it.util.escapeQuotes($property)) + '\') ';
2466       }
2467       out += ') { ';
2468       $it.schema = $sch;
2469       $it.schemaPath = $schemaPath + it.util.getProperty($property);
2470       $it.errSchemaPath = $errSchemaPath + '/' + it.util.escapeFragment($property);
2471       out += '  ' + (it.validate($it)) + ' ';
2472       $it.baseId = $currentBaseId;
2473       out += ' }  ';
2474       if ($breakOnError) {
2475         out += ' if (' + ($nextValid) + ') { ';
2476         $closingBraces += '}';
2477       }
2478     }
2479   }
2480   if ($breakOnError) {
2481     out += '   ' + ($closingBraces) + ' if (' + ($errs) + ' == errors) {';
2482   }
2483   return out;
2484 }
2485
2486 },{}],24:[function(require,module,exports){
2487 'use strict';
2488 module.exports = function generate_enum(it, $keyword, $ruleType) {
2489   var out = ' ';
2490   var $lvl = it.level;
2491   var $dataLvl = it.dataLevel;
2492   var $schema = it.schema[$keyword];
2493   var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
2494   var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
2495   var $breakOnError = !it.opts.allErrors;
2496   var $data = 'data' + ($dataLvl || '');
2497   var $valid = 'valid' + $lvl;
2498   var $isData = it.opts.$data && $schema && $schema.$data,
2499     $schemaValue;
2500   if ($isData) {
2501     out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; ';
2502     $schemaValue = 'schema' + $lvl;
2503   } else {
2504     $schemaValue = $schema;
2505   }
2506   var $i = 'i' + $lvl,
2507     $vSchema = 'schema' + $lvl;
2508   if (!$isData) {
2509     out += ' var ' + ($vSchema) + ' = validate.schema' + ($schemaPath) + ';';
2510   }
2511   out += 'var ' + ($valid) + ';';
2512   if ($isData) {
2513     out += ' if (schema' + ($lvl) + ' === undefined) ' + ($valid) + ' = true; else if (!Array.isArray(schema' + ($lvl) + ')) ' + ($valid) + ' = false; else {';
2514   }
2515   out += '' + ($valid) + ' = false;for (var ' + ($i) + '=0; ' + ($i) + '<' + ($vSchema) + '.length; ' + ($i) + '++) if (equal(' + ($data) + ', ' + ($vSchema) + '[' + ($i) + '])) { ' + ($valid) + ' = true; break; }';
2516   if ($isData) {
2517     out += '  }  ';
2518   }
2519   out += ' if (!' + ($valid) + ') {   ';
2520   var $$outStack = $$outStack || [];
2521   $$outStack.push(out);
2522   out = ''; /* istanbul ignore else */
2523   if (it.createErrors !== false) {
2524     out += ' { keyword: \'' + ('enum') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { allowedValues: schema' + ($lvl) + ' } ';
2525     if (it.opts.messages !== false) {
2526       out += ' , message: \'should be equal to one of the allowed values\' ';
2527     }
2528     if (it.opts.verbose) {
2529       out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
2530     }
2531     out += ' } ';
2532   } else {
2533     out += ' {} ';
2534   }
2535   var __err = out;
2536   out = $$outStack.pop();
2537   if (!it.compositeRule && $breakOnError) {
2538     /* istanbul ignore if */
2539     if (it.async) {
2540       out += ' throw new ValidationError([' + (__err) + ']); ';
2541     } else {
2542       out += ' validate.errors = [' + (__err) + ']; return false; ';
2543     }
2544   } else {
2545     out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
2546   }
2547   out += ' }';
2548   if ($breakOnError) {
2549     out += ' else { ';
2550   }
2551   return out;
2552 }
2553
2554 },{}],25:[function(require,module,exports){
2555 'use strict';
2556 module.exports = function generate_format(it, $keyword, $ruleType) {
2557   var out = ' ';
2558   var $lvl = it.level;
2559   var $dataLvl = it.dataLevel;
2560   var $schema = it.schema[$keyword];
2561   var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
2562   var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
2563   var $breakOnError = !it.opts.allErrors;
2564   var $data = 'data' + ($dataLvl || '');
2565   if (it.opts.format === false) {
2566     if ($breakOnError) {
2567       out += ' if (true) { ';
2568     }
2569     return out;
2570   }
2571   var $isData = it.opts.$data && $schema && $schema.$data,
2572     $schemaValue;
2573   if ($isData) {
2574     out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; ';
2575     $schemaValue = 'schema' + $lvl;
2576   } else {
2577     $schemaValue = $schema;
2578   }
2579   var $unknownFormats = it.opts.unknownFormats,
2580     $allowUnknown = Array.isArray($unknownFormats);
2581   if ($isData) {
2582     var $format = 'format' + $lvl,
2583       $isObject = 'isObject' + $lvl,
2584       $formatType = 'formatType' + $lvl;
2585     out += ' var ' + ($format) + ' = formats[' + ($schemaValue) + ']; var ' + ($isObject) + ' = typeof ' + ($format) + ' == \'object\' && !(' + ($format) + ' instanceof RegExp) && ' + ($format) + '.validate; var ' + ($formatType) + ' = ' + ($isObject) + ' && ' + ($format) + '.type || \'string\'; if (' + ($isObject) + ') { ';
2586     if (it.async) {
2587       out += ' var async' + ($lvl) + ' = ' + ($format) + '.async; ';
2588     }
2589     out += ' ' + ($format) + ' = ' + ($format) + '.validate; } if (  ';
2590     if ($isData) {
2591       out += ' (' + ($schemaValue) + ' !== undefined && typeof ' + ($schemaValue) + ' != \'string\') || ';
2592     }
2593     out += ' (';
2594     if ($unknownFormats != 'ignore') {
2595       out += ' (' + ($schemaValue) + ' && !' + ($format) + ' ';
2596       if ($allowUnknown) {
2597         out += ' && self._opts.unknownFormats.indexOf(' + ($schemaValue) + ') == -1 ';
2598       }
2599       out += ') || ';
2600     }
2601     out += ' (' + ($format) + ' && ' + ($formatType) + ' == \'' + ($ruleType) + '\' && !(typeof ' + ($format) + ' == \'function\' ? ';
2602     if (it.async) {
2603       out += ' (async' + ($lvl) + ' ? await ' + ($format) + '(' + ($data) + ') : ' + ($format) + '(' + ($data) + ')) ';
2604     } else {
2605       out += ' ' + ($format) + '(' + ($data) + ') ';
2606     }
2607     out += ' : ' + ($format) + '.test(' + ($data) + '))))) {';
2608   } else {
2609     var $format = it.formats[$schema];
2610     if (!$format) {
2611       if ($unknownFormats == 'ignore') {
2612         it.logger.warn('unknown format "' + $schema + '" ignored in schema at path "' + it.errSchemaPath + '"');
2613         if ($breakOnError) {
2614           out += ' if (true) { ';
2615         }
2616         return out;
2617       } else if ($allowUnknown && $unknownFormats.indexOf($schema) >= 0) {
2618         if ($breakOnError) {
2619           out += ' if (true) { ';
2620         }
2621         return out;
2622       } else {
2623         throw new Error('unknown format "' + $schema + '" is used in schema at path "' + it.errSchemaPath + '"');
2624       }
2625     }
2626     var $isObject = typeof $format == 'object' && !($format instanceof RegExp) && $format.validate;
2627     var $formatType = $isObject && $format.type || 'string';
2628     if ($isObject) {
2629       var $async = $format.async === true;
2630       $format = $format.validate;
2631     }
2632     if ($formatType != $ruleType) {
2633       if ($breakOnError) {
2634         out += ' if (true) { ';
2635       }
2636       return out;
2637     }
2638     if ($async) {
2639       if (!it.async) throw new Error('async format in sync schema');
2640       var $formatRef = 'formats' + it.util.getProperty($schema) + '.validate';
2641       out += ' if (!(await ' + ($formatRef) + '(' + ($data) + '))) { ';
2642     } else {
2643       out += ' if (! ';
2644       var $formatRef = 'formats' + it.util.getProperty($schema);
2645       if ($isObject) $formatRef += '.validate';
2646       if (typeof $format == 'function') {
2647         out += ' ' + ($formatRef) + '(' + ($data) + ') ';
2648       } else {
2649         out += ' ' + ($formatRef) + '.test(' + ($data) + ') ';
2650       }
2651       out += ') { ';
2652     }
2653   }
2654   var $$outStack = $$outStack || [];
2655   $$outStack.push(out);
2656   out = ''; /* istanbul ignore else */
2657   if (it.createErrors !== false) {
2658     out += ' { keyword: \'' + ('format') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { format:  ';
2659     if ($isData) {
2660       out += '' + ($schemaValue);
2661     } else {
2662       out += '' + (it.util.toQuotedString($schema));
2663     }
2664     out += '  } ';
2665     if (it.opts.messages !== false) {
2666       out += ' , message: \'should match format "';
2667       if ($isData) {
2668         out += '\' + ' + ($schemaValue) + ' + \'';
2669       } else {
2670         out += '' + (it.util.escapeQuotes($schema));
2671       }
2672       out += '"\' ';
2673     }
2674     if (it.opts.verbose) {
2675       out += ' , schema:  ';
2676       if ($isData) {
2677         out += 'validate.schema' + ($schemaPath);
2678       } else {
2679         out += '' + (it.util.toQuotedString($schema));
2680       }
2681       out += '         , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
2682     }
2683     out += ' } ';
2684   } else {
2685     out += ' {} ';
2686   }
2687   var __err = out;
2688   out = $$outStack.pop();
2689   if (!it.compositeRule && $breakOnError) {
2690     /* istanbul ignore if */
2691     if (it.async) {
2692       out += ' throw new ValidationError([' + (__err) + ']); ';
2693     } else {
2694       out += ' validate.errors = [' + (__err) + ']; return false; ';
2695     }
2696   } else {
2697     out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
2698   }
2699   out += ' } ';
2700   if ($breakOnError) {
2701     out += ' else { ';
2702   }
2703   return out;
2704 }
2705
2706 },{}],26:[function(require,module,exports){
2707 'use strict';
2708 module.exports = function generate_if(it, $keyword, $ruleType) {
2709   var out = ' ';
2710   var $lvl = it.level;
2711   var $dataLvl = it.dataLevel;
2712   var $schema = it.schema[$keyword];
2713   var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
2714   var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
2715   var $breakOnError = !it.opts.allErrors;
2716   var $data = 'data' + ($dataLvl || '');
2717   var $valid = 'valid' + $lvl;
2718   var $errs = 'errs__' + $lvl;
2719   var $it = it.util.copy(it);
2720   $it.level++;
2721   var $nextValid = 'valid' + $it.level;
2722   var $thenSch = it.schema['then'],
2723     $elseSch = it.schema['else'],
2724     $thenPresent = $thenSch !== undefined && (it.opts.strictKeywords ? typeof $thenSch == 'object' && Object.keys($thenSch).length > 0 : it.util.schemaHasRules($thenSch, it.RULES.all)),
2725     $elsePresent = $elseSch !== undefined && (it.opts.strictKeywords ? typeof $elseSch == 'object' && Object.keys($elseSch).length > 0 : it.util.schemaHasRules($elseSch, it.RULES.all)),
2726     $currentBaseId = $it.baseId;
2727   if ($thenPresent || $elsePresent) {
2728     var $ifClause;
2729     $it.createErrors = false;
2730     $it.schema = $schema;
2731     $it.schemaPath = $schemaPath;
2732     $it.errSchemaPath = $errSchemaPath;
2733     out += ' var ' + ($errs) + ' = errors; var ' + ($valid) + ' = true;  ';
2734     var $wasComposite = it.compositeRule;
2735     it.compositeRule = $it.compositeRule = true;
2736     out += '  ' + (it.validate($it)) + ' ';
2737     $it.baseId = $currentBaseId;
2738     $it.createErrors = true;
2739     out += '  errors = ' + ($errs) + '; if (vErrors !== null) { if (' + ($errs) + ') vErrors.length = ' + ($errs) + '; else vErrors = null; }  ';
2740     it.compositeRule = $it.compositeRule = $wasComposite;
2741     if ($thenPresent) {
2742       out += ' if (' + ($nextValid) + ') {  ';
2743       $it.schema = it.schema['then'];
2744       $it.schemaPath = it.schemaPath + '.then';
2745       $it.errSchemaPath = it.errSchemaPath + '/then';
2746       out += '  ' + (it.validate($it)) + ' ';
2747       $it.baseId = $currentBaseId;
2748       out += ' ' + ($valid) + ' = ' + ($nextValid) + '; ';
2749       if ($thenPresent && $elsePresent) {
2750         $ifClause = 'ifClause' + $lvl;
2751         out += ' var ' + ($ifClause) + ' = \'then\'; ';
2752       } else {
2753         $ifClause = '\'then\'';
2754       }
2755       out += ' } ';
2756       if ($elsePresent) {
2757         out += ' else { ';
2758       }
2759     } else {
2760       out += ' if (!' + ($nextValid) + ') { ';
2761     }
2762     if ($elsePresent) {
2763       $it.schema = it.schema['else'];
2764       $it.schemaPath = it.schemaPath + '.else';
2765       $it.errSchemaPath = it.errSchemaPath + '/else';
2766       out += '  ' + (it.validate($it)) + ' ';
2767       $it.baseId = $currentBaseId;
2768       out += ' ' + ($valid) + ' = ' + ($nextValid) + '; ';
2769       if ($thenPresent && $elsePresent) {
2770         $ifClause = 'ifClause' + $lvl;
2771         out += ' var ' + ($ifClause) + ' = \'else\'; ';
2772       } else {
2773         $ifClause = '\'else\'';
2774       }
2775       out += ' } ';
2776     }
2777     out += ' if (!' + ($valid) + ') {   var err =   '; /* istanbul ignore else */
2778     if (it.createErrors !== false) {
2779       out += ' { keyword: \'' + ('if') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { failingKeyword: ' + ($ifClause) + ' } ';
2780       if (it.opts.messages !== false) {
2781         out += ' , message: \'should match "\' + ' + ($ifClause) + ' + \'" schema\' ';
2782       }
2783       if (it.opts.verbose) {
2784         out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
2785       }
2786       out += ' } ';
2787     } else {
2788       out += ' {} ';
2789     }
2790     out += ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
2791     if (!it.compositeRule && $breakOnError) {
2792       /* istanbul ignore if */
2793       if (it.async) {
2794         out += ' throw new ValidationError(vErrors); ';
2795       } else {
2796         out += ' validate.errors = vErrors; return false; ';
2797       }
2798     }
2799     out += ' }   ';
2800     if ($breakOnError) {
2801       out += ' else { ';
2802     }
2803   } else {
2804     if ($breakOnError) {
2805       out += ' if (true) { ';
2806     }
2807   }
2808   return out;
2809 }
2810
2811 },{}],27:[function(require,module,exports){
2812 'use strict';
2813
2814 //all requires must be explicit because browserify won't work with dynamic requires
2815 module.exports = {
2816   '$ref': require('./ref'),
2817   allOf: require('./allOf'),
2818   anyOf: require('./anyOf'),
2819   '$comment': require('./comment'),
2820   const: require('./const'),
2821   contains: require('./contains'),
2822   dependencies: require('./dependencies'),
2823   'enum': require('./enum'),
2824   format: require('./format'),
2825   'if': require('./if'),
2826   items: require('./items'),
2827   maximum: require('./_limit'),
2828   minimum: require('./_limit'),
2829   maxItems: require('./_limitItems'),
2830   minItems: require('./_limitItems'),
2831   maxLength: require('./_limitLength'),
2832   minLength: require('./_limitLength'),
2833   maxProperties: require('./_limitProperties'),
2834   minProperties: require('./_limitProperties'),
2835   multipleOf: require('./multipleOf'),
2836   not: require('./not'),
2837   oneOf: require('./oneOf'),
2838   pattern: require('./pattern'),
2839   properties: require('./properties'),
2840   propertyNames: require('./propertyNames'),
2841   required: require('./required'),
2842   uniqueItems: require('./uniqueItems'),
2843   validate: require('./validate')
2844 };
2845
2846 },{"./_limit":13,"./_limitItems":14,"./_limitLength":15,"./_limitProperties":16,"./allOf":17,"./anyOf":18,"./comment":19,"./const":20,"./contains":21,"./dependencies":23,"./enum":24,"./format":25,"./if":26,"./items":28,"./multipleOf":29,"./not":30,"./oneOf":31,"./pattern":32,"./properties":33,"./propertyNames":34,"./ref":35,"./required":36,"./uniqueItems":37,"./validate":38}],28:[function(require,module,exports){
2847 'use strict';
2848 module.exports = function generate_items(it, $keyword, $ruleType) {
2849   var out = ' ';
2850   var $lvl = it.level;
2851   var $dataLvl = it.dataLevel;
2852   var $schema = it.schema[$keyword];
2853   var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
2854   var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
2855   var $breakOnError = !it.opts.allErrors;
2856   var $data = 'data' + ($dataLvl || '');
2857   var $valid = 'valid' + $lvl;
2858   var $errs = 'errs__' + $lvl;
2859   var $it = it.util.copy(it);
2860   var $closingBraces = '';
2861   $it.level++;
2862   var $nextValid = 'valid' + $it.level;
2863   var $idx = 'i' + $lvl,
2864     $dataNxt = $it.dataLevel = it.dataLevel + 1,
2865     $nextData = 'data' + $dataNxt,
2866     $currentBaseId = it.baseId;
2867   out += 'var ' + ($errs) + ' = errors;var ' + ($valid) + ';';
2868   if (Array.isArray($schema)) {
2869     var $additionalItems = it.schema.additionalItems;
2870     if ($additionalItems === false) {
2871       out += ' ' + ($valid) + ' = ' + ($data) + '.length <= ' + ($schema.length) + '; ';
2872       var $currErrSchemaPath = $errSchemaPath;
2873       $errSchemaPath = it.errSchemaPath + '/additionalItems';
2874       out += '  if (!' + ($valid) + ') {   ';
2875       var $$outStack = $$outStack || [];
2876       $$outStack.push(out);
2877       out = ''; /* istanbul ignore else */
2878       if (it.createErrors !== false) {
2879         out += ' { keyword: \'' + ('additionalItems') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { limit: ' + ($schema.length) + ' } ';
2880         if (it.opts.messages !== false) {
2881           out += ' , message: \'should NOT have more than ' + ($schema.length) + ' items\' ';
2882         }
2883         if (it.opts.verbose) {
2884           out += ' , schema: false , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
2885         }
2886         out += ' } ';
2887       } else {
2888         out += ' {} ';
2889       }
2890       var __err = out;
2891       out = $$outStack.pop();
2892       if (!it.compositeRule && $breakOnError) {
2893         /* istanbul ignore if */
2894         if (it.async) {
2895           out += ' throw new ValidationError([' + (__err) + ']); ';
2896         } else {
2897           out += ' validate.errors = [' + (__err) + ']; return false; ';
2898         }
2899       } else {
2900         out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
2901       }
2902       out += ' } ';
2903       $errSchemaPath = $currErrSchemaPath;
2904       if ($breakOnError) {
2905         $closingBraces += '}';
2906         out += ' else { ';
2907       }
2908     }
2909     var arr1 = $schema;
2910     if (arr1) {
2911       var $sch, $i = -1,
2912         l1 = arr1.length - 1;
2913       while ($i < l1) {
2914         $sch = arr1[$i += 1];
2915         if ((it.opts.strictKeywords ? typeof $sch == 'object' && Object.keys($sch).length > 0 : it.util.schemaHasRules($sch, it.RULES.all))) {
2916           out += ' ' + ($nextValid) + ' = true; if (' + ($data) + '.length > ' + ($i) + ') { ';
2917           var $passData = $data + '[' + $i + ']';
2918           $it.schema = $sch;
2919           $it.schemaPath = $schemaPath + '[' + $i + ']';
2920           $it.errSchemaPath = $errSchemaPath + '/' + $i;
2921           $it.errorPath = it.util.getPathExpr(it.errorPath, $i, it.opts.jsonPointers, true);
2922           $it.dataPathArr[$dataNxt] = $i;
2923           var $code = it.validate($it);
2924           $it.baseId = $currentBaseId;
2925           if (it.util.varOccurences($code, $nextData) < 2) {
2926             out += ' ' + (it.util.varReplace($code, $nextData, $passData)) + ' ';
2927           } else {
2928             out += ' var ' + ($nextData) + ' = ' + ($passData) + '; ' + ($code) + ' ';
2929           }
2930           out += ' }  ';
2931           if ($breakOnError) {
2932             out += ' if (' + ($nextValid) + ') { ';
2933             $closingBraces += '}';
2934           }
2935         }
2936       }
2937     }
2938     if (typeof $additionalItems == 'object' && (it.opts.strictKeywords ? typeof $additionalItems == 'object' && Object.keys($additionalItems).length > 0 : it.util.schemaHasRules($additionalItems, it.RULES.all))) {
2939       $it.schema = $additionalItems;
2940       $it.schemaPath = it.schemaPath + '.additionalItems';
2941       $it.errSchemaPath = it.errSchemaPath + '/additionalItems';
2942       out += ' ' + ($nextValid) + ' = true; if (' + ($data) + '.length > ' + ($schema.length) + ') {  for (var ' + ($idx) + ' = ' + ($schema.length) + '; ' + ($idx) + ' < ' + ($data) + '.length; ' + ($idx) + '++) { ';
2943       $it.errorPath = it.util.getPathExpr(it.errorPath, $idx, it.opts.jsonPointers, true);
2944       var $passData = $data + '[' + $idx + ']';
2945       $it.dataPathArr[$dataNxt] = $idx;
2946       var $code = it.validate($it);
2947       $it.baseId = $currentBaseId;
2948       if (it.util.varOccurences($code, $nextData) < 2) {
2949         out += ' ' + (it.util.varReplace($code, $nextData, $passData)) + ' ';
2950       } else {
2951         out += ' var ' + ($nextData) + ' = ' + ($passData) + '; ' + ($code) + ' ';
2952       }
2953       if ($breakOnError) {
2954         out += ' if (!' + ($nextValid) + ') break; ';
2955       }
2956       out += ' } }  ';
2957       if ($breakOnError) {
2958         out += ' if (' + ($nextValid) + ') { ';
2959         $closingBraces += '}';
2960       }
2961     }
2962   } else if ((it.opts.strictKeywords ? typeof $schema == 'object' && Object.keys($schema).length > 0 : it.util.schemaHasRules($schema, it.RULES.all))) {
2963     $it.schema = $schema;
2964     $it.schemaPath = $schemaPath;
2965     $it.errSchemaPath = $errSchemaPath;
2966     out += '  for (var ' + ($idx) + ' = ' + (0) + '; ' + ($idx) + ' < ' + ($data) + '.length; ' + ($idx) + '++) { ';
2967     $it.errorPath = it.util.getPathExpr(it.errorPath, $idx, it.opts.jsonPointers, true);
2968     var $passData = $data + '[' + $idx + ']';
2969     $it.dataPathArr[$dataNxt] = $idx;
2970     var $code = it.validate($it);
2971     $it.baseId = $currentBaseId;
2972     if (it.util.varOccurences($code, $nextData) < 2) {
2973       out += ' ' + (it.util.varReplace($code, $nextData, $passData)) + ' ';
2974     } else {
2975       out += ' var ' + ($nextData) + ' = ' + ($passData) + '; ' + ($code) + ' ';
2976     }
2977     if ($breakOnError) {
2978       out += ' if (!' + ($nextValid) + ') break; ';
2979     }
2980     out += ' }';
2981   }
2982   if ($breakOnError) {
2983     out += ' ' + ($closingBraces) + ' if (' + ($errs) + ' == errors) {';
2984   }
2985   return out;
2986 }
2987
2988 },{}],29:[function(require,module,exports){
2989 'use strict';
2990 module.exports = function generate_multipleOf(it, $keyword, $ruleType) {
2991   var out = ' ';
2992   var $lvl = it.level;
2993   var $dataLvl = it.dataLevel;
2994   var $schema = it.schema[$keyword];
2995   var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
2996   var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
2997   var $breakOnError = !it.opts.allErrors;
2998   var $data = 'data' + ($dataLvl || '');
2999   var $isData = it.opts.$data && $schema && $schema.$data,
3000     $schemaValue;
3001   if ($isData) {
3002     out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; ';
3003     $schemaValue = 'schema' + $lvl;
3004   } else {
3005     $schemaValue = $schema;
3006   }
3007   if (!($isData || typeof $schema == 'number')) {
3008     throw new Error($keyword + ' must be number');
3009   }
3010   out += 'var division' + ($lvl) + ';if (';
3011   if ($isData) {
3012     out += ' ' + ($schemaValue) + ' !== undefined && ( typeof ' + ($schemaValue) + ' != \'number\' || ';
3013   }
3014   out += ' (division' + ($lvl) + ' = ' + ($data) + ' / ' + ($schemaValue) + ', ';
3015   if (it.opts.multipleOfPrecision) {
3016     out += ' Math.abs(Math.round(division' + ($lvl) + ') - division' + ($lvl) + ') > 1e-' + (it.opts.multipleOfPrecision) + ' ';
3017   } else {
3018     out += ' division' + ($lvl) + ' !== parseInt(division' + ($lvl) + ') ';
3019   }
3020   out += ' ) ';
3021   if ($isData) {
3022     out += '  )  ';
3023   }
3024   out += ' ) {   ';
3025   var $$outStack = $$outStack || [];
3026   $$outStack.push(out);
3027   out = ''; /* istanbul ignore else */
3028   if (it.createErrors !== false) {
3029     out += ' { keyword: \'' + ('multipleOf') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { multipleOf: ' + ($schemaValue) + ' } ';
3030     if (it.opts.messages !== false) {
3031       out += ' , message: \'should be multiple of ';
3032       if ($isData) {
3033         out += '\' + ' + ($schemaValue);
3034       } else {
3035         out += '' + ($schemaValue) + '\'';
3036       }
3037     }
3038     if (it.opts.verbose) {
3039       out += ' , schema:  ';
3040       if ($isData) {
3041         out += 'validate.schema' + ($schemaPath);
3042       } else {
3043         out += '' + ($schema);
3044       }
3045       out += '         , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
3046     }
3047     out += ' } ';
3048   } else {
3049     out += ' {} ';
3050   }
3051   var __err = out;
3052   out = $$outStack.pop();
3053   if (!it.compositeRule && $breakOnError) {
3054     /* istanbul ignore if */
3055     if (it.async) {
3056       out += ' throw new ValidationError([' + (__err) + ']); ';
3057     } else {
3058       out += ' validate.errors = [' + (__err) + ']; return false; ';
3059     }
3060   } else {
3061     out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
3062   }
3063   out += '} ';
3064   if ($breakOnError) {
3065     out += ' else { ';
3066   }
3067   return out;
3068 }
3069
3070 },{}],30:[function(require,module,exports){
3071 'use strict';
3072 module.exports = function generate_not(it, $keyword, $ruleType) {
3073   var out = ' ';
3074   var $lvl = it.level;
3075   var $dataLvl = it.dataLevel;
3076   var $schema = it.schema[$keyword];
3077   var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
3078   var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
3079   var $breakOnError = !it.opts.allErrors;
3080   var $data = 'data' + ($dataLvl || '');
3081   var $errs = 'errs__' + $lvl;
3082   var $it = it.util.copy(it);
3083   $it.level++;
3084   var $nextValid = 'valid' + $it.level;
3085   if ((it.opts.strictKeywords ? typeof $schema == 'object' && Object.keys($schema).length > 0 : it.util.schemaHasRules($schema, it.RULES.all))) {
3086     $it.schema = $schema;
3087     $it.schemaPath = $schemaPath;
3088     $it.errSchemaPath = $errSchemaPath;
3089     out += ' var ' + ($errs) + ' = errors;  ';
3090     var $wasComposite = it.compositeRule;
3091     it.compositeRule = $it.compositeRule = true;
3092     $it.createErrors = false;
3093     var $allErrorsOption;
3094     if ($it.opts.allErrors) {
3095       $allErrorsOption = $it.opts.allErrors;
3096       $it.opts.allErrors = false;
3097     }
3098     out += ' ' + (it.validate($it)) + ' ';
3099     $it.createErrors = true;
3100     if ($allErrorsOption) $it.opts.allErrors = $allErrorsOption;
3101     it.compositeRule = $it.compositeRule = $wasComposite;
3102     out += ' if (' + ($nextValid) + ') {   ';
3103     var $$outStack = $$outStack || [];
3104     $$outStack.push(out);
3105     out = ''; /* istanbul ignore else */
3106     if (it.createErrors !== false) {
3107       out += ' { keyword: \'' + ('not') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: {} ';
3108       if (it.opts.messages !== false) {
3109         out += ' , message: \'should NOT be valid\' ';
3110       }
3111       if (it.opts.verbose) {
3112         out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
3113       }
3114       out += ' } ';
3115     } else {
3116       out += ' {} ';
3117     }
3118     var __err = out;
3119     out = $$outStack.pop();
3120     if (!it.compositeRule && $breakOnError) {
3121       /* istanbul ignore if */
3122       if (it.async) {
3123         out += ' throw new ValidationError([' + (__err) + ']); ';
3124       } else {
3125         out += ' validate.errors = [' + (__err) + ']; return false; ';
3126       }
3127     } else {
3128       out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
3129     }
3130     out += ' } else {  errors = ' + ($errs) + '; if (vErrors !== null) { if (' + ($errs) + ') vErrors.length = ' + ($errs) + '; else vErrors = null; } ';
3131     if (it.opts.allErrors) {
3132       out += ' } ';
3133     }
3134   } else {
3135     out += '  var err =   '; /* istanbul ignore else */
3136     if (it.createErrors !== false) {
3137       out += ' { keyword: \'' + ('not') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: {} ';
3138       if (it.opts.messages !== false) {
3139         out += ' , message: \'should NOT be valid\' ';
3140       }
3141       if (it.opts.verbose) {
3142         out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
3143       }
3144       out += ' } ';
3145     } else {
3146       out += ' {} ';
3147     }
3148     out += ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
3149     if ($breakOnError) {
3150       out += ' if (false) { ';
3151     }
3152   }
3153   return out;
3154 }
3155
3156 },{}],31:[function(require,module,exports){
3157 'use strict';
3158 module.exports = function generate_oneOf(it, $keyword, $ruleType) {
3159   var out = ' ';
3160   var $lvl = it.level;
3161   var $dataLvl = it.dataLevel;
3162   var $schema = it.schema[$keyword];
3163   var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
3164   var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
3165   var $breakOnError = !it.opts.allErrors;
3166   var $data = 'data' + ($dataLvl || '');
3167   var $valid = 'valid' + $lvl;
3168   var $errs = 'errs__' + $lvl;
3169   var $it = it.util.copy(it);
3170   var $closingBraces = '';
3171   $it.level++;
3172   var $nextValid = 'valid' + $it.level;
3173   var $currentBaseId = $it.baseId,
3174     $prevValid = 'prevValid' + $lvl,
3175     $passingSchemas = 'passingSchemas' + $lvl;
3176   out += 'var ' + ($errs) + ' = errors , ' + ($prevValid) + ' = false , ' + ($valid) + ' = false , ' + ($passingSchemas) + ' = null; ';
3177   var $wasComposite = it.compositeRule;
3178   it.compositeRule = $it.compositeRule = true;
3179   var arr1 = $schema;
3180   if (arr1) {
3181     var $sch, $i = -1,
3182       l1 = arr1.length - 1;
3183     while ($i < l1) {
3184       $sch = arr1[$i += 1];
3185       if ((it.opts.strictKeywords ? typeof $sch == 'object' && Object.keys($sch).length > 0 : it.util.schemaHasRules($sch, it.RULES.all))) {
3186         $it.schema = $sch;
3187         $it.schemaPath = $schemaPath + '[' + $i + ']';
3188         $it.errSchemaPath = $errSchemaPath + '/' + $i;
3189         out += '  ' + (it.validate($it)) + ' ';
3190         $it.baseId = $currentBaseId;
3191       } else {
3192         out += ' var ' + ($nextValid) + ' = true; ';
3193       }
3194       if ($i) {
3195         out += ' if (' + ($nextValid) + ' && ' + ($prevValid) + ') { ' + ($valid) + ' = false; ' + ($passingSchemas) + ' = [' + ($passingSchemas) + ', ' + ($i) + ']; } else { ';
3196         $closingBraces += '}';
3197       }
3198       out += ' if (' + ($nextValid) + ') { ' + ($valid) + ' = ' + ($prevValid) + ' = true; ' + ($passingSchemas) + ' = ' + ($i) + '; }';
3199     }
3200   }
3201   it.compositeRule = $it.compositeRule = $wasComposite;
3202   out += '' + ($closingBraces) + 'if (!' + ($valid) + ') {   var err =   '; /* istanbul ignore else */
3203   if (it.createErrors !== false) {
3204     out += ' { keyword: \'' + ('oneOf') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { passingSchemas: ' + ($passingSchemas) + ' } ';
3205     if (it.opts.messages !== false) {
3206       out += ' , message: \'should match exactly one schema in oneOf\' ';
3207     }
3208     if (it.opts.verbose) {
3209       out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
3210     }
3211     out += ' } ';
3212   } else {
3213     out += ' {} ';
3214   }
3215   out += ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
3216   if (!it.compositeRule && $breakOnError) {
3217     /* istanbul ignore if */
3218     if (it.async) {
3219       out += ' throw new ValidationError(vErrors); ';
3220     } else {
3221       out += ' validate.errors = vErrors; return false; ';
3222     }
3223   }
3224   out += '} else {  errors = ' + ($errs) + '; if (vErrors !== null) { if (' + ($errs) + ') vErrors.length = ' + ($errs) + '; else vErrors = null; }';
3225   if (it.opts.allErrors) {
3226     out += ' } ';
3227   }
3228   return out;
3229 }
3230
3231 },{}],32:[function(require,module,exports){
3232 'use strict';
3233 module.exports = function generate_pattern(it, $keyword, $ruleType) {
3234   var out = ' ';
3235   var $lvl = it.level;
3236   var $dataLvl = it.dataLevel;
3237   var $schema = it.schema[$keyword];
3238   var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
3239   var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
3240   var $breakOnError = !it.opts.allErrors;
3241   var $data = 'data' + ($dataLvl || '');
3242   var $isData = it.opts.$data && $schema && $schema.$data,
3243     $schemaValue;
3244   if ($isData) {
3245     out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; ';
3246     $schemaValue = 'schema' + $lvl;
3247   } else {
3248     $schemaValue = $schema;
3249   }
3250   var $regexp = $isData ? '(new RegExp(' + $schemaValue + '))' : it.usePattern($schema);
3251   out += 'if ( ';
3252   if ($isData) {
3253     out += ' (' + ($schemaValue) + ' !== undefined && typeof ' + ($schemaValue) + ' != \'string\') || ';
3254   }
3255   out += ' !' + ($regexp) + '.test(' + ($data) + ') ) {   ';
3256   var $$outStack = $$outStack || [];
3257   $$outStack.push(out);
3258   out = ''; /* istanbul ignore else */
3259   if (it.createErrors !== false) {
3260     out += ' { keyword: \'' + ('pattern') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { pattern:  ';
3261     if ($isData) {
3262       out += '' + ($schemaValue);
3263     } else {
3264       out += '' + (it.util.toQuotedString($schema));
3265     }
3266     out += '  } ';
3267     if (it.opts.messages !== false) {
3268       out += ' , message: \'should match pattern "';
3269       if ($isData) {
3270         out += '\' + ' + ($schemaValue) + ' + \'';
3271       } else {
3272         out += '' + (it.util.escapeQuotes($schema));
3273       }
3274       out += '"\' ';
3275     }
3276     if (it.opts.verbose) {
3277       out += ' , schema:  ';
3278       if ($isData) {
3279         out += 'validate.schema' + ($schemaPath);
3280       } else {
3281         out += '' + (it.util.toQuotedString($schema));
3282       }
3283       out += '         , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
3284     }
3285     out += ' } ';
3286   } else {
3287     out += ' {} ';
3288   }
3289   var __err = out;
3290   out = $$outStack.pop();
3291   if (!it.compositeRule && $breakOnError) {
3292     /* istanbul ignore if */
3293     if (it.async) {
3294       out += ' throw new ValidationError([' + (__err) + ']); ';
3295     } else {
3296       out += ' validate.errors = [' + (__err) + ']; return false; ';
3297     }
3298   } else {
3299     out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
3300   }
3301   out += '} ';
3302   if ($breakOnError) {
3303     out += ' else { ';
3304   }
3305   return out;
3306 }
3307
3308 },{}],33:[function(require,module,exports){
3309 'use strict';
3310 module.exports = function generate_properties(it, $keyword, $ruleType) {
3311   var out = ' ';
3312   var $lvl = it.level;
3313   var $dataLvl = it.dataLevel;
3314   var $schema = it.schema[$keyword];
3315   var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
3316   var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
3317   var $breakOnError = !it.opts.allErrors;
3318   var $data = 'data' + ($dataLvl || '');
3319   var $errs = 'errs__' + $lvl;
3320   var $it = it.util.copy(it);
3321   var $closingBraces = '';
3322   $it.level++;
3323   var $nextValid = 'valid' + $it.level;
3324   var $key = 'key' + $lvl,
3325     $idx = 'idx' + $lvl,
3326     $dataNxt = $it.dataLevel = it.dataLevel + 1,
3327     $nextData = 'data' + $dataNxt,
3328     $dataProperties = 'dataProperties' + $lvl;
3329   var $schemaKeys = Object.keys($schema || {}).filter(notProto),
3330     $pProperties = it.schema.patternProperties || {},
3331     $pPropertyKeys = Object.keys($pProperties).filter(notProto),
3332     $aProperties = it.schema.additionalProperties,
3333     $someProperties = $schemaKeys.length || $pPropertyKeys.length,
3334     $noAdditional = $aProperties === false,
3335     $additionalIsSchema = typeof $aProperties == 'object' && Object.keys($aProperties).length,
3336     $removeAdditional = it.opts.removeAdditional,
3337     $checkAdditional = $noAdditional || $additionalIsSchema || $removeAdditional,
3338     $ownProperties = it.opts.ownProperties,
3339     $currentBaseId = it.baseId;
3340   var $required = it.schema.required;
3341   if ($required && !(it.opts.$data && $required.$data) && $required.length < it.opts.loopRequired) {
3342     var $requiredHash = it.util.toHash($required);
3343   }
3344
3345   function notProto(p) {
3346     return p !== '__proto__';
3347   }
3348   out += 'var ' + ($errs) + ' = errors;var ' + ($nextValid) + ' = true;';
3349   if ($ownProperties) {
3350     out += ' var ' + ($dataProperties) + ' = undefined;';
3351   }
3352   if ($checkAdditional) {
3353     if ($ownProperties) {
3354       out += ' ' + ($dataProperties) + ' = ' + ($dataProperties) + ' || Object.keys(' + ($data) + '); for (var ' + ($idx) + '=0; ' + ($idx) + '<' + ($dataProperties) + '.length; ' + ($idx) + '++) { var ' + ($key) + ' = ' + ($dataProperties) + '[' + ($idx) + ']; ';
3355     } else {
3356       out += ' for (var ' + ($key) + ' in ' + ($data) + ') { ';
3357     }
3358     if ($someProperties) {
3359       out += ' var isAdditional' + ($lvl) + ' = !(false ';
3360       if ($schemaKeys.length) {
3361         if ($schemaKeys.length > 8) {
3362           out += ' || validate.schema' + ($schemaPath) + '.hasOwnProperty(' + ($key) + ') ';
3363         } else {
3364           var arr1 = $schemaKeys;
3365           if (arr1) {
3366             var $propertyKey, i1 = -1,
3367               l1 = arr1.length - 1;
3368             while (i1 < l1) {
3369               $propertyKey = arr1[i1 += 1];
3370               out += ' || ' + ($key) + ' == ' + (it.util.toQuotedString($propertyKey)) + ' ';
3371             }
3372           }
3373         }
3374       }
3375       if ($pPropertyKeys.length) {
3376         var arr2 = $pPropertyKeys;
3377         if (arr2) {
3378           var $pProperty, $i = -1,
3379             l2 = arr2.length - 1;
3380           while ($i < l2) {
3381             $pProperty = arr2[$i += 1];
3382             out += ' || ' + (it.usePattern($pProperty)) + '.test(' + ($key) + ') ';
3383           }
3384         }
3385       }
3386       out += ' ); if (isAdditional' + ($lvl) + ') { ';
3387     }
3388     if ($removeAdditional == 'all') {
3389       out += ' delete ' + ($data) + '[' + ($key) + ']; ';
3390     } else {
3391       var $currentErrorPath = it.errorPath;
3392       var $additionalProperty = '\' + ' + $key + ' + \'';
3393       if (it.opts._errorDataPathProperty) {
3394         it.errorPath = it.util.getPathExpr(it.errorPath, $key, it.opts.jsonPointers);
3395       }
3396       if ($noAdditional) {
3397         if ($removeAdditional) {
3398           out += ' delete ' + ($data) + '[' + ($key) + ']; ';
3399         } else {
3400           out += ' ' + ($nextValid) + ' = false; ';
3401           var $currErrSchemaPath = $errSchemaPath;
3402           $errSchemaPath = it.errSchemaPath + '/additionalProperties';
3403           var $$outStack = $$outStack || [];
3404           $$outStack.push(out);
3405           out = ''; /* istanbul ignore else */
3406           if (it.createErrors !== false) {
3407             out += ' { keyword: \'' + ('additionalProperties') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { additionalProperty: \'' + ($additionalProperty) + '\' } ';
3408             if (it.opts.messages !== false) {
3409               out += ' , message: \'';
3410               if (it.opts._errorDataPathProperty) {
3411                 out += 'is an invalid additional property';
3412               } else {
3413                 out += 'should NOT have additional properties';
3414               }
3415               out += '\' ';
3416             }
3417             if (it.opts.verbose) {
3418               out += ' , schema: false , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
3419             }
3420             out += ' } ';
3421           } else {
3422             out += ' {} ';
3423           }
3424           var __err = out;
3425           out = $$outStack.pop();
3426           if (!it.compositeRule && $breakOnError) {
3427             /* istanbul ignore if */
3428             if (it.async) {
3429               out += ' throw new ValidationError([' + (__err) + ']); ';
3430             } else {
3431               out += ' validate.errors = [' + (__err) + ']; return false; ';
3432             }
3433           } else {
3434             out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
3435           }
3436           $errSchemaPath = $currErrSchemaPath;
3437           if ($breakOnError) {
3438             out += ' break; ';
3439           }
3440         }
3441       } else if ($additionalIsSchema) {
3442         if ($removeAdditional == 'failing') {
3443           out += ' var ' + ($errs) + ' = errors;  ';
3444           var $wasComposite = it.compositeRule;
3445           it.compositeRule = $it.compositeRule = true;
3446           $it.schema = $aProperties;
3447           $it.schemaPath = it.schemaPath + '.additionalProperties';
3448           $it.errSchemaPath = it.errSchemaPath + '/additionalProperties';
3449           $it.errorPath = it.opts._errorDataPathProperty ? it.errorPath : it.util.getPathExpr(it.errorPath, $key, it.opts.jsonPointers);
3450           var $passData = $data + '[' + $key + ']';
3451           $it.dataPathArr[$dataNxt] = $key;
3452           var $code = it.validate($it);
3453           $it.baseId = $currentBaseId;
3454           if (it.util.varOccurences($code, $nextData) < 2) {
3455             out += ' ' + (it.util.varReplace($code, $nextData, $passData)) + ' ';
3456           } else {
3457             out += ' var ' + ($nextData) + ' = ' + ($passData) + '; ' + ($code) + ' ';
3458           }
3459           out += ' if (!' + ($nextValid) + ') { errors = ' + ($errs) + '; if (validate.errors !== null) { if (errors) validate.errors.length = errors; else validate.errors = null; } delete ' + ($data) + '[' + ($key) + ']; }  ';
3460           it.compositeRule = $it.compositeRule = $wasComposite;
3461         } else {
3462           $it.schema = $aProperties;
3463           $it.schemaPath = it.schemaPath + '.additionalProperties';
3464           $it.errSchemaPath = it.errSchemaPath + '/additionalProperties';
3465           $it.errorPath = it.opts._errorDataPathProperty ? it.errorPath : it.util.getPathExpr(it.errorPath, $key, it.opts.jsonPointers);
3466           var $passData = $data + '[' + $key + ']';
3467           $it.dataPathArr[$dataNxt] = $key;
3468           var $code = it.validate($it);
3469           $it.baseId = $currentBaseId;
3470           if (it.util.varOccurences($code, $nextData) < 2) {
3471             out += ' ' + (it.util.varReplace($code, $nextData, $passData)) + ' ';
3472           } else {
3473             out += ' var ' + ($nextData) + ' = ' + ($passData) + '; ' + ($code) + ' ';
3474           }
3475           if ($breakOnError) {
3476             out += ' if (!' + ($nextValid) + ') break; ';
3477           }
3478         }
3479       }
3480       it.errorPath = $currentErrorPath;
3481     }
3482     if ($someProperties) {
3483       out += ' } ';
3484     }
3485     out += ' }  ';
3486     if ($breakOnError) {
3487       out += ' if (' + ($nextValid) + ') { ';
3488       $closingBraces += '}';
3489     }
3490   }
3491   var $useDefaults = it.opts.useDefaults && !it.compositeRule;
3492   if ($schemaKeys.length) {
3493     var arr3 = $schemaKeys;
3494     if (arr3) {
3495       var $propertyKey, i3 = -1,
3496         l3 = arr3.length - 1;
3497       while (i3 < l3) {
3498         $propertyKey = arr3[i3 += 1];
3499         var $sch = $schema[$propertyKey];
3500         if ((it.opts.strictKeywords ? typeof $sch == 'object' && Object.keys($sch).length > 0 : it.util.schemaHasRules($sch, it.RULES.all))) {
3501           var $prop = it.util.getProperty($propertyKey),
3502             $passData = $data + $prop,
3503             $hasDefault = $useDefaults && $sch.default !== undefined;
3504           $it.schema = $sch;
3505           $it.schemaPath = $schemaPath + $prop;
3506           $it.errSchemaPath = $errSchemaPath + '/' + it.util.escapeFragment($propertyKey);
3507           $it.errorPath = it.util.getPath(it.errorPath, $propertyKey, it.opts.jsonPointers);
3508           $it.dataPathArr[$dataNxt] = it.util.toQuotedString($propertyKey);
3509           var $code = it.validate($it);
3510           $it.baseId = $currentBaseId;
3511           if (it.util.varOccurences($code, $nextData) < 2) {
3512             $code = it.util.varReplace($code, $nextData, $passData);
3513             var $useData = $passData;
3514           } else {
3515             var $useData = $nextData;
3516             out += ' var ' + ($nextData) + ' = ' + ($passData) + '; ';
3517           }
3518           if ($hasDefault) {
3519             out += ' ' + ($code) + ' ';
3520           } else {
3521             if ($requiredHash && $requiredHash[$propertyKey]) {
3522               out += ' if ( ' + ($useData) + ' === undefined ';
3523               if ($ownProperties) {
3524                 out += ' || ! Object.prototype.hasOwnProperty.call(' + ($data) + ', \'' + (it.util.escapeQuotes($propertyKey)) + '\') ';
3525               }
3526               out += ') { ' + ($nextValid) + ' = false; ';
3527               var $currentErrorPath = it.errorPath,
3528                 $currErrSchemaPath = $errSchemaPath,
3529                 $missingProperty = it.util.escapeQuotes($propertyKey);
3530               if (it.opts._errorDataPathProperty) {
3531                 it.errorPath = it.util.getPath($currentErrorPath, $propertyKey, it.opts.jsonPointers);
3532               }
3533               $errSchemaPath = it.errSchemaPath + '/required';
3534               var $$outStack = $$outStack || [];
3535               $$outStack.push(out);
3536               out = ''; /* istanbul ignore else */
3537               if (it.createErrors !== false) {
3538                 out += ' { keyword: \'' + ('required') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { missingProperty: \'' + ($missingProperty) + '\' } ';
3539                 if (it.opts.messages !== false) {
3540                   out += ' , message: \'';
3541                   if (it.opts._errorDataPathProperty) {
3542                     out += 'is a required property';
3543                   } else {
3544                     out += 'should have required property \\\'' + ($missingProperty) + '\\\'';
3545                   }
3546                   out += '\' ';
3547                 }
3548                 if (it.opts.verbose) {
3549                   out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
3550                 }
3551                 out += ' } ';
3552               } else {
3553                 out += ' {} ';
3554               }
3555               var __err = out;
3556               out = $$outStack.pop();
3557               if (!it.compositeRule && $breakOnError) {
3558                 /* istanbul ignore if */
3559                 if (it.async) {
3560                   out += ' throw new ValidationError([' + (__err) + ']); ';
3561                 } else {
3562                   out += ' validate.errors = [' + (__err) + ']; return false; ';
3563                 }
3564               } else {
3565                 out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
3566               }
3567               $errSchemaPath = $currErrSchemaPath;
3568               it.errorPath = $currentErrorPath;
3569               out += ' } else { ';
3570             } else {
3571               if ($breakOnError) {
3572                 out += ' if ( ' + ($useData) + ' === undefined ';
3573                 if ($ownProperties) {
3574                   out += ' || ! Object.prototype.hasOwnProperty.call(' + ($data) + ', \'' + (it.util.escapeQuotes($propertyKey)) + '\') ';
3575                 }
3576                 out += ') { ' + ($nextValid) + ' = true; } else { ';
3577               } else {
3578                 out += ' if (' + ($useData) + ' !== undefined ';
3579                 if ($ownProperties) {
3580                   out += ' &&   Object.prototype.hasOwnProperty.call(' + ($data) + ', \'' + (it.util.escapeQuotes($propertyKey)) + '\') ';
3581                 }
3582                 out += ' ) { ';
3583               }
3584             }
3585             out += ' ' + ($code) + ' } ';
3586           }
3587         }
3588         if ($breakOnError) {
3589           out += ' if (' + ($nextValid) + ') { ';
3590           $closingBraces += '}';
3591         }
3592       }
3593     }
3594   }
3595   if ($pPropertyKeys.length) {
3596     var arr4 = $pPropertyKeys;
3597     if (arr4) {
3598       var $pProperty, i4 = -1,
3599         l4 = arr4.length - 1;
3600       while (i4 < l4) {
3601         $pProperty = arr4[i4 += 1];
3602         var $sch = $pProperties[$pProperty];
3603         if ((it.opts.strictKeywords ? typeof $sch == 'object' && Object.keys($sch).length > 0 : it.util.schemaHasRules($sch, it.RULES.all))) {
3604           $it.schema = $sch;
3605           $it.schemaPath = it.schemaPath + '.patternProperties' + it.util.getProperty($pProperty);
3606           $it.errSchemaPath = it.errSchemaPath + '/patternProperties/' + it.util.escapeFragment($pProperty);
3607           if ($ownProperties) {
3608             out += ' ' + ($dataProperties) + ' = ' + ($dataProperties) + ' || Object.keys(' + ($data) + '); for (var ' + ($idx) + '=0; ' + ($idx) + '<' + ($dataProperties) + '.length; ' + ($idx) + '++) { var ' + ($key) + ' = ' + ($dataProperties) + '[' + ($idx) + ']; ';
3609           } else {
3610             out += ' for (var ' + ($key) + ' in ' + ($data) + ') { ';
3611           }
3612           out += ' if (' + (it.usePattern($pProperty)) + '.test(' + ($key) + ')) { ';
3613           $it.errorPath = it.util.getPathExpr(it.errorPath, $key, it.opts.jsonPointers);
3614           var $passData = $data + '[' + $key + ']';
3615           $it.dataPathArr[$dataNxt] = $key;
3616           var $code = it.validate($it);
3617           $it.baseId = $currentBaseId;
3618           if (it.util.varOccurences($code, $nextData) < 2) {
3619             out += ' ' + (it.util.varReplace($code, $nextData, $passData)) + ' ';
3620           } else {
3621             out += ' var ' + ($nextData) + ' = ' + ($passData) + '; ' + ($code) + ' ';
3622           }
3623           if ($breakOnError) {
3624             out += ' if (!' + ($nextValid) + ') break; ';
3625           }
3626           out += ' } ';
3627           if ($breakOnError) {
3628             out += ' else ' + ($nextValid) + ' = true; ';
3629           }
3630           out += ' }  ';
3631           if ($breakOnError) {
3632             out += ' if (' + ($nextValid) + ') { ';
3633             $closingBraces += '}';
3634           }
3635         }
3636       }
3637     }
3638   }
3639   if ($breakOnError) {
3640     out += ' ' + ($closingBraces) + ' if (' + ($errs) + ' == errors) {';
3641   }
3642   return out;
3643 }
3644
3645 },{}],34:[function(require,module,exports){
3646 'use strict';
3647 module.exports = function generate_propertyNames(it, $keyword, $ruleType) {
3648   var out = ' ';
3649   var $lvl = it.level;
3650   var $dataLvl = it.dataLevel;
3651   var $schema = it.schema[$keyword];
3652   var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
3653   var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
3654   var $breakOnError = !it.opts.allErrors;
3655   var $data = 'data' + ($dataLvl || '');
3656   var $errs = 'errs__' + $lvl;
3657   var $it = it.util.copy(it);
3658   var $closingBraces = '';
3659   $it.level++;
3660   var $nextValid = 'valid' + $it.level;
3661   out += 'var ' + ($errs) + ' = errors;';
3662   if ((it.opts.strictKeywords ? typeof $schema == 'object' && Object.keys($schema).length > 0 : it.util.schemaHasRules($schema, it.RULES.all))) {
3663     $it.schema = $schema;
3664     $it.schemaPath = $schemaPath;
3665     $it.errSchemaPath = $errSchemaPath;
3666     var $key = 'key' + $lvl,
3667       $idx = 'idx' + $lvl,
3668       $i = 'i' + $lvl,
3669       $invalidName = '\' + ' + $key + ' + \'',
3670       $dataNxt = $it.dataLevel = it.dataLevel + 1,
3671       $nextData = 'data' + $dataNxt,
3672       $dataProperties = 'dataProperties' + $lvl,
3673       $ownProperties = it.opts.ownProperties,
3674       $currentBaseId = it.baseId;
3675     if ($ownProperties) {
3676       out += ' var ' + ($dataProperties) + ' = undefined; ';
3677     }
3678     if ($ownProperties) {
3679       out += ' ' + ($dataProperties) + ' = ' + ($dataProperties) + ' || Object.keys(' + ($data) + '); for (var ' + ($idx) + '=0; ' + ($idx) + '<' + ($dataProperties) + '.length; ' + ($idx) + '++) { var ' + ($key) + ' = ' + ($dataProperties) + '[' + ($idx) + ']; ';
3680     } else {
3681       out += ' for (var ' + ($key) + ' in ' + ($data) + ') { ';
3682     }
3683     out += ' var startErrs' + ($lvl) + ' = errors; ';
3684     var $passData = $key;
3685     var $wasComposite = it.compositeRule;
3686     it.compositeRule = $it.compositeRule = true;
3687     var $code = it.validate($it);
3688     $it.baseId = $currentBaseId;
3689     if (it.util.varOccurences($code, $nextData) < 2) {
3690       out += ' ' + (it.util.varReplace($code, $nextData, $passData)) + ' ';
3691     } else {
3692       out += ' var ' + ($nextData) + ' = ' + ($passData) + '; ' + ($code) + ' ';
3693     }
3694     it.compositeRule = $it.compositeRule = $wasComposite;
3695     out += ' if (!' + ($nextValid) + ') { for (var ' + ($i) + '=startErrs' + ($lvl) + '; ' + ($i) + '<errors; ' + ($i) + '++) { vErrors[' + ($i) + '].propertyName = ' + ($key) + '; }   var err =   '; /* istanbul ignore else */
3696     if (it.createErrors !== false) {
3697       out += ' { keyword: \'' + ('propertyNames') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { propertyName: \'' + ($invalidName) + '\' } ';
3698       if (it.opts.messages !== false) {
3699         out += ' , message: \'property name \\\'' + ($invalidName) + '\\\' is invalid\' ';
3700       }
3701       if (it.opts.verbose) {
3702         out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
3703       }
3704       out += ' } ';
3705     } else {
3706       out += ' {} ';
3707     }
3708     out += ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
3709     if (!it.compositeRule && $breakOnError) {
3710       /* istanbul ignore if */
3711       if (it.async) {
3712         out += ' throw new ValidationError(vErrors); ';
3713       } else {
3714         out += ' validate.errors = vErrors; return false; ';
3715       }
3716     }
3717     if ($breakOnError) {
3718       out += ' break; ';
3719     }
3720     out += ' } }';
3721   }
3722   if ($breakOnError) {
3723     out += ' ' + ($closingBraces) + ' if (' + ($errs) + ' == errors) {';
3724   }
3725   return out;
3726 }
3727
3728 },{}],35:[function(require,module,exports){
3729 'use strict';
3730 module.exports = function generate_ref(it, $keyword, $ruleType) {
3731   var out = ' ';
3732   var $lvl = it.level;
3733   var $dataLvl = it.dataLevel;
3734   var $schema = it.schema[$keyword];
3735   var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
3736   var $breakOnError = !it.opts.allErrors;
3737   var $data = 'data' + ($dataLvl || '');
3738   var $valid = 'valid' + $lvl;
3739   var $async, $refCode;
3740   if ($schema == '#' || $schema == '#/') {
3741     if (it.isRoot) {
3742       $async = it.async;
3743       $refCode = 'validate';
3744     } else {
3745       $async = it.root.schema.$async === true;
3746       $refCode = 'root.refVal[0]';
3747     }
3748   } else {
3749     var $refVal = it.resolveRef(it.baseId, $schema, it.isRoot);
3750     if ($refVal === undefined) {
3751       var $message = it.MissingRefError.message(it.baseId, $schema);
3752       if (it.opts.missingRefs == 'fail') {
3753         it.logger.error($message);
3754         var $$outStack = $$outStack || [];
3755         $$outStack.push(out);
3756         out = ''; /* istanbul ignore else */
3757         if (it.createErrors !== false) {
3758           out += ' { keyword: \'' + ('$ref') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { ref: \'' + (it.util.escapeQuotes($schema)) + '\' } ';
3759           if (it.opts.messages !== false) {
3760             out += ' , message: \'can\\\'t resolve reference ' + (it.util.escapeQuotes($schema)) + '\' ';
3761           }
3762           if (it.opts.verbose) {
3763             out += ' , schema: ' + (it.util.toQuotedString($schema)) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
3764           }
3765           out += ' } ';
3766         } else {
3767           out += ' {} ';
3768         }
3769         var __err = out;
3770         out = $$outStack.pop();
3771         if (!it.compositeRule && $breakOnError) {
3772           /* istanbul ignore if */
3773           if (it.async) {
3774             out += ' throw new ValidationError([' + (__err) + ']); ';
3775           } else {
3776             out += ' validate.errors = [' + (__err) + ']; return false; ';
3777           }
3778         } else {
3779           out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
3780         }
3781         if ($breakOnError) {
3782           out += ' if (false) { ';
3783         }
3784       } else if (it.opts.missingRefs == 'ignore') {
3785         it.logger.warn($message);
3786         if ($breakOnError) {
3787           out += ' if (true) { ';
3788         }
3789       } else {
3790         throw new it.MissingRefError(it.baseId, $schema, $message);
3791       }
3792     } else if ($refVal.inline) {
3793       var $it = it.util.copy(it);
3794       $it.level++;
3795       var $nextValid = 'valid' + $it.level;
3796       $it.schema = $refVal.schema;
3797       $it.schemaPath = '';
3798       $it.errSchemaPath = $schema;
3799       var $code = it.validate($it).replace(/validate\.schema/g, $refVal.code);
3800       out += ' ' + ($code) + ' ';
3801       if ($breakOnError) {
3802         out += ' if (' + ($nextValid) + ') { ';
3803       }
3804     } else {
3805       $async = $refVal.$async === true || (it.async && $refVal.$async !== false);
3806       $refCode = $refVal.code;
3807     }
3808   }
3809   if ($refCode) {
3810     var $$outStack = $$outStack || [];
3811     $$outStack.push(out);
3812     out = '';
3813     if (it.opts.passContext) {
3814       out += ' ' + ($refCode) + '.call(this, ';
3815     } else {
3816       out += ' ' + ($refCode) + '( ';
3817     }
3818     out += ' ' + ($data) + ', (dataPath || \'\')';
3819     if (it.errorPath != '""') {
3820       out += ' + ' + (it.errorPath);
3821     }
3822     var $parentData = $dataLvl ? 'data' + (($dataLvl - 1) || '') : 'parentData',
3823       $parentDataProperty = $dataLvl ? it.dataPathArr[$dataLvl] : 'parentDataProperty';
3824     out += ' , ' + ($parentData) + ' , ' + ($parentDataProperty) + ', rootData)  ';
3825     var __callValidate = out;
3826     out = $$outStack.pop();
3827     if ($async) {
3828       if (!it.async) throw new Error('async schema referenced by sync schema');
3829       if ($breakOnError) {
3830         out += ' var ' + ($valid) + '; ';
3831       }
3832       out += ' try { await ' + (__callValidate) + '; ';
3833       if ($breakOnError) {
3834         out += ' ' + ($valid) + ' = true; ';
3835       }
3836       out += ' } catch (e) { if (!(e instanceof ValidationError)) throw e; if (vErrors === null) vErrors = e.errors; else vErrors = vErrors.concat(e.errors); errors = vErrors.length; ';
3837       if ($breakOnError) {
3838         out += ' ' + ($valid) + ' = false; ';
3839       }
3840       out += ' } ';
3841       if ($breakOnError) {
3842         out += ' if (' + ($valid) + ') { ';
3843       }
3844     } else {
3845       out += ' if (!' + (__callValidate) + ') { if (vErrors === null) vErrors = ' + ($refCode) + '.errors; else vErrors = vErrors.concat(' + ($refCode) + '.errors); errors = vErrors.length; } ';
3846       if ($breakOnError) {
3847         out += ' else { ';
3848       }
3849     }
3850   }
3851   return out;
3852 }
3853
3854 },{}],36:[function(require,module,exports){
3855 'use strict';
3856 module.exports = function generate_required(it, $keyword, $ruleType) {
3857   var out = ' ';
3858   var $lvl = it.level;
3859   var $dataLvl = it.dataLevel;
3860   var $schema = it.schema[$keyword];
3861   var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
3862   var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
3863   var $breakOnError = !it.opts.allErrors;
3864   var $data = 'data' + ($dataLvl || '');
3865   var $valid = 'valid' + $lvl;
3866   var $isData = it.opts.$data && $schema && $schema.$data,
3867     $schemaValue;
3868   if ($isData) {
3869     out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; ';
3870     $schemaValue = 'schema' + $lvl;
3871   } else {
3872     $schemaValue = $schema;
3873   }
3874   var $vSchema = 'schema' + $lvl;
3875   if (!$isData) {
3876     if ($schema.length < it.opts.loopRequired && it.schema.properties && Object.keys(it.schema.properties).length) {
3877       var $required = [];
3878       var arr1 = $schema;
3879       if (arr1) {
3880         var $property, i1 = -1,
3881           l1 = arr1.length - 1;
3882         while (i1 < l1) {
3883           $property = arr1[i1 += 1];
3884           var $propertySch = it.schema.properties[$property];
3885           if (!($propertySch && (it.opts.strictKeywords ? typeof $propertySch == 'object' && Object.keys($propertySch).length > 0 : it.util.schemaHasRules($propertySch, it.RULES.all)))) {
3886             $required[$required.length] = $property;
3887           }
3888         }
3889       }
3890     } else {
3891       var $required = $schema;
3892     }
3893   }
3894   if ($isData || $required.length) {
3895     var $currentErrorPath = it.errorPath,
3896       $loopRequired = $isData || $required.length >= it.opts.loopRequired,
3897       $ownProperties = it.opts.ownProperties;
3898     if ($breakOnError) {
3899       out += ' var missing' + ($lvl) + '; ';
3900       if ($loopRequired) {
3901         if (!$isData) {
3902           out += ' var ' + ($vSchema) + ' = validate.schema' + ($schemaPath) + '; ';
3903         }
3904         var $i = 'i' + $lvl,
3905           $propertyPath = 'schema' + $lvl + '[' + $i + ']',
3906           $missingProperty = '\' + ' + $propertyPath + ' + \'';
3907         if (it.opts._errorDataPathProperty) {
3908           it.errorPath = it.util.getPathExpr($currentErrorPath, $propertyPath, it.opts.jsonPointers);
3909         }
3910         out += ' var ' + ($valid) + ' = true; ';
3911         if ($isData) {
3912           out += ' if (schema' + ($lvl) + ' === undefined) ' + ($valid) + ' = true; else if (!Array.isArray(schema' + ($lvl) + ')) ' + ($valid) + ' = false; else {';
3913         }
3914         out += ' for (var ' + ($i) + ' = 0; ' + ($i) + ' < ' + ($vSchema) + '.length; ' + ($i) + '++) { ' + ($valid) + ' = ' + ($data) + '[' + ($vSchema) + '[' + ($i) + ']] !== undefined ';
3915         if ($ownProperties) {
3916           out += ' &&   Object.prototype.hasOwnProperty.call(' + ($data) + ', ' + ($vSchema) + '[' + ($i) + ']) ';
3917         }
3918         out += '; if (!' + ($valid) + ') break; } ';
3919         if ($isData) {
3920           out += '  }  ';
3921         }
3922         out += '  if (!' + ($valid) + ') {   ';
3923         var $$outStack = $$outStack || [];
3924         $$outStack.push(out);
3925         out = ''; /* istanbul ignore else */
3926         if (it.createErrors !== false) {
3927           out += ' { keyword: \'' + ('required') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { missingProperty: \'' + ($missingProperty) + '\' } ';
3928           if (it.opts.messages !== false) {
3929             out += ' , message: \'';
3930             if (it.opts._errorDataPathProperty) {
3931               out += 'is a required property';
3932             } else {
3933               out += 'should have required property \\\'' + ($missingProperty) + '\\\'';
3934             }
3935             out += '\' ';
3936           }
3937           if (it.opts.verbose) {
3938             out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
3939           }
3940           out += ' } ';
3941         } else {
3942           out += ' {} ';
3943         }
3944         var __err = out;
3945         out = $$outStack.pop();
3946         if (!it.compositeRule && $breakOnError) {
3947           /* istanbul ignore if */
3948           if (it.async) {
3949             out += ' throw new ValidationError([' + (__err) + ']); ';
3950           } else {
3951             out += ' validate.errors = [' + (__err) + ']; return false; ';
3952           }
3953         } else {
3954           out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
3955         }
3956         out += ' } else { ';
3957       } else {
3958         out += ' if ( ';
3959         var arr2 = $required;
3960         if (arr2) {
3961           var $propertyKey, $i = -1,
3962             l2 = arr2.length - 1;
3963           while ($i < l2) {
3964             $propertyKey = arr2[$i += 1];
3965             if ($i) {
3966               out += ' || ';
3967             }
3968             var $prop = it.util.getProperty($propertyKey),
3969               $useData = $data + $prop;
3970             out += ' ( ( ' + ($useData) + ' === undefined ';
3971             if ($ownProperties) {
3972               out += ' || ! Object.prototype.hasOwnProperty.call(' + ($data) + ', \'' + (it.util.escapeQuotes($propertyKey)) + '\') ';
3973             }
3974             out += ') && (missing' + ($lvl) + ' = ' + (it.util.toQuotedString(it.opts.jsonPointers ? $propertyKey : $prop)) + ') ) ';
3975           }
3976         }
3977         out += ') {  ';
3978         var $propertyPath = 'missing' + $lvl,
3979           $missingProperty = '\' + ' + $propertyPath + ' + \'';
3980         if (it.opts._errorDataPathProperty) {
3981           it.errorPath = it.opts.jsonPointers ? it.util.getPathExpr($currentErrorPath, $propertyPath, true) : $currentErrorPath + ' + ' + $propertyPath;
3982         }
3983         var $$outStack = $$outStack || [];
3984         $$outStack.push(out);
3985         out = ''; /* istanbul ignore else */
3986         if (it.createErrors !== false) {
3987           out += ' { keyword: \'' + ('required') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { missingProperty: \'' + ($missingProperty) + '\' } ';
3988           if (it.opts.messages !== false) {
3989             out += ' , message: \'';
3990             if (it.opts._errorDataPathProperty) {
3991               out += 'is a required property';
3992             } else {
3993               out += 'should have required property \\\'' + ($missingProperty) + '\\\'';
3994             }
3995             out += '\' ';
3996           }
3997           if (it.opts.verbose) {
3998             out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
3999           }
4000           out += ' } ';
4001         } else {
4002           out += ' {} ';
4003         }
4004         var __err = out;
4005         out = $$outStack.pop();
4006         if (!it.compositeRule && $breakOnError) {
4007           /* istanbul ignore if */
4008           if (it.async) {
4009             out += ' throw new ValidationError([' + (__err) + ']); ';
4010           } else {
4011             out += ' validate.errors = [' + (__err) + ']; return false; ';
4012           }
4013         } else {
4014           out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
4015         }
4016         out += ' } else { ';
4017       }
4018     } else {
4019       if ($loopRequired) {
4020         if (!$isData) {
4021           out += ' var ' + ($vSchema) + ' = validate.schema' + ($schemaPath) + '; ';
4022         }
4023         var $i = 'i' + $lvl,
4024           $propertyPath = 'schema' + $lvl + '[' + $i + ']',
4025           $missingProperty = '\' + ' + $propertyPath + ' + \'';
4026         if (it.opts._errorDataPathProperty) {
4027           it.errorPath = it.util.getPathExpr($currentErrorPath, $propertyPath, it.opts.jsonPointers);
4028         }
4029         if ($isData) {
4030           out += ' if (' + ($vSchema) + ' && !Array.isArray(' + ($vSchema) + ')) {  var err =   '; /* istanbul ignore else */
4031           if (it.createErrors !== false) {
4032             out += ' { keyword: \'' + ('required') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { missingProperty: \'' + ($missingProperty) + '\' } ';
4033             if (it.opts.messages !== false) {
4034               out += ' , message: \'';
4035               if (it.opts._errorDataPathProperty) {
4036                 out += 'is a required property';
4037               } else {
4038                 out += 'should have required property \\\'' + ($missingProperty) + '\\\'';
4039               }
4040               out += '\' ';
4041             }
4042             if (it.opts.verbose) {
4043               out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
4044             }
4045             out += ' } ';
4046           } else {
4047             out += ' {} ';
4048           }
4049           out += ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } else if (' + ($vSchema) + ' !== undefined) { ';
4050         }
4051         out += ' for (var ' + ($i) + ' = 0; ' + ($i) + ' < ' + ($vSchema) + '.length; ' + ($i) + '++) { if (' + ($data) + '[' + ($vSchema) + '[' + ($i) + ']] === undefined ';
4052         if ($ownProperties) {
4053           out += ' || ! Object.prototype.hasOwnProperty.call(' + ($data) + ', ' + ($vSchema) + '[' + ($i) + ']) ';
4054         }
4055         out += ') {  var err =   '; /* istanbul ignore else */
4056         if (it.createErrors !== false) {
4057           out += ' { keyword: \'' + ('required') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { missingProperty: \'' + ($missingProperty) + '\' } ';
4058           if (it.opts.messages !== false) {
4059             out += ' , message: \'';
4060             if (it.opts._errorDataPathProperty) {
4061               out += 'is a required property';
4062             } else {
4063               out += 'should have required property \\\'' + ($missingProperty) + '\\\'';
4064             }
4065             out += '\' ';
4066           }
4067           if (it.opts.verbose) {
4068             out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
4069           }
4070           out += ' } ';
4071         } else {
4072           out += ' {} ';
4073         }
4074         out += ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } } ';
4075         if ($isData) {
4076           out += '  }  ';
4077         }
4078       } else {
4079         var arr3 = $required;
4080         if (arr3) {
4081           var $propertyKey, i3 = -1,
4082             l3 = arr3.length - 1;
4083           while (i3 < l3) {
4084             $propertyKey = arr3[i3 += 1];
4085             var $prop = it.util.getProperty($propertyKey),
4086               $missingProperty = it.util.escapeQuotes($propertyKey),
4087               $useData = $data + $prop;
4088             if (it.opts._errorDataPathProperty) {
4089               it.errorPath = it.util.getPath($currentErrorPath, $propertyKey, it.opts.jsonPointers);
4090             }
4091             out += ' if ( ' + ($useData) + ' === undefined ';
4092             if ($ownProperties) {
4093               out += ' || ! Object.prototype.hasOwnProperty.call(' + ($data) + ', \'' + (it.util.escapeQuotes($propertyKey)) + '\') ';
4094             }
4095             out += ') {  var err =   '; /* istanbul ignore else */
4096             if (it.createErrors !== false) {
4097               out += ' { keyword: \'' + ('required') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { missingProperty: \'' + ($missingProperty) + '\' } ';
4098               if (it.opts.messages !== false) {
4099                 out += ' , message: \'';
4100                 if (it.opts._errorDataPathProperty) {
4101                   out += 'is a required property';
4102                 } else {
4103                   out += 'should have required property \\\'' + ($missingProperty) + '\\\'';
4104                 }
4105                 out += '\' ';
4106               }
4107               if (it.opts.verbose) {
4108                 out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
4109               }
4110               out += ' } ';
4111             } else {
4112               out += ' {} ';
4113             }
4114             out += ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } ';
4115           }
4116         }
4117       }
4118     }
4119     it.errorPath = $currentErrorPath;
4120   } else if ($breakOnError) {
4121     out += ' if (true) {';
4122   }
4123   return out;
4124 }
4125
4126 },{}],37:[function(require,module,exports){
4127 'use strict';
4128 module.exports = function generate_uniqueItems(it, $keyword, $ruleType) {
4129   var out = ' ';
4130   var $lvl = it.level;
4131   var $dataLvl = it.dataLevel;
4132   var $schema = it.schema[$keyword];
4133   var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
4134   var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
4135   var $breakOnError = !it.opts.allErrors;
4136   var $data = 'data' + ($dataLvl || '');
4137   var $valid = 'valid' + $lvl;
4138   var $isData = it.opts.$data && $schema && $schema.$data,
4139     $schemaValue;
4140   if ($isData) {
4141     out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; ';
4142     $schemaValue = 'schema' + $lvl;
4143   } else {
4144     $schemaValue = $schema;
4145   }
4146   if (($schema || $isData) && it.opts.uniqueItems !== false) {
4147     if ($isData) {
4148       out += ' var ' + ($valid) + '; if (' + ($schemaValue) + ' === false || ' + ($schemaValue) + ' === undefined) ' + ($valid) + ' = true; else if (typeof ' + ($schemaValue) + ' != \'boolean\') ' + ($valid) + ' = false; else { ';
4149     }
4150     out += ' var i = ' + ($data) + '.length , ' + ($valid) + ' = true , j; if (i > 1) { ';
4151     var $itemType = it.schema.items && it.schema.items.type,
4152       $typeIsArray = Array.isArray($itemType);
4153     if (!$itemType || $itemType == 'object' || $itemType == 'array' || ($typeIsArray && ($itemType.indexOf('object') >= 0 || $itemType.indexOf('array') >= 0))) {
4154       out += ' outer: for (;i--;) { for (j = i; j--;) { if (equal(' + ($data) + '[i], ' + ($data) + '[j])) { ' + ($valid) + ' = false; break outer; } } } ';
4155     } else {
4156       out += ' var itemIndices = {}, item; for (;i--;) { var item = ' + ($data) + '[i]; ';
4157       var $method = 'checkDataType' + ($typeIsArray ? 's' : '');
4158       out += ' if (' + (it.util[$method]($itemType, 'item', it.opts.strictNumbers, true)) + ') continue; ';
4159       if ($typeIsArray) {
4160         out += ' if (typeof item == \'string\') item = \'"\' + item; ';
4161       }
4162       out += ' if (typeof itemIndices[item] == \'number\') { ' + ($valid) + ' = false; j = itemIndices[item]; break; } itemIndices[item] = i; } ';
4163     }
4164     out += ' } ';
4165     if ($isData) {
4166       out += '  }  ';
4167     }
4168     out += ' if (!' + ($valid) + ') {   ';
4169     var $$outStack = $$outStack || [];
4170     $$outStack.push(out);
4171     out = ''; /* istanbul ignore else */
4172     if (it.createErrors !== false) {
4173       out += ' { keyword: \'' + ('uniqueItems') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { i: i, j: j } ';
4174       if (it.opts.messages !== false) {
4175         out += ' , message: \'should NOT have duplicate items (items ## \' + j + \' and \' + i + \' are identical)\' ';
4176       }
4177       if (it.opts.verbose) {
4178         out += ' , schema:  ';
4179         if ($isData) {
4180           out += 'validate.schema' + ($schemaPath);
4181         } else {
4182           out += '' + ($schema);
4183         }
4184         out += '         , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
4185       }
4186       out += ' } ';
4187     } else {
4188       out += ' {} ';
4189     }
4190     var __err = out;
4191     out = $$outStack.pop();
4192     if (!it.compositeRule && $breakOnError) {
4193       /* istanbul ignore if */
4194       if (it.async) {
4195         out += ' throw new ValidationError([' + (__err) + ']); ';
4196       } else {
4197         out += ' validate.errors = [' + (__err) + ']; return false; ';
4198       }
4199     } else {
4200       out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
4201     }
4202     out += ' } ';
4203     if ($breakOnError) {
4204       out += ' else { ';
4205     }
4206   } else {
4207     if ($breakOnError) {
4208       out += ' if (true) { ';
4209     }
4210   }
4211   return out;
4212 }
4213
4214 },{}],38:[function(require,module,exports){
4215 'use strict';
4216 module.exports = function generate_validate(it, $keyword, $ruleType) {
4217   var out = '';
4218   var $async = it.schema.$async === true,
4219     $refKeywords = it.util.schemaHasRulesExcept(it.schema, it.RULES.all, '$ref'),
4220     $id = it.self._getId(it.schema);
4221   if (it.opts.strictKeywords) {
4222     var $unknownKwd = it.util.schemaUnknownRules(it.schema, it.RULES.keywords);
4223     if ($unknownKwd) {
4224       var $keywordsMsg = 'unknown keyword: ' + $unknownKwd;
4225       if (it.opts.strictKeywords === 'log') it.logger.warn($keywordsMsg);
4226       else throw new Error($keywordsMsg);
4227     }
4228   }
4229   if (it.isTop) {
4230     out += ' var validate = ';
4231     if ($async) {
4232       it.async = true;
4233       out += 'async ';
4234     }
4235     out += 'function(data, dataPath, parentData, parentDataProperty, rootData) { \'use strict\'; ';
4236     if ($id && (it.opts.sourceCode || it.opts.processCode)) {
4237       out += ' ' + ('/\*# sourceURL=' + $id + ' */') + ' ';
4238     }
4239   }
4240   if (typeof it.schema == 'boolean' || !($refKeywords || it.schema.$ref)) {
4241     var $keyword = 'false schema';
4242     var $lvl = it.level;
4243     var $dataLvl = it.dataLevel;
4244     var $schema = it.schema[$keyword];
4245     var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
4246     var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
4247     var $breakOnError = !it.opts.allErrors;
4248     var $errorKeyword;
4249     var $data = 'data' + ($dataLvl || '');
4250     var $valid = 'valid' + $lvl;
4251     if (it.schema === false) {
4252       if (it.isTop) {
4253         $breakOnError = true;
4254       } else {
4255         out += ' var ' + ($valid) + ' = false; ';
4256       }
4257       var $$outStack = $$outStack || [];
4258       $$outStack.push(out);
4259       out = ''; /* istanbul ignore else */
4260       if (it.createErrors !== false) {
4261         out += ' { keyword: \'' + ($errorKeyword || 'false schema') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: {} ';
4262         if (it.opts.messages !== false) {
4263           out += ' , message: \'boolean schema is false\' ';
4264         }
4265         if (it.opts.verbose) {
4266           out += ' , schema: false , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
4267         }
4268         out += ' } ';
4269       } else {
4270         out += ' {} ';
4271       }
4272       var __err = out;
4273       out = $$outStack.pop();
4274       if (!it.compositeRule && $breakOnError) {
4275         /* istanbul ignore if */
4276         if (it.async) {
4277           out += ' throw new ValidationError([' + (__err) + ']); ';
4278         } else {
4279           out += ' validate.errors = [' + (__err) + ']; return false; ';
4280         }
4281       } else {
4282         out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
4283       }
4284     } else {
4285       if (it.isTop) {
4286         if ($async) {
4287           out += ' return data; ';
4288         } else {
4289           out += ' validate.errors = null; return true; ';
4290         }
4291       } else {
4292         out += ' var ' + ($valid) + ' = true; ';
4293       }
4294     }
4295     if (it.isTop) {
4296       out += ' }; return validate; ';
4297     }
4298     return out;
4299   }
4300   if (it.isTop) {
4301     var $top = it.isTop,
4302       $lvl = it.level = 0,
4303       $dataLvl = it.dataLevel = 0,
4304       $data = 'data';
4305     it.rootId = it.resolve.fullPath(it.self._getId(it.root.schema));
4306     it.baseId = it.baseId || it.rootId;
4307     delete it.isTop;
4308     it.dataPathArr = [undefined];
4309     if (it.schema.default !== undefined && it.opts.useDefaults && it.opts.strictDefaults) {
4310       var $defaultMsg = 'default is ignored in the schema root';
4311       if (it.opts.strictDefaults === 'log') it.logger.warn($defaultMsg);
4312       else throw new Error($defaultMsg);
4313     }
4314     out += ' var vErrors = null; ';
4315     out += ' var errors = 0;     ';
4316     out += ' if (rootData === undefined) rootData = data; ';
4317   } else {
4318     var $lvl = it.level,
4319       $dataLvl = it.dataLevel,
4320       $data = 'data' + ($dataLvl || '');
4321     if ($id) it.baseId = it.resolve.url(it.baseId, $id);
4322     if ($async && !it.async) throw new Error('async schema in sync schema');
4323     out += ' var errs_' + ($lvl) + ' = errors;';
4324   }
4325   var $valid = 'valid' + $lvl,
4326     $breakOnError = !it.opts.allErrors,
4327     $closingBraces1 = '',
4328     $closingBraces2 = '';
4329   var $errorKeyword;
4330   var $typeSchema = it.schema.type,
4331     $typeIsArray = Array.isArray($typeSchema);
4332   if ($typeSchema && it.opts.nullable && it.schema.nullable === true) {
4333     if ($typeIsArray) {
4334       if ($typeSchema.indexOf('null') == -1) $typeSchema = $typeSchema.concat('null');
4335     } else if ($typeSchema != 'null') {
4336       $typeSchema = [$typeSchema, 'null'];
4337       $typeIsArray = true;
4338     }
4339   }
4340   if ($typeIsArray && $typeSchema.length == 1) {
4341     $typeSchema = $typeSchema[0];
4342     $typeIsArray = false;
4343   }
4344   if (it.schema.$ref && $refKeywords) {
4345     if (it.opts.extendRefs == 'fail') {
4346       throw new Error('$ref: validation keywords used in schema at path "' + it.errSchemaPath + '" (see option extendRefs)');
4347     } else if (it.opts.extendRefs !== true) {
4348       $refKeywords = false;
4349       it.logger.warn('$ref: keywords ignored in schema at path "' + it.errSchemaPath + '"');
4350     }
4351   }
4352   if (it.schema.$comment && it.opts.$comment) {
4353     out += ' ' + (it.RULES.all.$comment.code(it, '$comment'));
4354   }
4355   if ($typeSchema) {
4356     if (it.opts.coerceTypes) {
4357       var $coerceToTypes = it.util.coerceToTypes(it.opts.coerceTypes, $typeSchema);
4358     }
4359     var $rulesGroup = it.RULES.types[$typeSchema];
4360     if ($coerceToTypes || $typeIsArray || $rulesGroup === true || ($rulesGroup && !$shouldUseGroup($rulesGroup))) {
4361       var $schemaPath = it.schemaPath + '.type',
4362         $errSchemaPath = it.errSchemaPath + '/type';
4363       var $schemaPath = it.schemaPath + '.type',
4364         $errSchemaPath = it.errSchemaPath + '/type',
4365         $method = $typeIsArray ? 'checkDataTypes' : 'checkDataType';
4366       out += ' if (' + (it.util[$method]($typeSchema, $data, it.opts.strictNumbers, true)) + ') { ';
4367       if ($coerceToTypes) {
4368         var $dataType = 'dataType' + $lvl,
4369           $coerced = 'coerced' + $lvl;
4370         out += ' var ' + ($dataType) + ' = typeof ' + ($data) + '; ';
4371         if (it.opts.coerceTypes == 'array') {
4372           out += ' if (' + ($dataType) + ' == \'object\' && Array.isArray(' + ($data) + ')) ' + ($dataType) + ' = \'array\'; ';
4373         }
4374         out += ' var ' + ($coerced) + ' = undefined; ';
4375         var $bracesCoercion = '';
4376         var arr1 = $coerceToTypes;
4377         if (arr1) {
4378           var $type, $i = -1,
4379             l1 = arr1.length - 1;
4380           while ($i < l1) {
4381             $type = arr1[$i += 1];
4382             if ($i) {
4383               out += ' if (' + ($coerced) + ' === undefined) { ';
4384               $bracesCoercion += '}';
4385             }
4386             if (it.opts.coerceTypes == 'array' && $type != 'array') {
4387               out += ' if (' + ($dataType) + ' == \'array\' && ' + ($data) + '.length == 1) { ' + ($coerced) + ' = ' + ($data) + ' = ' + ($data) + '[0]; ' + ($dataType) + ' = typeof ' + ($data) + ';  } ';
4388             }
4389             if ($type == 'string') {
4390               out += ' if (' + ($dataType) + ' == \'number\' || ' + ($dataType) + ' == \'boolean\') ' + ($coerced) + ' = \'\' + ' + ($data) + '; else if (' + ($data) + ' === null) ' + ($coerced) + ' = \'\'; ';
4391             } else if ($type == 'number' || $type == 'integer') {
4392               out += ' if (' + ($dataType) + ' == \'boolean\' || ' + ($data) + ' === null || (' + ($dataType) + ' == \'string\' && ' + ($data) + ' && ' + ($data) + ' == +' + ($data) + ' ';
4393               if ($type == 'integer') {
4394                 out += ' && !(' + ($data) + ' % 1)';
4395               }
4396               out += ')) ' + ($coerced) + ' = +' + ($data) + '; ';
4397             } else if ($type == 'boolean') {
4398               out += ' if (' + ($data) + ' === \'false\' || ' + ($data) + ' === 0 || ' + ($data) + ' === null) ' + ($coerced) + ' = false; else if (' + ($data) + ' === \'true\' || ' + ($data) + ' === 1) ' + ($coerced) + ' = true; ';
4399             } else if ($type == 'null') {
4400               out += ' if (' + ($data) + ' === \'\' || ' + ($data) + ' === 0 || ' + ($data) + ' === false) ' + ($coerced) + ' = null; ';
4401             } else if (it.opts.coerceTypes == 'array' && $type == 'array') {
4402               out += ' if (' + ($dataType) + ' == \'string\' || ' + ($dataType) + ' == \'number\' || ' + ($dataType) + ' == \'boolean\' || ' + ($data) + ' == null) ' + ($coerced) + ' = [' + ($data) + ']; ';
4403             }
4404           }
4405         }
4406         out += ' ' + ($bracesCoercion) + ' if (' + ($coerced) + ' === undefined) {   ';
4407         var $$outStack = $$outStack || [];
4408         $$outStack.push(out);
4409         out = ''; /* istanbul ignore else */
4410         if (it.createErrors !== false) {
4411           out += ' { keyword: \'' + ($errorKeyword || 'type') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { type: \'';
4412           if ($typeIsArray) {
4413             out += '' + ($typeSchema.join(","));
4414           } else {
4415             out += '' + ($typeSchema);
4416           }
4417           out += '\' } ';
4418           if (it.opts.messages !== false) {
4419             out += ' , message: \'should be ';
4420             if ($typeIsArray) {
4421               out += '' + ($typeSchema.join(","));
4422             } else {
4423               out += '' + ($typeSchema);
4424             }
4425             out += '\' ';
4426           }
4427           if (it.opts.verbose) {
4428             out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
4429           }
4430           out += ' } ';
4431         } else {
4432           out += ' {} ';
4433         }
4434         var __err = out;
4435         out = $$outStack.pop();
4436         if (!it.compositeRule && $breakOnError) {
4437           /* istanbul ignore if */
4438           if (it.async) {
4439             out += ' throw new ValidationError([' + (__err) + ']); ';
4440           } else {
4441             out += ' validate.errors = [' + (__err) + ']; return false; ';
4442           }
4443         } else {
4444           out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
4445         }
4446         out += ' } else {  ';
4447         var $parentData = $dataLvl ? 'data' + (($dataLvl - 1) || '') : 'parentData',
4448           $parentDataProperty = $dataLvl ? it.dataPathArr[$dataLvl] : 'parentDataProperty';
4449         out += ' ' + ($data) + ' = ' + ($coerced) + '; ';
4450         if (!$dataLvl) {
4451           out += 'if (' + ($parentData) + ' !== undefined)';
4452         }
4453         out += ' ' + ($parentData) + '[' + ($parentDataProperty) + '] = ' + ($coerced) + '; } ';
4454       } else {
4455         var $$outStack = $$outStack || [];
4456         $$outStack.push(out);
4457         out = ''; /* istanbul ignore else */
4458         if (it.createErrors !== false) {
4459           out += ' { keyword: \'' + ($errorKeyword || 'type') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { type: \'';
4460           if ($typeIsArray) {
4461             out += '' + ($typeSchema.join(","));
4462           } else {
4463             out += '' + ($typeSchema);
4464           }
4465           out += '\' } ';
4466           if (it.opts.messages !== false) {
4467             out += ' , message: \'should be ';
4468             if ($typeIsArray) {
4469               out += '' + ($typeSchema.join(","));
4470             } else {
4471               out += '' + ($typeSchema);
4472             }
4473             out += '\' ';
4474           }
4475           if (it.opts.verbose) {
4476             out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
4477           }
4478           out += ' } ';
4479         } else {
4480           out += ' {} ';
4481         }
4482         var __err = out;
4483         out = $$outStack.pop();
4484         if (!it.compositeRule && $breakOnError) {
4485           /* istanbul ignore if */
4486           if (it.async) {
4487             out += ' throw new ValidationError([' + (__err) + ']); ';
4488           } else {
4489             out += ' validate.errors = [' + (__err) + ']; return false; ';
4490           }
4491         } else {
4492           out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
4493         }
4494       }
4495       out += ' } ';
4496     }
4497   }
4498   if (it.schema.$ref && !$refKeywords) {
4499     out += ' ' + (it.RULES.all.$ref.code(it, '$ref')) + ' ';
4500     if ($breakOnError) {
4501       out += ' } if (errors === ';
4502       if ($top) {
4503         out += '0';
4504       } else {
4505         out += 'errs_' + ($lvl);
4506       }
4507       out += ') { ';
4508       $closingBraces2 += '}';
4509     }
4510   } else {
4511     var arr2 = it.RULES;
4512     if (arr2) {
4513       var $rulesGroup, i2 = -1,
4514         l2 = arr2.length - 1;
4515       while (i2 < l2) {
4516         $rulesGroup = arr2[i2 += 1];
4517         if ($shouldUseGroup($rulesGroup)) {
4518           if ($rulesGroup.type) {
4519             out += ' if (' + (it.util.checkDataType($rulesGroup.type, $data, it.opts.strictNumbers)) + ') { ';
4520           }
4521           if (it.opts.useDefaults) {
4522             if ($rulesGroup.type == 'object' && it.schema.properties) {
4523               var $schema = it.schema.properties,
4524                 $schemaKeys = Object.keys($schema);
4525               var arr3 = $schemaKeys;
4526               if (arr3) {
4527                 var $propertyKey, i3 = -1,
4528                   l3 = arr3.length - 1;
4529                 while (i3 < l3) {
4530                   $propertyKey = arr3[i3 += 1];
4531                   var $sch = $schema[$propertyKey];
4532                   if ($sch.default !== undefined) {
4533                     var $passData = $data + it.util.getProperty($propertyKey);
4534                     if (it.compositeRule) {
4535                       if (it.opts.strictDefaults) {
4536                         var $defaultMsg = 'default is ignored for: ' + $passData;
4537                         if (it.opts.strictDefaults === 'log') it.logger.warn($defaultMsg);
4538                         else throw new Error($defaultMsg);
4539                       }
4540                     } else {
4541                       out += ' if (' + ($passData) + ' === undefined ';
4542                       if (it.opts.useDefaults == 'empty') {
4543                         out += ' || ' + ($passData) + ' === null || ' + ($passData) + ' === \'\' ';
4544                       }
4545                       out += ' ) ' + ($passData) + ' = ';
4546                       if (it.opts.useDefaults == 'shared') {
4547                         out += ' ' + (it.useDefault($sch.default)) + ' ';
4548                       } else {
4549                         out += ' ' + (JSON.stringify($sch.default)) + ' ';
4550                       }
4551                       out += '; ';
4552                     }
4553                   }
4554                 }
4555               }
4556             } else if ($rulesGroup.type == 'array' && Array.isArray(it.schema.items)) {
4557               var arr4 = it.schema.items;
4558               if (arr4) {
4559                 var $sch, $i = -1,
4560                   l4 = arr4.length - 1;
4561                 while ($i < l4) {
4562                   $sch = arr4[$i += 1];
4563                   if ($sch.default !== undefined) {
4564                     var $passData = $data + '[' + $i + ']';
4565                     if (it.compositeRule) {
4566                       if (it.opts.strictDefaults) {
4567                         var $defaultMsg = 'default is ignored for: ' + $passData;
4568                         if (it.opts.strictDefaults === 'log') it.logger.warn($defaultMsg);
4569                         else throw new Error($defaultMsg);
4570                       }
4571                     } else {
4572                       out += ' if (' + ($passData) + ' === undefined ';
4573                       if (it.opts.useDefaults == 'empty') {
4574                         out += ' || ' + ($passData) + ' === null || ' + ($passData) + ' === \'\' ';
4575                       }
4576                       out += ' ) ' + ($passData) + ' = ';
4577                       if (it.opts.useDefaults == 'shared') {
4578                         out += ' ' + (it.useDefault($sch.default)) + ' ';
4579                       } else {
4580                         out += ' ' + (JSON.stringify($sch.default)) + ' ';
4581                       }
4582                       out += '; ';
4583                     }
4584                   }
4585                 }
4586               }
4587             }
4588           }
4589           var arr5 = $rulesGroup.rules;
4590           if (arr5) {
4591             var $rule, i5 = -1,
4592               l5 = arr5.length - 1;
4593             while (i5 < l5) {
4594               $rule = arr5[i5 += 1];
4595               if ($shouldUseRule($rule)) {
4596                 var $code = $rule.code(it, $rule.keyword, $rulesGroup.type);
4597                 if ($code) {
4598                   out += ' ' + ($code) + ' ';
4599                   if ($breakOnError) {
4600                     $closingBraces1 += '}';
4601                   }
4602                 }
4603               }
4604             }
4605           }
4606           if ($breakOnError) {
4607             out += ' ' + ($closingBraces1) + ' ';
4608             $closingBraces1 = '';
4609           }
4610           if ($rulesGroup.type) {
4611             out += ' } ';
4612             if ($typeSchema && $typeSchema === $rulesGroup.type && !$coerceToTypes) {
4613               out += ' else { ';
4614               var $schemaPath = it.schemaPath + '.type',
4615                 $errSchemaPath = it.errSchemaPath + '/type';
4616               var $$outStack = $$outStack || [];
4617               $$outStack.push(out);
4618               out = ''; /* istanbul ignore else */
4619               if (it.createErrors !== false) {
4620                 out += ' { keyword: \'' + ($errorKeyword || 'type') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { type: \'';
4621                 if ($typeIsArray) {
4622                   out += '' + ($typeSchema.join(","));
4623                 } else {
4624                   out += '' + ($typeSchema);
4625                 }
4626                 out += '\' } ';
4627                 if (it.opts.messages !== false) {
4628                   out += ' , message: \'should be ';
4629                   if ($typeIsArray) {
4630                     out += '' + ($typeSchema.join(","));
4631                   } else {
4632                     out += '' + ($typeSchema);
4633                   }
4634                   out += '\' ';
4635                 }
4636                 if (it.opts.verbose) {
4637                   out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
4638                 }
4639                 out += ' } ';
4640               } else {
4641                 out += ' {} ';
4642               }
4643               var __err = out;
4644               out = $$outStack.pop();
4645               if (!it.compositeRule && $breakOnError) {
4646                 /* istanbul ignore if */
4647                 if (it.async) {
4648                   out += ' throw new ValidationError([' + (__err) + ']); ';
4649                 } else {
4650                   out += ' validate.errors = [' + (__err) + ']; return false; ';
4651                 }
4652               } else {
4653                 out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
4654               }
4655               out += ' } ';
4656             }
4657           }
4658           if ($breakOnError) {
4659             out += ' if (errors === ';
4660             if ($top) {
4661               out += '0';
4662             } else {
4663               out += 'errs_' + ($lvl);
4664             }
4665             out += ') { ';
4666             $closingBraces2 += '}';
4667           }
4668         }
4669       }
4670     }
4671   }
4672   if ($breakOnError) {
4673     out += ' ' + ($closingBraces2) + ' ';
4674   }
4675   if ($top) {
4676     if ($async) {
4677       out += ' if (errors === 0) return data;           ';
4678       out += ' else throw new ValidationError(vErrors); ';
4679     } else {
4680       out += ' validate.errors = vErrors; ';
4681       out += ' return errors === 0;       ';
4682     }
4683     out += ' }; return validate;';
4684   } else {
4685     out += ' var ' + ($valid) + ' = errors === errs_' + ($lvl) + ';';
4686   }
4687
4688   function $shouldUseGroup($rulesGroup) {
4689     var rules = $rulesGroup.rules;
4690     for (var i = 0; i < rules.length; i++)
4691       if ($shouldUseRule(rules[i])) return true;
4692   }
4693
4694   function $shouldUseRule($rule) {
4695     return it.schema[$rule.keyword] !== undefined || ($rule.implements && $ruleImplementsSomeKeyword($rule));
4696   }
4697
4698   function $ruleImplementsSomeKeyword($rule) {
4699     var impl = $rule.implements;
4700     for (var i = 0; i < impl.length; i++)
4701       if (it.schema[impl[i]] !== undefined) return true;
4702   }
4703   return out;
4704 }
4705
4706 },{}],39:[function(require,module,exports){
4707 'use strict';
4708
4709 var IDENTIFIER = /^[a-z_$][a-z0-9_$-]*$/i;
4710 var customRuleCode = require('./dotjs/custom');
4711 var definitionSchema = require('./definition_schema');
4712
4713 module.exports = {
4714   add: addKeyword,
4715   get: getKeyword,
4716   remove: removeKeyword,
4717   validate: validateKeyword
4718 };
4719
4720
4721 /**
4722  * Define custom keyword
4723  * @this  Ajv
4724  * @param {String} keyword custom keyword, should be unique (including different from all standard, custom and macro keywords).
4725  * @param {Object} definition keyword definition object with properties `type` (type(s) which the keyword applies to), `validate` or `compile`.
4726  * @return {Ajv} this for method chaining
4727  */
4728 function addKeyword(keyword, definition) {
4729   /* jshint validthis: true */
4730   /* eslint no-shadow: 0 */
4731   var RULES = this.RULES;
4732   if (RULES.keywords[keyword])
4733     throw new Error('Keyword ' + keyword + ' is already defined');
4734
4735   if (!IDENTIFIER.test(keyword))
4736     throw new Error('Keyword ' + keyword + ' is not a valid identifier');
4737
4738   if (definition) {
4739     this.validateKeyword(definition, true);
4740
4741     var dataType = definition.type;
4742     if (Array.isArray(dataType)) {
4743       for (var i=0; i<dataType.length; i++)
4744         _addRule(keyword, dataType[i], definition);
4745     } else {
4746       _addRule(keyword, dataType, definition);
4747     }
4748
4749     var metaSchema = definition.metaSchema;
4750     if (metaSchema) {
4751       if (definition.$data && this._opts.$data) {
4752         metaSchema = {
4753           anyOf: [
4754             metaSchema,
4755             { '$ref': 'https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#' }
4756           ]
4757         };
4758       }
4759       definition.validateSchema = this.compile(metaSchema, true);
4760     }
4761   }
4762
4763   RULES.keywords[keyword] = RULES.all[keyword] = true;
4764
4765
4766   function _addRule(keyword, dataType, definition) {
4767     var ruleGroup;
4768     for (var i=0; i<RULES.length; i++) {
4769       var rg = RULES[i];
4770       if (rg.type == dataType) {
4771         ruleGroup = rg;
4772         break;
4773       }
4774     }
4775
4776     if (!ruleGroup) {
4777       ruleGroup = { type: dataType, rules: [] };
4778       RULES.push(ruleGroup);
4779     }
4780
4781     var rule = {
4782       keyword: keyword,
4783       definition: definition,
4784       custom: true,
4785       code: customRuleCode,
4786       implements: definition.implements
4787     };
4788     ruleGroup.rules.push(rule);
4789     RULES.custom[keyword] = rule;
4790   }
4791
4792   return this;
4793 }
4794
4795
4796 /**
4797  * Get keyword
4798  * @this  Ajv
4799  * @param {String} keyword pre-defined or custom keyword.
4800  * @return {Object|Boolean} custom keyword definition, `true` if it is a predefined keyword, `false` otherwise.
4801  */
4802 function getKeyword(keyword) {
4803   /* jshint validthis: true */
4804   var rule = this.RULES.custom[keyword];
4805   return rule ? rule.definition : this.RULES.keywords[keyword] || false;
4806 }
4807
4808
4809 /**
4810  * Remove keyword
4811  * @this  Ajv
4812  * @param {String} keyword pre-defined or custom keyword.
4813  * @return {Ajv} this for method chaining
4814  */
4815 function removeKeyword(keyword) {
4816   /* jshint validthis: true */
4817   var RULES = this.RULES;
4818   delete RULES.keywords[keyword];
4819   delete RULES.all[keyword];
4820   delete RULES.custom[keyword];
4821   for (var i=0; i<RULES.length; i++) {
4822     var rules = RULES[i].rules;
4823     for (var j=0; j<rules.length; j++) {
4824       if (rules[j].keyword == keyword) {
4825         rules.splice(j, 1);
4826         break;
4827       }
4828     }
4829   }
4830   return this;
4831 }
4832
4833
4834 /**
4835  * Validate keyword definition
4836  * @this  Ajv
4837  * @param {Object} definition keyword definition object.
4838  * @param {Boolean} throwError true to throw exception if definition is invalid
4839  * @return {boolean} validation result
4840  */
4841 function validateKeyword(definition, throwError) {
4842   validateKeyword.errors = null;
4843   var v = this._validateKeyword = this._validateKeyword
4844                                   || this.compile(definitionSchema, true);
4845
4846   if (v(definition)) return true;
4847   validateKeyword.errors = v.errors;
4848   if (throwError)
4849     throw new Error('custom keyword definition is invalid: '  + this.errorsText(v.errors));
4850   else
4851     return false;
4852 }
4853
4854 },{"./definition_schema":12,"./dotjs/custom":22}],40:[function(require,module,exports){
4855 module.exports={
4856     "$schema": "http://json-schema.org/draft-07/schema#",
4857     "$id": "https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",
4858     "description": "Meta-schema for $data reference (JSON Schema extension proposal)",
4859     "type": "object",
4860     "required": [ "$data" ],
4861     "properties": {
4862         "$data": {
4863             "type": "string",
4864             "anyOf": [
4865                 { "format": "relative-json-pointer" }, 
4866                 { "format": "json-pointer" }
4867             ]
4868         }
4869     },
4870     "additionalProperties": false
4871 }
4872
4873 },{}],41:[function(require,module,exports){
4874 module.exports={
4875     "$schema": "http://json-schema.org/draft-07/schema#",
4876     "$id": "http://json-schema.org/draft-07/schema#",
4877     "title": "Core schema meta-schema",
4878     "definitions": {
4879         "schemaArray": {
4880             "type": "array",
4881             "minItems": 1,
4882             "items": { "$ref": "#" }
4883         },
4884         "nonNegativeInteger": {
4885             "type": "integer",
4886             "minimum": 0
4887         },
4888         "nonNegativeIntegerDefault0": {
4889             "allOf": [
4890                 { "$ref": "#/definitions/nonNegativeInteger" },
4891                 { "default": 0 }
4892             ]
4893         },
4894         "simpleTypes": {
4895             "enum": [
4896                 "array",
4897                 "boolean",
4898                 "integer",
4899                 "null",
4900                 "number",
4901                 "object",
4902                 "string"
4903             ]
4904         },
4905         "stringArray": {
4906             "type": "array",
4907             "items": { "type": "string" },
4908             "uniqueItems": true,
4909             "default": []
4910         }
4911     },
4912     "type": ["object", "boolean"],
4913     "properties": {
4914         "$id": {
4915             "type": "string",
4916             "format": "uri-reference"
4917         },
4918         "$schema": {
4919             "type": "string",
4920             "format": "uri"
4921         },
4922         "$ref": {
4923             "type": "string",
4924             "format": "uri-reference"
4925         },
4926         "$comment": {
4927             "type": "string"
4928         },
4929         "title": {
4930             "type": "string"
4931         },
4932         "description": {
4933             "type": "string"
4934         },
4935         "default": true,
4936         "readOnly": {
4937             "type": "boolean",
4938             "default": false
4939         },
4940         "examples": {
4941             "type": "array",
4942             "items": true
4943         },
4944         "multipleOf": {
4945             "type": "number",
4946             "exclusiveMinimum": 0
4947         },
4948         "maximum": {
4949             "type": "number"
4950         },
4951         "exclusiveMaximum": {
4952             "type": "number"
4953         },
4954         "minimum": {
4955             "type": "number"
4956         },
4957         "exclusiveMinimum": {
4958             "type": "number"
4959         },
4960         "maxLength": { "$ref": "#/definitions/nonNegativeInteger" },
4961         "minLength": { "$ref": "#/definitions/nonNegativeIntegerDefault0" },
4962         "pattern": {
4963             "type": "string",
4964             "format": "regex"
4965         },
4966         "additionalItems": { "$ref": "#" },
4967         "items": {
4968             "anyOf": [
4969                 { "$ref": "#" },
4970                 { "$ref": "#/definitions/schemaArray" }
4971             ],
4972             "default": true
4973         },
4974         "maxItems": { "$ref": "#/definitions/nonNegativeInteger" },
4975         "minItems": { "$ref": "#/definitions/nonNegativeIntegerDefault0" },
4976         "uniqueItems": {
4977             "type": "boolean",
4978             "default": false
4979         },
4980         "contains": { "$ref": "#" },
4981         "maxProperties": { "$ref": "#/definitions/nonNegativeInteger" },
4982         "minProperties": { "$ref": "#/definitions/nonNegativeIntegerDefault0" },
4983         "required": { "$ref": "#/definitions/stringArray" },
4984         "additionalProperties": { "$ref": "#" },
4985         "definitions": {
4986             "type": "object",
4987             "additionalProperties": { "$ref": "#" },
4988             "default": {}
4989         },
4990         "properties": {
4991             "type": "object",
4992             "additionalProperties": { "$ref": "#" },
4993             "default": {}
4994         },
4995         "patternProperties": {
4996             "type": "object",
4997             "additionalProperties": { "$ref": "#" },
4998             "propertyNames": { "format": "regex" },
4999             "default": {}
5000         },
5001         "dependencies": {
5002             "type": "object",
5003             "additionalProperties": {
5004                 "anyOf": [
5005                     { "$ref": "#" },
5006                     { "$ref": "#/definitions/stringArray" }
5007                 ]
5008             }
5009         },
5010         "propertyNames": { "$ref": "#" },
5011         "const": true,
5012         "enum": {
5013             "type": "array",
5014             "items": true,
5015             "minItems": 1,
5016             "uniqueItems": true
5017         },
5018         "type": {
5019             "anyOf": [
5020                 { "$ref": "#/definitions/simpleTypes" },
5021                 {
5022                     "type": "array",
5023                     "items": { "$ref": "#/definitions/simpleTypes" },
5024                     "minItems": 1,
5025                     "uniqueItems": true
5026                 }
5027             ]
5028         },
5029         "format": { "type": "string" },
5030         "contentMediaType": { "type": "string" },
5031         "contentEncoding": { "type": "string" },
5032         "if": {"$ref": "#"},
5033         "then": {"$ref": "#"},
5034         "else": {"$ref": "#"},
5035         "allOf": { "$ref": "#/definitions/schemaArray" },
5036         "anyOf": { "$ref": "#/definitions/schemaArray" },
5037         "oneOf": { "$ref": "#/definitions/schemaArray" },
5038         "not": { "$ref": "#" }
5039     },
5040     "default": true
5041 }
5042
5043 },{}],42:[function(require,module,exports){
5044 'use strict';
5045
5046 // do not edit .js files directly - edit src/index.jst
5047
5048
5049
5050 module.exports = function equal(a, b) {
5051   if (a === b) return true;
5052
5053   if (a && b && typeof a == 'object' && typeof b == 'object') {
5054     if (a.constructor !== b.constructor) return false;
5055
5056     var length, i, keys;
5057     if (Array.isArray(a)) {
5058       length = a.length;
5059       if (length != b.length) return false;
5060       for (i = length; i-- !== 0;)
5061         if (!equal(a[i], b[i])) return false;
5062       return true;
5063     }
5064
5065
5066
5067     if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
5068     if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
5069     if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
5070
5071     keys = Object.keys(a);
5072     length = keys.length;
5073     if (length !== Object.keys(b).length) return false;
5074
5075     for (i = length; i-- !== 0;)
5076       if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
5077
5078     for (i = length; i-- !== 0;) {
5079       var key = keys[i];
5080
5081       if (!equal(a[key], b[key])) return false;
5082     }
5083
5084     return true;
5085   }
5086
5087   // true if both NaN, false otherwise
5088   return a!==a && b!==b;
5089 };
5090
5091 },{}],43:[function(require,module,exports){
5092 'use strict';
5093
5094 module.exports = function (data, opts) {
5095     if (!opts) opts = {};
5096     if (typeof opts === 'function') opts = { cmp: opts };
5097     var cycles = (typeof opts.cycles === 'boolean') ? opts.cycles : false;
5098
5099     var cmp = opts.cmp && (function (f) {
5100         return function (node) {
5101             return function (a, b) {
5102                 var aobj = { key: a, value: node[a] };
5103                 var bobj = { key: b, value: node[b] };
5104                 return f(aobj, bobj);
5105             };
5106         };
5107     })(opts.cmp);
5108
5109     var seen = [];
5110     return (function stringify (node) {
5111         if (node && node.toJSON && typeof node.toJSON === 'function') {
5112             node = node.toJSON();
5113         }
5114
5115         if (node === undefined) return;
5116         if (typeof node == 'number') return isFinite(node) ? '' + node : 'null';
5117         if (typeof node !== 'object') return JSON.stringify(node);
5118
5119         var i, out;
5120         if (Array.isArray(node)) {
5121             out = '[';
5122             for (i = 0; i < node.length; i++) {
5123                 if (i) out += ',';
5124                 out += stringify(node[i]) || 'null';
5125             }
5126             return out + ']';
5127         }
5128
5129         if (node === null) return 'null';
5130
5131         if (seen.indexOf(node) !== -1) {
5132             if (cycles) return JSON.stringify('__cycle__');
5133             throw new TypeError('Converting circular structure to JSON');
5134         }
5135
5136         var seenIndex = seen.push(node) - 1;
5137         var keys = Object.keys(node).sort(cmp && cmp(node));
5138         out = '';
5139         for (i = 0; i < keys.length; i++) {
5140             var key = keys[i];
5141             var value = stringify(node[key]);
5142
5143             if (!value) continue;
5144             if (out) out += ',';
5145             out += JSON.stringify(key) + ':' + value;
5146         }
5147         seen.splice(seenIndex, 1);
5148         return '{' + out + '}';
5149     })(data);
5150 };
5151
5152 },{}],44:[function(require,module,exports){
5153 'use strict';
5154
5155 var traverse = module.exports = function (schema, opts, cb) {
5156   // Legacy support for v0.3.1 and earlier.
5157   if (typeof opts == 'function') {
5158     cb = opts;
5159     opts = {};
5160   }
5161
5162   cb = opts.cb || cb;
5163   var pre = (typeof cb == 'function') ? cb : cb.pre || function() {};
5164   var post = cb.post || function() {};
5165
5166   _traverse(opts, pre, post, schema, '', schema);
5167 };
5168
5169
5170 traverse.keywords = {
5171   additionalItems: true,
5172   items: true,
5173   contains: true,
5174   additionalProperties: true,
5175   propertyNames: true,
5176   not: true
5177 };
5178
5179 traverse.arrayKeywords = {
5180   items: true,
5181   allOf: true,
5182   anyOf: true,
5183   oneOf: true
5184 };
5185
5186 traverse.propsKeywords = {
5187   definitions: true,
5188   properties: true,
5189   patternProperties: true,
5190   dependencies: true
5191 };
5192
5193 traverse.skipKeywords = {
5194   default: true,
5195   enum: true,
5196   const: true,
5197   required: true,
5198   maximum: true,
5199   minimum: true,
5200   exclusiveMaximum: true,
5201   exclusiveMinimum: true,
5202   multipleOf: true,
5203   maxLength: true,
5204   minLength: true,
5205   pattern: true,
5206   format: true,
5207   maxItems: true,
5208   minItems: true,
5209   uniqueItems: true,
5210   maxProperties: true,
5211   minProperties: true
5212 };
5213
5214
5215 function _traverse(opts, pre, post, schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex) {
5216   if (schema && typeof schema == 'object' && !Array.isArray(schema)) {
5217     pre(schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex);
5218     for (var key in schema) {
5219       var sch = schema[key];
5220       if (Array.isArray(sch)) {
5221         if (key in traverse.arrayKeywords) {
5222           for (var i=0; i<sch.length; i++)
5223             _traverse(opts, pre, post, sch[i], jsonPtr + '/' + key + '/' + i, rootSchema, jsonPtr, key, schema, i);
5224         }
5225       } else if (key in traverse.propsKeywords) {
5226         if (sch && typeof sch == 'object') {
5227           for (var prop in sch)
5228             _traverse(opts, pre, post, sch[prop], jsonPtr + '/' + key + '/' + escapeJsonPtr(prop), rootSchema, jsonPtr, key, schema, prop);
5229         }
5230       } else if (key in traverse.keywords || (opts.allKeys && !(key in traverse.skipKeywords))) {
5231         _traverse(opts, pre, post, sch, jsonPtr + '/' + key, rootSchema, jsonPtr, key, schema);
5232       }
5233     }
5234     post(schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex);
5235   }
5236 }
5237
5238
5239 function escapeJsonPtr(str) {
5240   return str.replace(/~/g, '~0').replace(/\//g, '~1');
5241 }
5242
5243 },{}],45:[function(require,module,exports){
5244 /** @license URI.js v4.2.1 (c) 2011 Gary Court. License: http://github.com/garycourt/uri-js */
5245 (function (global, factory) {
5246         typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
5247         typeof define === 'function' && define.amd ? define(['exports'], factory) :
5248         (factory((global.URI = global.URI || {})));
5249 }(this, (function (exports) { 'use strict';
5250
5251 function merge() {
5252     for (var _len = arguments.length, sets = Array(_len), _key = 0; _key < _len; _key++) {
5253         sets[_key] = arguments[_key];
5254     }
5255
5256     if (sets.length > 1) {
5257         sets[0] = sets[0].slice(0, -1);
5258         var xl = sets.length - 1;
5259         for (var x = 1; x < xl; ++x) {
5260             sets[x] = sets[x].slice(1, -1);
5261         }
5262         sets[xl] = sets[xl].slice(1);
5263         return sets.join('');
5264     } else {
5265         return sets[0];
5266     }
5267 }
5268 function subexp(str) {
5269     return "(?:" + str + ")";
5270 }
5271 function typeOf(o) {
5272     return o === undefined ? "undefined" : o === null ? "null" : Object.prototype.toString.call(o).split(" ").pop().split("]").shift().toLowerCase();
5273 }
5274 function toUpperCase(str) {
5275     return str.toUpperCase();
5276 }
5277 function toArray(obj) {
5278     return obj !== undefined && obj !== null ? obj instanceof Array ? obj : typeof obj.length !== "number" || obj.split || obj.setInterval || obj.call ? [obj] : Array.prototype.slice.call(obj) : [];
5279 }
5280 function assign(target, source) {
5281     var obj = target;
5282     if (source) {
5283         for (var key in source) {
5284             obj[key] = source[key];
5285         }
5286     }
5287     return obj;
5288 }
5289
5290 function buildExps(isIRI) {
5291     var ALPHA$$ = "[A-Za-z]",
5292         CR$ = "[\\x0D]",
5293         DIGIT$$ = "[0-9]",
5294         DQUOTE$$ = "[\\x22]",
5295         HEXDIG$$ = merge(DIGIT$$, "[A-Fa-f]"),
5296         //case-insensitive
5297     LF$$ = "[\\x0A]",
5298         SP$$ = "[\\x20]",
5299         PCT_ENCODED$ = subexp(subexp("%[EFef]" + HEXDIG$$ + "%" + HEXDIG$$ + HEXDIG$$ + "%" + HEXDIG$$ + HEXDIG$$) + "|" + subexp("%[89A-Fa-f]" + HEXDIG$$ + "%" + HEXDIG$$ + HEXDIG$$) + "|" + subexp("%" + HEXDIG$$ + HEXDIG$$)),
5300         //expanded
5301     GEN_DELIMS$$ = "[\\:\\/\\?\\#\\[\\]\\@]",
5302         SUB_DELIMS$$ = "[\\!\\$\\&\\'\\(\\)\\*\\+\\,\\;\\=]",
5303         RESERVED$$ = merge(GEN_DELIMS$$, SUB_DELIMS$$),
5304         UCSCHAR$$ = isIRI ? "[\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]" : "[]",
5305         //subset, excludes bidi control characters
5306     IPRIVATE$$ = isIRI ? "[\\uE000-\\uF8FF]" : "[]",
5307         //subset
5308     UNRESERVED$$ = merge(ALPHA$$, DIGIT$$, "[\\-\\.\\_\\~]", UCSCHAR$$),
5309         SCHEME$ = subexp(ALPHA$$ + merge(ALPHA$$, DIGIT$$, "[\\+\\-\\.]") + "*"),
5310         USERINFO$ = subexp(subexp(PCT_ENCODED$ + "|" + merge(UNRESERVED$$, SUB_DELIMS$$, "[\\:]")) + "*"),
5311         DEC_OCTET$ = subexp(subexp("25[0-5]") + "|" + subexp("2[0-4]" + DIGIT$$) + "|" + subexp("1" + DIGIT$$ + DIGIT$$) + "|" + subexp("[1-9]" + DIGIT$$) + "|" + DIGIT$$),
5312         DEC_OCTET_RELAXED$ = subexp(subexp("25[0-5]") + "|" + subexp("2[0-4]" + DIGIT$$) + "|" + subexp("1" + DIGIT$$ + DIGIT$$) + "|" + subexp("0?[1-9]" + DIGIT$$) + "|0?0?" + DIGIT$$),
5313         //relaxed parsing rules
5314     IPV4ADDRESS$ = subexp(DEC_OCTET_RELAXED$ + "\\." + DEC_OCTET_RELAXED$ + "\\." + DEC_OCTET_RELAXED$ + "\\." + DEC_OCTET_RELAXED$),
5315         H16$ = subexp(HEXDIG$$ + "{1,4}"),
5316         LS32$ = subexp(subexp(H16$ + "\\:" + H16$) + "|" + IPV4ADDRESS$),
5317         IPV6ADDRESS1$ = subexp(subexp(H16$ + "\\:") + "{6}" + LS32$),
5318         //                           6( h16 ":" ) ls32
5319     IPV6ADDRESS2$ = subexp("\\:\\:" + subexp(H16$ + "\\:") + "{5}" + LS32$),
5320         //                      "::" 5( h16 ":" ) ls32
5321     IPV6ADDRESS3$ = subexp(subexp(H16$) + "?\\:\\:" + subexp(H16$ + "\\:") + "{4}" + LS32$),
5322         //[               h16 ] "::" 4( h16 ":" ) ls32
5323     IPV6ADDRESS4$ = subexp(subexp(subexp(H16$ + "\\:") + "{0,1}" + H16$) + "?\\:\\:" + subexp(H16$ + "\\:") + "{3}" + LS32$),
5324         //[ *1( h16 ":" ) h16 ] "::" 3( h16 ":" ) ls32
5325     IPV6ADDRESS5$ = subexp(subexp(subexp(H16$ + "\\:") + "{0,2}" + H16$) + "?\\:\\:" + subexp(H16$ + "\\:") + "{2}" + LS32$),
5326         //[ *2( h16 ":" ) h16 ] "::" 2( h16 ":" ) ls32
5327     IPV6ADDRESS6$ = subexp(subexp(subexp(H16$ + "\\:") + "{0,3}" + H16$) + "?\\:\\:" + H16$ + "\\:" + LS32$),
5328         //[ *3( h16 ":" ) h16 ] "::"    h16 ":"   ls32
5329     IPV6ADDRESS7$ = subexp(subexp(subexp(H16$ + "\\:") + "{0,4}" + H16$) + "?\\:\\:" + LS32$),
5330         //[ *4( h16 ":" ) h16 ] "::"              ls32
5331     IPV6ADDRESS8$ = subexp(subexp(subexp(H16$ + "\\:") + "{0,5}" + H16$) + "?\\:\\:" + H16$),
5332         //[ *5( h16 ":" ) h16 ] "::"              h16
5333     IPV6ADDRESS9$ = subexp(subexp(subexp(H16$ + "\\:") + "{0,6}" + H16$) + "?\\:\\:"),
5334         //[ *6( h16 ":" ) h16 ] "::"
5335     IPV6ADDRESS$ = subexp([IPV6ADDRESS1$, IPV6ADDRESS2$, IPV6ADDRESS3$, IPV6ADDRESS4$, IPV6ADDRESS5$, IPV6ADDRESS6$, IPV6ADDRESS7$, IPV6ADDRESS8$, IPV6ADDRESS9$].join("|")),
5336         ZONEID$ = subexp(subexp(UNRESERVED$$ + "|" + PCT_ENCODED$) + "+"),
5337         //RFC 6874
5338     IPV6ADDRZ$ = subexp(IPV6ADDRESS$ + "\\%25" + ZONEID$),
5339         //RFC 6874
5340     IPV6ADDRZ_RELAXED$ = subexp(IPV6ADDRESS$ + subexp("\\%25|\\%(?!" + HEXDIG$$ + "{2})") + ZONEID$),
5341         //RFC 6874, with relaxed parsing rules
5342     IPVFUTURE$ = subexp("[vV]" + HEXDIG$$ + "+\\." + merge(UNRESERVED$$, SUB_DELIMS$$, "[\\:]") + "+"),
5343         IP_LITERAL$ = subexp("\\[" + subexp(IPV6ADDRZ_RELAXED$ + "|" + IPV6ADDRESS$ + "|" + IPVFUTURE$) + "\\]"),
5344         //RFC 6874
5345     REG_NAME$ = subexp(subexp(PCT_ENCODED$ + "|" + merge(UNRESERVED$$, SUB_DELIMS$$)) + "*"),
5346         HOST$ = subexp(IP_LITERAL$ + "|" + IPV4ADDRESS$ + "(?!" + REG_NAME$ + ")" + "|" + REG_NAME$),
5347         PORT$ = subexp(DIGIT$$ + "*"),
5348         AUTHORITY$ = subexp(subexp(USERINFO$ + "@") + "?" + HOST$ + subexp("\\:" + PORT$) + "?"),
5349         PCHAR$ = subexp(PCT_ENCODED$ + "|" + merge(UNRESERVED$$, SUB_DELIMS$$, "[\\:\\@]")),
5350         SEGMENT$ = subexp(PCHAR$ + "*"),
5351         SEGMENT_NZ$ = subexp(PCHAR$ + "+"),
5352         SEGMENT_NZ_NC$ = subexp(subexp(PCT_ENCODED$ + "|" + merge(UNRESERVED$$, SUB_DELIMS$$, "[\\@]")) + "+"),
5353         PATH_ABEMPTY$ = subexp(subexp("\\/" + SEGMENT$) + "*"),
5354         PATH_ABSOLUTE$ = subexp("\\/" + subexp(SEGMENT_NZ$ + PATH_ABEMPTY$) + "?"),
5355         //simplified
5356     PATH_NOSCHEME$ = subexp(SEGMENT_NZ_NC$ + PATH_ABEMPTY$),
5357         //simplified
5358     PATH_ROOTLESS$ = subexp(SEGMENT_NZ$ + PATH_ABEMPTY$),
5359         //simplified
5360     PATH_EMPTY$ = "(?!" + PCHAR$ + ")",
5361         PATH$ = subexp(PATH_ABEMPTY$ + "|" + PATH_ABSOLUTE$ + "|" + PATH_NOSCHEME$ + "|" + PATH_ROOTLESS$ + "|" + PATH_EMPTY$),
5362         QUERY$ = subexp(subexp(PCHAR$ + "|" + merge("[\\/\\?]", IPRIVATE$$)) + "*"),
5363         FRAGMENT$ = subexp(subexp(PCHAR$ + "|[\\/\\?]") + "*"),
5364         HIER_PART$ = subexp(subexp("\\/\\/" + AUTHORITY$ + PATH_ABEMPTY$) + "|" + PATH_ABSOLUTE$ + "|" + PATH_ROOTLESS$ + "|" + PATH_EMPTY$),
5365         URI$ = subexp(SCHEME$ + "\\:" + HIER_PART$ + subexp("\\?" + QUERY$) + "?" + subexp("\\#" + FRAGMENT$) + "?"),
5366         RELATIVE_PART$ = subexp(subexp("\\/\\/" + AUTHORITY$ + PATH_ABEMPTY$) + "|" + PATH_ABSOLUTE$ + "|" + PATH_NOSCHEME$ + "|" + PATH_EMPTY$),
5367         RELATIVE$ = subexp(RELATIVE_PART$ + subexp("\\?" + QUERY$) + "?" + subexp("\\#" + FRAGMENT$) + "?"),
5368         URI_REFERENCE$ = subexp(URI$ + "|" + RELATIVE$),
5369         ABSOLUTE_URI$ = subexp(SCHEME$ + "\\:" + HIER_PART$ + subexp("\\?" + QUERY$) + "?"),
5370         GENERIC_REF$ = "^(" + SCHEME$ + ")\\:" + subexp(subexp("\\/\\/(" + subexp("(" + USERINFO$ + ")@") + "?(" + HOST$ + ")" + subexp("\\:(" + PORT$ + ")") + "?)") + "?(" + PATH_ABEMPTY$ + "|" + PATH_ABSOLUTE$ + "|" + PATH_ROOTLESS$ + "|" + PATH_EMPTY$ + ")") + subexp("\\?(" + QUERY$ + ")") + "?" + subexp("\\#(" + FRAGMENT$ + ")") + "?$",
5371         RELATIVE_REF$ = "^(){0}" + subexp(subexp("\\/\\/(" + subexp("(" + USERINFO$ + ")@") + "?(" + HOST$ + ")" + subexp("\\:(" + PORT$ + ")") + "?)") + "?(" + PATH_ABEMPTY$ + "|" + PATH_ABSOLUTE$ + "|" + PATH_NOSCHEME$ + "|" + PATH_EMPTY$ + ")") + subexp("\\?(" + QUERY$ + ")") + "?" + subexp("\\#(" + FRAGMENT$ + ")") + "?$",
5372         ABSOLUTE_REF$ = "^(" + SCHEME$ + ")\\:" + subexp(subexp("\\/\\/(" + subexp("(" + USERINFO$ + ")@") + "?(" + HOST$ + ")" + subexp("\\:(" + PORT$ + ")") + "?)") + "?(" + PATH_ABEMPTY$ + "|" + PATH_ABSOLUTE$ + "|" + PATH_ROOTLESS$ + "|" + PATH_EMPTY$ + ")") + subexp("\\?(" + QUERY$ + ")") + "?$",
5373         SAMEDOC_REF$ = "^" + subexp("\\#(" + FRAGMENT$ + ")") + "?$",
5374         AUTHORITY_REF$ = "^" + subexp("(" + USERINFO$ + ")@") + "?(" + HOST$ + ")" + subexp("\\:(" + PORT$ + ")") + "?$";
5375     return {
5376         NOT_SCHEME: new RegExp(merge("[^]", ALPHA$$, DIGIT$$, "[\\+\\-\\.]"), "g"),
5377         NOT_USERINFO: new RegExp(merge("[^\\%\\:]", UNRESERVED$$, SUB_DELIMS$$), "g"),
5378         NOT_HOST: new RegExp(merge("[^\\%\\[\\]\\:]", UNRESERVED$$, SUB_DELIMS$$), "g"),
5379         NOT_PATH: new RegExp(merge("[^\\%\\/\\:\\@]", UNRESERVED$$, SUB_DELIMS$$), "g"),
5380         NOT_PATH_NOSCHEME: new RegExp(merge("[^\\%\\/\\@]", UNRESERVED$$, SUB_DELIMS$$), "g"),
5381         NOT_QUERY: new RegExp(merge("[^\\%]", UNRESERVED$$, SUB_DELIMS$$, "[\\:\\@\\/\\?]", IPRIVATE$$), "g"),
5382         NOT_FRAGMENT: new RegExp(merge("[^\\%]", UNRESERVED$$, SUB_DELIMS$$, "[\\:\\@\\/\\?]"), "g"),
5383         ESCAPE: new RegExp(merge("[^]", UNRESERVED$$, SUB_DELIMS$$), "g"),
5384         UNRESERVED: new RegExp(UNRESERVED$$, "g"),
5385         OTHER_CHARS: new RegExp(merge("[^\\%]", UNRESERVED$$, RESERVED$$), "g"),
5386         PCT_ENCODED: new RegExp(PCT_ENCODED$, "g"),
5387         IPV4ADDRESS: new RegExp("^(" + IPV4ADDRESS$ + ")$"),
5388         IPV6ADDRESS: new RegExp("^\\[?(" + IPV6ADDRESS$ + ")" + subexp(subexp("\\%25|\\%(?!" + HEXDIG$$ + "{2})") + "(" + ZONEID$ + ")") + "?\\]?$") //RFC 6874, with relaxed parsing rules
5389     };
5390 }
5391 var URI_PROTOCOL = buildExps(false);
5392
5393 var IRI_PROTOCOL = buildExps(true);
5394
5395 var slicedToArray = function () {
5396   function sliceIterator(arr, i) {
5397     var _arr = [];
5398     var _n = true;
5399     var _d = false;
5400     var _e = undefined;
5401
5402     try {
5403       for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
5404         _arr.push(_s.value);
5405
5406         if (i && _arr.length === i) break;
5407       }
5408     } catch (err) {
5409       _d = true;
5410       _e = err;
5411     } finally {
5412       try {
5413         if (!_n && _i["return"]) _i["return"]();
5414       } finally {
5415         if (_d) throw _e;
5416       }
5417     }
5418
5419     return _arr;
5420   }
5421
5422   return function (arr, i) {
5423     if (Array.isArray(arr)) {
5424       return arr;
5425     } else if (Symbol.iterator in Object(arr)) {
5426       return sliceIterator(arr, i);
5427     } else {
5428       throw new TypeError("Invalid attempt to destructure non-iterable instance");
5429     }
5430   };
5431 }();
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445 var toConsumableArray = function (arr) {
5446   if (Array.isArray(arr)) {
5447     for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
5448
5449     return arr2;
5450   } else {
5451     return Array.from(arr);
5452   }
5453 };
5454
5455 /** Highest positive signed 32-bit float value */
5456
5457 var maxInt = 2147483647; // aka. 0x7FFFFFFF or 2^31-1
5458
5459 /** Bootstring parameters */
5460 var base = 36;
5461 var tMin = 1;
5462 var tMax = 26;
5463 var skew = 38;
5464 var damp = 700;
5465 var initialBias = 72;
5466 var initialN = 128; // 0x80
5467 var delimiter = '-'; // '\x2D'
5468
5469 /** Regular expressions */
5470 var regexPunycode = /^xn--/;
5471 var regexNonASCII = /[^\0-\x7E]/; // non-ASCII chars
5472 var regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g; // RFC 3490 separators
5473
5474 /** Error messages */
5475 var errors = {
5476         'overflow': 'Overflow: input needs wider integers to process',
5477         'not-basic': 'Illegal input >= 0x80 (not a basic code point)',
5478         'invalid-input': 'Invalid input'
5479 };
5480
5481 /** Convenience shortcuts */
5482 var baseMinusTMin = base - tMin;
5483 var floor = Math.floor;
5484 var stringFromCharCode = String.fromCharCode;
5485
5486 /*--------------------------------------------------------------------------*/
5487
5488 /**
5489  * A generic error utility function.
5490  * @private
5491  * @param {String} type The error type.
5492  * @returns {Error} Throws a `RangeError` with the applicable error message.
5493  */
5494 function error$1(type) {
5495         throw new RangeError(errors[type]);
5496 }
5497
5498 /**
5499  * A generic `Array#map` utility function.
5500  * @private
5501  * @param {Array} array The array to iterate over.
5502  * @param {Function} callback The function that gets called for every array
5503  * item.
5504  * @returns {Array} A new array of values returned by the callback function.
5505  */
5506 function map(array, fn) {
5507         var result = [];
5508         var length = array.length;
5509         while (length--) {
5510                 result[length] = fn(array[length]);
5511         }
5512         return result;
5513 }
5514
5515 /**
5516  * A simple `Array#map`-like wrapper to work with domain name strings or email
5517  * addresses.
5518  * @private
5519  * @param {String} domain The domain name or email address.
5520  * @param {Function} callback The function that gets called for every
5521  * character.
5522  * @returns {Array} A new string of characters returned by the callback
5523  * function.
5524  */
5525 function mapDomain(string, fn) {
5526         var parts = string.split('@');
5527         var result = '';
5528         if (parts.length > 1) {
5529                 // In email addresses, only the domain name should be punycoded. Leave
5530                 // the local part (i.e. everything up to `@`) intact.
5531                 result = parts[0] + '@';
5532                 string = parts[1];
5533         }
5534         // Avoid `split(regex)` for IE8 compatibility. See #17.
5535         string = string.replace(regexSeparators, '\x2E');
5536         var labels = string.split('.');
5537         var encoded = map(labels, fn).join('.');
5538         return result + encoded;
5539 }
5540
5541 /**
5542  * Creates an array containing the numeric code points of each Unicode
5543  * character in the string. While JavaScript uses UCS-2 internally,
5544  * this function will convert a pair of surrogate halves (each of which
5545  * UCS-2 exposes as separate characters) into a single code point,
5546  * matching UTF-16.
5547  * @see `punycode.ucs2.encode`
5548  * @see <https://mathiasbynens.be/notes/javascript-encoding>
5549  * @memberOf punycode.ucs2
5550  * @name decode
5551  * @param {String} string The Unicode input string (UCS-2).
5552  * @returns {Array} The new array of code points.
5553  */
5554 function ucs2decode(string) {
5555         var output = [];
5556         var counter = 0;
5557         var length = string.length;
5558         while (counter < length) {
5559                 var value = string.charCodeAt(counter++);
5560                 if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
5561                         // It's a high surrogate, and there is a next character.
5562                         var extra = string.charCodeAt(counter++);
5563                         if ((extra & 0xFC00) == 0xDC00) {
5564                                 // Low surrogate.
5565                                 output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
5566                         } else {
5567                                 // It's an unmatched surrogate; only append this code unit, in case the
5568                                 // next code unit is the high surrogate of a surrogate pair.
5569                                 output.push(value);
5570                                 counter--;
5571                         }
5572                 } else {
5573                         output.push(value);
5574                 }
5575         }
5576         return output;
5577 }
5578
5579 /**
5580  * Creates a string based on an array of numeric code points.
5581  * @see `punycode.ucs2.decode`
5582  * @memberOf punycode.ucs2
5583  * @name encode
5584  * @param {Array} codePoints The array of numeric code points.
5585  * @returns {String} The new Unicode string (UCS-2).
5586  */
5587 var ucs2encode = function ucs2encode(array) {
5588         return String.fromCodePoint.apply(String, toConsumableArray(array));
5589 };
5590
5591 /**
5592  * Converts a basic code point into a digit/integer.
5593  * @see `digitToBasic()`
5594  * @private
5595  * @param {Number} codePoint The basic numeric code point value.
5596  * @returns {Number} The numeric value of a basic code point (for use in
5597  * representing integers) in the range `0` to `base - 1`, or `base` if
5598  * the code point does not represent a value.
5599  */
5600 var basicToDigit = function basicToDigit(codePoint) {
5601         if (codePoint - 0x30 < 0x0A) {
5602                 return codePoint - 0x16;
5603         }
5604         if (codePoint - 0x41 < 0x1A) {
5605                 return codePoint - 0x41;
5606         }
5607         if (codePoint - 0x61 < 0x1A) {
5608                 return codePoint - 0x61;
5609         }
5610         return base;
5611 };
5612
5613 /**
5614  * Converts a digit/integer into a basic code point.
5615  * @see `basicToDigit()`
5616  * @private
5617  * @param {Number} digit The numeric value of a basic code point.
5618  * @returns {Number} The basic code point whose value (when used for
5619  * representing integers) is `digit`, which needs to be in the range
5620  * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is
5621  * used; else, the lowercase form is used. The behavior is undefined
5622  * if `flag` is non-zero and `digit` has no uppercase form.
5623  */
5624 var digitToBasic = function digitToBasic(digit, flag) {
5625         //  0..25 map to ASCII a..z or A..Z
5626         // 26..35 map to ASCII 0..9
5627         return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
5628 };
5629
5630 /**
5631  * Bias adaptation function as per section 3.4 of RFC 3492.
5632  * https://tools.ietf.org/html/rfc3492#section-3.4
5633  * @private
5634  */
5635 var adapt = function adapt(delta, numPoints, firstTime) {
5636         var k = 0;
5637         delta = firstTime ? floor(delta / damp) : delta >> 1;
5638         delta += floor(delta / numPoints);
5639         for (; /* no initialization */delta > baseMinusTMin * tMax >> 1; k += base) {
5640                 delta = floor(delta / baseMinusTMin);
5641         }
5642         return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
5643 };
5644
5645 /**
5646  * Converts a Punycode string of ASCII-only symbols to a string of Unicode
5647  * symbols.
5648  * @memberOf punycode
5649  * @param {String} input The Punycode string of ASCII-only symbols.
5650  * @returns {String} The resulting string of Unicode symbols.
5651  */
5652 var decode = function decode(input) {
5653         // Don't use UCS-2.
5654         var output = [];
5655         var inputLength = input.length;
5656         var i = 0;
5657         var n = initialN;
5658         var bias = initialBias;
5659
5660         // Handle the basic code points: let `basic` be the number of input code
5661         // points before the last delimiter, or `0` if there is none, then copy
5662         // the first basic code points to the output.
5663
5664         var basic = input.lastIndexOf(delimiter);
5665         if (basic < 0) {
5666                 basic = 0;
5667         }
5668
5669         for (var j = 0; j < basic; ++j) {
5670                 // if it's not a basic code point
5671                 if (input.charCodeAt(j) >= 0x80) {
5672                         error$1('not-basic');
5673                 }
5674                 output.push(input.charCodeAt(j));
5675         }
5676
5677         // Main decoding loop: start just after the last delimiter if any basic code
5678         // points were copied; start at the beginning otherwise.
5679
5680         for (var index = basic > 0 ? basic + 1 : 0; index < inputLength;) /* no final expression */{
5681
5682                 // `index` is the index of the next character to be consumed.
5683                 // Decode a generalized variable-length integer into `delta`,
5684                 // which gets added to `i`. The overflow checking is easier
5685                 // if we increase `i` as we go, then subtract off its starting
5686                 // value at the end to obtain `delta`.
5687                 var oldi = i;
5688                 for (var w = 1, k = base;; /* no condition */k += base) {
5689
5690                         if (index >= inputLength) {
5691                                 error$1('invalid-input');
5692                         }
5693
5694                         var digit = basicToDigit(input.charCodeAt(index++));
5695
5696                         if (digit >= base || digit > floor((maxInt - i) / w)) {
5697                                 error$1('overflow');
5698                         }
5699
5700                         i += digit * w;
5701                         var t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;
5702
5703                         if (digit < t) {
5704                                 break;
5705                         }
5706
5707                         var baseMinusT = base - t;
5708                         if (w > floor(maxInt / baseMinusT)) {
5709                                 error$1('overflow');
5710                         }
5711
5712                         w *= baseMinusT;
5713                 }
5714
5715                 var out = output.length + 1;
5716                 bias = adapt(i - oldi, out, oldi == 0);
5717
5718                 // `i` was supposed to wrap around from `out` to `0`,
5719                 // incrementing `n` each time, so we'll fix that now:
5720                 if (floor(i / out) > maxInt - n) {
5721                         error$1('overflow');
5722                 }
5723
5724                 n += floor(i / out);
5725                 i %= out;
5726
5727                 // Insert `n` at position `i` of the output.
5728                 output.splice(i++, 0, n);
5729         }
5730
5731         return String.fromCodePoint.apply(String, output);
5732 };
5733
5734 /**
5735  * Converts a string of Unicode symbols (e.g. a domain name label) to a
5736  * Punycode string of ASCII-only symbols.
5737  * @memberOf punycode
5738  * @param {String} input The string of Unicode symbols.
5739  * @returns {String} The resulting Punycode string of ASCII-only symbols.
5740  */
5741 var encode = function encode(input) {
5742         var output = [];
5743
5744         // Convert the input in UCS-2 to an array of Unicode code points.
5745         input = ucs2decode(input);
5746
5747         // Cache the length.
5748         var inputLength = input.length;
5749
5750         // Initialize the state.
5751         var n = initialN;
5752         var delta = 0;
5753         var bias = initialBias;
5754
5755         // Handle the basic code points.
5756         var _iteratorNormalCompletion = true;
5757         var _didIteratorError = false;
5758         var _iteratorError = undefined;
5759
5760         try {
5761                 for (var _iterator = input[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
5762                         var _currentValue2 = _step.value;
5763
5764                         if (_currentValue2 < 0x80) {
5765                                 output.push(stringFromCharCode(_currentValue2));
5766                         }
5767                 }
5768         } catch (err) {
5769                 _didIteratorError = true;
5770                 _iteratorError = err;
5771         } finally {
5772                 try {
5773                         if (!_iteratorNormalCompletion && _iterator.return) {
5774                                 _iterator.return();
5775                         }
5776                 } finally {
5777                         if (_didIteratorError) {
5778                                 throw _iteratorError;
5779                         }
5780                 }
5781         }
5782
5783         var basicLength = output.length;
5784         var handledCPCount = basicLength;
5785
5786         // `handledCPCount` is the number of code points that have been handled;
5787         // `basicLength` is the number of basic code points.
5788
5789         // Finish the basic string with a delimiter unless it's empty.
5790         if (basicLength) {
5791                 output.push(delimiter);
5792         }
5793
5794         // Main encoding loop:
5795         while (handledCPCount < inputLength) {
5796
5797                 // All non-basic code points < n have been handled already. Find the next
5798                 // larger one:
5799                 var m = maxInt;
5800                 var _iteratorNormalCompletion2 = true;
5801                 var _didIteratorError2 = false;
5802                 var _iteratorError2 = undefined;
5803
5804                 try {
5805                         for (var _iterator2 = input[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
5806                                 var currentValue = _step2.value;
5807
5808                                 if (currentValue >= n && currentValue < m) {
5809                                         m = currentValue;
5810                                 }
5811                         }
5812
5813                         // Increase `delta` enough to advance the decoder's <n,i> state to <m,0>,
5814                         // but guard against overflow.
5815                 } catch (err) {
5816                         _didIteratorError2 = true;
5817                         _iteratorError2 = err;
5818                 } finally {
5819                         try {
5820                                 if (!_iteratorNormalCompletion2 && _iterator2.return) {
5821                                         _iterator2.return();
5822                                 }
5823                         } finally {
5824                                 if (_didIteratorError2) {
5825                                         throw _iteratorError2;
5826                                 }
5827                         }
5828                 }
5829
5830                 var handledCPCountPlusOne = handledCPCount + 1;
5831                 if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
5832                         error$1('overflow');
5833                 }
5834
5835                 delta += (m - n) * handledCPCountPlusOne;
5836                 n = m;
5837
5838                 var _iteratorNormalCompletion3 = true;
5839                 var _didIteratorError3 = false;
5840                 var _iteratorError3 = undefined;
5841
5842                 try {
5843                         for (var _iterator3 = input[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
5844                                 var _currentValue = _step3.value;
5845
5846                                 if (_currentValue < n && ++delta > maxInt) {
5847                                         error$1('overflow');
5848                                 }
5849                                 if (_currentValue == n) {
5850                                         // Represent delta as a generalized variable-length integer.
5851                                         var q = delta;
5852                                         for (var k = base;; /* no condition */k += base) {
5853                                                 var t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;
5854                                                 if (q < t) {
5855                                                         break;
5856                                                 }
5857                                                 var qMinusT = q - t;
5858                                                 var baseMinusT = base - t;
5859                                                 output.push(stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0)));
5860                                                 q = floor(qMinusT / baseMinusT);
5861                                         }
5862
5863                                         output.push(stringFromCharCode(digitToBasic(q, 0)));
5864                                         bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
5865                                         delta = 0;
5866                                         ++handledCPCount;
5867                                 }
5868                         }
5869                 } catch (err) {
5870                         _didIteratorError3 = true;
5871                         _iteratorError3 = err;
5872                 } finally {
5873                         try {
5874                                 if (!_iteratorNormalCompletion3 && _iterator3.return) {
5875                                         _iterator3.return();
5876                                 }
5877                         } finally {
5878                                 if (_didIteratorError3) {
5879                                         throw _iteratorError3;
5880                                 }
5881                         }
5882                 }
5883
5884                 ++delta;
5885                 ++n;
5886         }
5887         return output.join('');
5888 };
5889
5890 /**
5891  * Converts a Punycode string representing a domain name or an email address
5892  * to Unicode. Only the Punycoded parts of the input will be converted, i.e.
5893  * it doesn't matter if you call it on a string that has already been
5894  * converted to Unicode.
5895  * @memberOf punycode
5896  * @param {String} input The Punycoded domain name or email address to
5897  * convert to Unicode.
5898  * @returns {String} The Unicode representation of the given Punycode
5899  * string.
5900  */
5901 var toUnicode = function toUnicode(input) {
5902         return mapDomain(input, function (string) {
5903                 return regexPunycode.test(string) ? decode(string.slice(4).toLowerCase()) : string;
5904         });
5905 };
5906
5907 /**
5908  * Converts a Unicode string representing a domain name or an email address to
5909  * Punycode. Only the non-ASCII parts of the domain name will be converted,
5910  * i.e. it doesn't matter if you call it with a domain that's already in
5911  * ASCII.
5912  * @memberOf punycode
5913  * @param {String} input The domain name or email address to convert, as a
5914  * Unicode string.
5915  * @returns {String} The Punycode representation of the given domain name or
5916  * email address.
5917  */
5918 var toASCII = function toASCII(input) {
5919         return mapDomain(input, function (string) {
5920                 return regexNonASCII.test(string) ? 'xn--' + encode(string) : string;
5921         });
5922 };
5923
5924 /*--------------------------------------------------------------------------*/
5925
5926 /** Define the public API */
5927 var punycode = {
5928         /**
5929   * A string representing the current Punycode.js version number.
5930   * @memberOf punycode
5931   * @type String
5932   */
5933         'version': '2.1.0',
5934         /**
5935   * An object of methods to convert from JavaScript's internal character
5936   * representation (UCS-2) to Unicode code points, and back.
5937   * @see <https://mathiasbynens.be/notes/javascript-encoding>
5938   * @memberOf punycode
5939   * @type Object
5940   */
5941         'ucs2': {
5942                 'decode': ucs2decode,
5943                 'encode': ucs2encode
5944         },
5945         'decode': decode,
5946         'encode': encode,
5947         'toASCII': toASCII,
5948         'toUnicode': toUnicode
5949 };
5950
5951 /**
5952  * URI.js
5953  *
5954  * @fileoverview An RFC 3986 compliant, scheme extendable URI parsing/validating/resolving library for JavaScript.
5955  * @author <a href="mailto:gary.court@gmail.com">Gary Court</a>
5956  * @see http://github.com/garycourt/uri-js
5957  */
5958 /**
5959  * Copyright 2011 Gary Court. All rights reserved.
5960  *
5961  * Redistribution and use in source and binary forms, with or without modification, are
5962  * permitted provided that the following conditions are met:
5963  *
5964  *    1. Redistributions of source code must retain the above copyright notice, this list of
5965  *       conditions and the following disclaimer.
5966  *
5967  *    2. Redistributions in binary form must reproduce the above copyright notice, this list
5968  *       of conditions and the following disclaimer in the documentation and/or other materials
5969  *       provided with the distribution.
5970  *
5971  * THIS SOFTWARE IS PROVIDED BY GARY COURT ``AS IS'' AND ANY EXPRESS OR IMPLIED
5972  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
5973  * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GARY COURT OR
5974  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
5975  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
5976  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
5977  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
5978  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
5979  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5980  *
5981  * The views and conclusions contained in the software and documentation are those of the
5982  * authors and should not be interpreted as representing official policies, either expressed
5983  * or implied, of Gary Court.
5984  */
5985 var SCHEMES = {};
5986 function pctEncChar(chr) {
5987     var c = chr.charCodeAt(0);
5988     var e = void 0;
5989     if (c < 16) e = "%0" + c.toString(16).toUpperCase();else if (c < 128) e = "%" + c.toString(16).toUpperCase();else if (c < 2048) e = "%" + (c >> 6 | 192).toString(16).toUpperCase() + "%" + (c & 63 | 128).toString(16).toUpperCase();else e = "%" + (c >> 12 | 224).toString(16).toUpperCase() + "%" + (c >> 6 & 63 | 128).toString(16).toUpperCase() + "%" + (c & 63 | 128).toString(16).toUpperCase();
5990     return e;
5991 }
5992 function pctDecChars(str) {
5993     var newStr = "";
5994     var i = 0;
5995     var il = str.length;
5996     while (i < il) {
5997         var c = parseInt(str.substr(i + 1, 2), 16);
5998         if (c < 128) {
5999             newStr += String.fromCharCode(c);
6000             i += 3;
6001         } else if (c >= 194 && c < 224) {
6002             if (il - i >= 6) {
6003                 var c2 = parseInt(str.substr(i + 4, 2), 16);
6004                 newStr += String.fromCharCode((c & 31) << 6 | c2 & 63);
6005             } else {
6006                 newStr += str.substr(i, 6);
6007             }
6008             i += 6;
6009         } else if (c >= 224) {
6010             if (il - i >= 9) {
6011                 var _c = parseInt(str.substr(i + 4, 2), 16);
6012                 var c3 = parseInt(str.substr(i + 7, 2), 16);
6013                 newStr += String.fromCharCode((c & 15) << 12 | (_c & 63) << 6 | c3 & 63);
6014             } else {
6015                 newStr += str.substr(i, 9);
6016             }
6017             i += 9;
6018         } else {
6019             newStr += str.substr(i, 3);
6020             i += 3;
6021         }
6022     }
6023     return newStr;
6024 }
6025 function _normalizeComponentEncoding(components, protocol) {
6026     function decodeUnreserved(str) {
6027         var decStr = pctDecChars(str);
6028         return !decStr.match(protocol.UNRESERVED) ? str : decStr;
6029     }
6030     if (components.scheme) components.scheme = String(components.scheme).replace(protocol.PCT_ENCODED, decodeUnreserved).toLowerCase().replace(protocol.NOT_SCHEME, "");
6031     if (components.userinfo !== undefined) components.userinfo = String(components.userinfo).replace(protocol.PCT_ENCODED, decodeUnreserved).replace(protocol.NOT_USERINFO, pctEncChar).replace(protocol.PCT_ENCODED, toUpperCase);
6032     if (components.host !== undefined) components.host = String(components.host).replace(protocol.PCT_ENCODED, decodeUnreserved).toLowerCase().replace(protocol.NOT_HOST, pctEncChar).replace(protocol.PCT_ENCODED, toUpperCase);
6033     if (components.path !== undefined) components.path = String(components.path).replace(protocol.PCT_ENCODED, decodeUnreserved).replace(components.scheme ? protocol.NOT_PATH : protocol.NOT_PATH_NOSCHEME, pctEncChar).replace(protocol.PCT_ENCODED, toUpperCase);
6034     if (components.query !== undefined) components.query = String(components.query).replace(protocol.PCT_ENCODED, decodeUnreserved).replace(protocol.NOT_QUERY, pctEncChar).replace(protocol.PCT_ENCODED, toUpperCase);
6035     if (components.fragment !== undefined) components.fragment = String(components.fragment).replace(protocol.PCT_ENCODED, decodeUnreserved).replace(protocol.NOT_FRAGMENT, pctEncChar).replace(protocol.PCT_ENCODED, toUpperCase);
6036     return components;
6037 }
6038
6039 function _stripLeadingZeros(str) {
6040     return str.replace(/^0*(.*)/, "$1") || "0";
6041 }
6042 function _normalizeIPv4(host, protocol) {
6043     var matches = host.match(protocol.IPV4ADDRESS) || [];
6044
6045     var _matches = slicedToArray(matches, 2),
6046         address = _matches[1];
6047
6048     if (address) {
6049         return address.split(".").map(_stripLeadingZeros).join(".");
6050     } else {
6051         return host;
6052     }
6053 }
6054 function _normalizeIPv6(host, protocol) {
6055     var matches = host.match(protocol.IPV6ADDRESS) || [];
6056
6057     var _matches2 = slicedToArray(matches, 3),
6058         address = _matches2[1],
6059         zone = _matches2[2];
6060
6061     if (address) {
6062         var _address$toLowerCase$ = address.toLowerCase().split('::').reverse(),
6063             _address$toLowerCase$2 = slicedToArray(_address$toLowerCase$, 2),
6064             last = _address$toLowerCase$2[0],
6065             first = _address$toLowerCase$2[1];
6066
6067         var firstFields = first ? first.split(":").map(_stripLeadingZeros) : [];
6068         var lastFields = last.split(":").map(_stripLeadingZeros);
6069         var isLastFieldIPv4Address = protocol.IPV4ADDRESS.test(lastFields[lastFields.length - 1]);
6070         var fieldCount = isLastFieldIPv4Address ? 7 : 8;
6071         var lastFieldsStart = lastFields.length - fieldCount;
6072         var fields = Array(fieldCount);
6073         for (var x = 0; x < fieldCount; ++x) {
6074             fields[x] = firstFields[x] || lastFields[lastFieldsStart + x] || '';
6075         }
6076         if (isLastFieldIPv4Address) {
6077             fields[fieldCount - 1] = _normalizeIPv4(fields[fieldCount - 1], protocol);
6078         }
6079         var allZeroFields = fields.reduce(function (acc, field, index) {
6080             if (!field || field === "0") {
6081                 var lastLongest = acc[acc.length - 1];
6082                 if (lastLongest && lastLongest.index + lastLongest.length === index) {
6083                     lastLongest.length++;
6084                 } else {
6085                     acc.push({ index: index, length: 1 });
6086                 }
6087             }
6088             return acc;
6089         }, []);
6090         var longestZeroFields = allZeroFields.sort(function (a, b) {
6091             return b.length - a.length;
6092         })[0];
6093         var newHost = void 0;
6094         if (longestZeroFields && longestZeroFields.length > 1) {
6095             var newFirst = fields.slice(0, longestZeroFields.index);
6096             var newLast = fields.slice(longestZeroFields.index + longestZeroFields.length);
6097             newHost = newFirst.join(":") + "::" + newLast.join(":");
6098         } else {
6099             newHost = fields.join(":");
6100         }
6101         if (zone) {
6102             newHost += "%" + zone;
6103         }
6104         return newHost;
6105     } else {
6106         return host;
6107     }
6108 }
6109 var URI_PARSE = /^(?:([^:\/?#]+):)?(?:\/\/((?:([^\/?#@]*)@)?(\[[^\/?#\]]+\]|[^\/?#:]*)(?:\:(\d*))?))?([^?#]*)(?:\?([^#]*))?(?:#((?:.|\n|\r)*))?/i;
6110 var NO_MATCH_IS_UNDEFINED = "".match(/(){0}/)[1] === undefined;
6111 function parse(uriString) {
6112     var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
6113
6114     var components = {};
6115     var protocol = options.iri !== false ? IRI_PROTOCOL : URI_PROTOCOL;
6116     if (options.reference === "suffix") uriString = (options.scheme ? options.scheme + ":" : "") + "//" + uriString;
6117     var matches = uriString.match(URI_PARSE);
6118     if (matches) {
6119         if (NO_MATCH_IS_UNDEFINED) {
6120             //store each component
6121             components.scheme = matches[1];
6122             components.userinfo = matches[3];
6123             components.host = matches[4];
6124             components.port = parseInt(matches[5], 10);
6125             components.path = matches[6] || "";
6126             components.query = matches[7];
6127             components.fragment = matches[8];
6128             //fix port number
6129             if (isNaN(components.port)) {
6130                 components.port = matches[5];
6131             }
6132         } else {
6133             //IE FIX for improper RegExp matching
6134             //store each component
6135             components.scheme = matches[1] || undefined;
6136             components.userinfo = uriString.indexOf("@") !== -1 ? matches[3] : undefined;
6137             components.host = uriString.indexOf("//") !== -1 ? matches[4] : undefined;
6138             components.port = parseInt(matches[5], 10);
6139             components.path = matches[6] || "";
6140             components.query = uriString.indexOf("?") !== -1 ? matches[7] : undefined;
6141             components.fragment = uriString.indexOf("#") !== -1 ? matches[8] : undefined;
6142             //fix port number
6143             if (isNaN(components.port)) {
6144                 components.port = uriString.match(/\/\/(?:.|\n)*\:(?:\/|\?|\#|$)/) ? matches[4] : undefined;
6145             }
6146         }
6147         if (components.host) {
6148             //normalize IP hosts
6149             components.host = _normalizeIPv6(_normalizeIPv4(components.host, protocol), protocol);
6150         }
6151         //determine reference type
6152         if (components.scheme === undefined && components.userinfo === undefined && components.host === undefined && components.port === undefined && !components.path && components.query === undefined) {
6153             components.reference = "same-document";
6154         } else if (components.scheme === undefined) {
6155             components.reference = "relative";
6156         } else if (components.fragment === undefined) {
6157             components.reference = "absolute";
6158         } else {
6159             components.reference = "uri";
6160         }
6161         //check for reference errors
6162         if (options.reference && options.reference !== "suffix" && options.reference !== components.reference) {
6163             components.error = components.error || "URI is not a " + options.reference + " reference.";
6164         }
6165         //find scheme handler
6166         var schemeHandler = SCHEMES[(options.scheme || components.scheme || "").toLowerCase()];
6167         //check if scheme can't handle IRIs
6168         if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport)) {
6169             //if host component is a domain name
6170             if (components.host && (options.domainHost || schemeHandler && schemeHandler.domainHost)) {
6171                 //convert Unicode IDN -> ASCII IDN
6172                 try {
6173                     components.host = punycode.toASCII(components.host.replace(protocol.PCT_ENCODED, pctDecChars).toLowerCase());
6174                 } catch (e) {
6175                     components.error = components.error || "Host's domain name can not be converted to ASCII via punycode: " + e;
6176                 }
6177             }
6178             //convert IRI -> URI
6179             _normalizeComponentEncoding(components, URI_PROTOCOL);
6180         } else {
6181             //normalize encodings
6182             _normalizeComponentEncoding(components, protocol);
6183         }
6184         //perform scheme specific parsing
6185         if (schemeHandler && schemeHandler.parse) {
6186             schemeHandler.parse(components, options);
6187         }
6188     } else {
6189         components.error = components.error || "URI can not be parsed.";
6190     }
6191     return components;
6192 }
6193
6194 function _recomposeAuthority(components, options) {
6195     var protocol = options.iri !== false ? IRI_PROTOCOL : URI_PROTOCOL;
6196     var uriTokens = [];
6197     if (components.userinfo !== undefined) {
6198         uriTokens.push(components.userinfo);
6199         uriTokens.push("@");
6200     }
6201     if (components.host !== undefined) {
6202         //normalize IP hosts, add brackets and escape zone separator for IPv6
6203         uriTokens.push(_normalizeIPv6(_normalizeIPv4(String(components.host), protocol), protocol).replace(protocol.IPV6ADDRESS, function (_, $1, $2) {
6204             return "[" + $1 + ($2 ? "%25" + $2 : "") + "]";
6205         }));
6206     }
6207     if (typeof components.port === "number") {
6208         uriTokens.push(":");
6209         uriTokens.push(components.port.toString(10));
6210     }
6211     return uriTokens.length ? uriTokens.join("") : undefined;
6212 }
6213
6214 var RDS1 = /^\.\.?\//;
6215 var RDS2 = /^\/\.(\/|$)/;
6216 var RDS3 = /^\/\.\.(\/|$)/;
6217 var RDS5 = /^\/?(?:.|\n)*?(?=\/|$)/;
6218 function removeDotSegments(input) {
6219     var output = [];
6220     while (input.length) {
6221         if (input.match(RDS1)) {
6222             input = input.replace(RDS1, "");
6223         } else if (input.match(RDS2)) {
6224             input = input.replace(RDS2, "/");
6225         } else if (input.match(RDS3)) {
6226             input = input.replace(RDS3, "/");
6227             output.pop();
6228         } else if (input === "." || input === "..") {
6229             input = "";
6230         } else {
6231             var im = input.match(RDS5);
6232             if (im) {
6233                 var s = im[0];
6234                 input = input.slice(s.length);
6235                 output.push(s);
6236             } else {
6237                 throw new Error("Unexpected dot segment condition");
6238             }
6239         }
6240     }
6241     return output.join("");
6242 }
6243
6244 function serialize(components) {
6245     var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
6246
6247     var protocol = options.iri ? IRI_PROTOCOL : URI_PROTOCOL;
6248     var uriTokens = [];
6249     //find scheme handler
6250     var schemeHandler = SCHEMES[(options.scheme || components.scheme || "").toLowerCase()];
6251     //perform scheme specific serialization
6252     if (schemeHandler && schemeHandler.serialize) schemeHandler.serialize(components, options);
6253     if (components.host) {
6254         //if host component is an IPv6 address
6255         if (protocol.IPV6ADDRESS.test(components.host)) {}
6256         //TODO: normalize IPv6 address as per RFC 5952
6257
6258         //if host component is a domain name
6259         else if (options.domainHost || schemeHandler && schemeHandler.domainHost) {
6260                 //convert IDN via punycode
6261                 try {
6262                     components.host = !options.iri ? punycode.toASCII(components.host.replace(protocol.PCT_ENCODED, pctDecChars).toLowerCase()) : punycode.toUnicode(components.host);
6263                 } catch (e) {
6264                     components.error = components.error || "Host's domain name can not be converted to " + (!options.iri ? "ASCII" : "Unicode") + " via punycode: " + e;
6265                 }
6266             }
6267     }
6268     //normalize encoding
6269     _normalizeComponentEncoding(components, protocol);
6270     if (options.reference !== "suffix" && components.scheme) {
6271         uriTokens.push(components.scheme);
6272         uriTokens.push(":");
6273     }
6274     var authority = _recomposeAuthority(components, options);
6275     if (authority !== undefined) {
6276         if (options.reference !== "suffix") {
6277             uriTokens.push("//");
6278         }
6279         uriTokens.push(authority);
6280         if (components.path && components.path.charAt(0) !== "/") {
6281             uriTokens.push("/");
6282         }
6283     }
6284     if (components.path !== undefined) {
6285         var s = components.path;
6286         if (!options.absolutePath && (!schemeHandler || !schemeHandler.absolutePath)) {
6287             s = removeDotSegments(s);
6288         }
6289         if (authority === undefined) {
6290             s = s.replace(/^\/\//, "/%2F"); //don't allow the path to start with "//"
6291         }
6292         uriTokens.push(s);
6293     }
6294     if (components.query !== undefined) {
6295         uriTokens.push("?");
6296         uriTokens.push(components.query);
6297     }
6298     if (components.fragment !== undefined) {
6299         uriTokens.push("#");
6300         uriTokens.push(components.fragment);
6301     }
6302     return uriTokens.join(""); //merge tokens into a string
6303 }
6304
6305 function resolveComponents(base, relative) {
6306     var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
6307     var skipNormalization = arguments[3];
6308
6309     var target = {};
6310     if (!skipNormalization) {
6311         base = parse(serialize(base, options), options); //normalize base components
6312         relative = parse(serialize(relative, options), options); //normalize relative components
6313     }
6314     options = options || {};
6315     if (!options.tolerant && relative.scheme) {
6316         target.scheme = relative.scheme;
6317         //target.authority = relative.authority;
6318         target.userinfo = relative.userinfo;
6319         target.host = relative.host;
6320         target.port = relative.port;
6321         target.path = removeDotSegments(relative.path || "");
6322         target.query = relative.query;
6323     } else {
6324         if (relative.userinfo !== undefined || relative.host !== undefined || relative.port !== undefined) {
6325             //target.authority = relative.authority;
6326             target.userinfo = relative.userinfo;
6327             target.host = relative.host;
6328             target.port = relative.port;
6329             target.path = removeDotSegments(relative.path || "");
6330             target.query = relative.query;
6331         } else {
6332             if (!relative.path) {
6333                 target.path = base.path;
6334                 if (relative.query !== undefined) {
6335                     target.query = relative.query;
6336                 } else {
6337                     target.query = base.query;
6338                 }
6339             } else {
6340                 if (relative.path.charAt(0) === "/") {
6341                     target.path = removeDotSegments(relative.path);
6342                 } else {
6343                     if ((base.userinfo !== undefined || base.host !== undefined || base.port !== undefined) && !base.path) {
6344                         target.path = "/" + relative.path;
6345                     } else if (!base.path) {
6346                         target.path = relative.path;
6347                     } else {
6348                         target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative.path;
6349                     }
6350                     target.path = removeDotSegments(target.path);
6351                 }
6352                 target.query = relative.query;
6353             }
6354             //target.authority = base.authority;
6355             target.userinfo = base.userinfo;
6356             target.host = base.host;
6357             target.port = base.port;
6358         }
6359         target.scheme = base.scheme;
6360     }
6361     target.fragment = relative.fragment;
6362     return target;
6363 }
6364
6365 function resolve(baseURI, relativeURI, options) {
6366     var schemelessOptions = assign({ scheme: 'null' }, options);
6367     return serialize(resolveComponents(parse(baseURI, schemelessOptions), parse(relativeURI, schemelessOptions), schemelessOptions, true), schemelessOptions);
6368 }
6369
6370 function normalize(uri, options) {
6371     if (typeof uri === "string") {
6372         uri = serialize(parse(uri, options), options);
6373     } else if (typeOf(uri) === "object") {
6374         uri = parse(serialize(uri, options), options);
6375     }
6376     return uri;
6377 }
6378
6379 function equal(uriA, uriB, options) {
6380     if (typeof uriA === "string") {
6381         uriA = serialize(parse(uriA, options), options);
6382     } else if (typeOf(uriA) === "object") {
6383         uriA = serialize(uriA, options);
6384     }
6385     if (typeof uriB === "string") {
6386         uriB = serialize(parse(uriB, options), options);
6387     } else if (typeOf(uriB) === "object") {
6388         uriB = serialize(uriB, options);
6389     }
6390     return uriA === uriB;
6391 }
6392
6393 function escapeComponent(str, options) {
6394     return str && str.toString().replace(!options || !options.iri ? URI_PROTOCOL.ESCAPE : IRI_PROTOCOL.ESCAPE, pctEncChar);
6395 }
6396
6397 function unescapeComponent(str, options) {
6398     return str && str.toString().replace(!options || !options.iri ? URI_PROTOCOL.PCT_ENCODED : IRI_PROTOCOL.PCT_ENCODED, pctDecChars);
6399 }
6400
6401 var handler = {
6402     scheme: "http",
6403     domainHost: true,
6404     parse: function parse(components, options) {
6405         //report missing host
6406         if (!components.host) {
6407             components.error = components.error || "HTTP URIs must have a host.";
6408         }
6409         return components;
6410     },
6411     serialize: function serialize(components, options) {
6412         //normalize the default port
6413         if (components.port === (String(components.scheme).toLowerCase() !== "https" ? 80 : 443) || components.port === "") {
6414             components.port = undefined;
6415         }
6416         //normalize the empty path
6417         if (!components.path) {
6418             components.path = "/";
6419         }
6420         //NOTE: We do not parse query strings for HTTP URIs
6421         //as WWW Form Url Encoded query strings are part of the HTML4+ spec,
6422         //and not the HTTP spec.
6423         return components;
6424     }
6425 };
6426
6427 var handler$1 = {
6428     scheme: "https",
6429     domainHost: handler.domainHost,
6430     parse: handler.parse,
6431     serialize: handler.serialize
6432 };
6433
6434 var O = {};
6435 var isIRI = true;
6436 //RFC 3986
6437 var UNRESERVED$$ = "[A-Za-z0-9\\-\\.\\_\\~" + (isIRI ? "\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF" : "") + "]";
6438 var HEXDIG$$ = "[0-9A-Fa-f]"; //case-insensitive
6439 var PCT_ENCODED$ = subexp(subexp("%[EFef]" + HEXDIG$$ + "%" + HEXDIG$$ + HEXDIG$$ + "%" + HEXDIG$$ + HEXDIG$$) + "|" + subexp("%[89A-Fa-f]" + HEXDIG$$ + "%" + HEXDIG$$ + HEXDIG$$) + "|" + subexp("%" + HEXDIG$$ + HEXDIG$$)); //expanded
6440 //RFC 5322, except these symbols as per RFC 6068: @ : / ? # [ ] & ; =
6441 //const ATEXT$$ = "[A-Za-z0-9\\!\\#\\$\\%\\&\\'\\*\\+\\-\\/\\=\\?\\^\\_\\`\\{\\|\\}\\~]";
6442 //const WSP$$ = "[\\x20\\x09]";
6443 //const OBS_QTEXT$$ = "[\\x01-\\x08\\x0B\\x0C\\x0E-\\x1F\\x7F]";  //(%d1-8 / %d11-12 / %d14-31 / %d127)
6444 //const QTEXT$$ = merge("[\\x21\\x23-\\x5B\\x5D-\\x7E]", OBS_QTEXT$$);  //%d33 / %d35-91 / %d93-126 / obs-qtext
6445 //const VCHAR$$ = "[\\x21-\\x7E]";
6446 //const WSP$$ = "[\\x20\\x09]";
6447 //const OBS_QP$ = subexp("\\\\" + merge("[\\x00\\x0D\\x0A]", OBS_QTEXT$$));  //%d0 / CR / LF / obs-qtext
6448 //const FWS$ = subexp(subexp(WSP$$ + "*" + "\\x0D\\x0A") + "?" + WSP$$ + "+");
6449 //const QUOTED_PAIR$ = subexp(subexp("\\\\" + subexp(VCHAR$$ + "|" + WSP$$)) + "|" + OBS_QP$);
6450 //const QUOTED_STRING$ = subexp('\\"' + subexp(FWS$ + "?" + QCONTENT$) + "*" + FWS$ + "?" + '\\"');
6451 var ATEXT$$ = "[A-Za-z0-9\\!\\$\\%\\'\\*\\+\\-\\^\\_\\`\\{\\|\\}\\~]";
6452 var QTEXT$$ = "[\\!\\$\\%\\'\\(\\)\\*\\+\\,\\-\\.0-9\\<\\>A-Z\\x5E-\\x7E]";
6453 var VCHAR$$ = merge(QTEXT$$, "[\\\"\\\\]");
6454 var SOME_DELIMS$$ = "[\\!\\$\\'\\(\\)\\*\\+\\,\\;\\:\\@]";
6455 var UNRESERVED = new RegExp(UNRESERVED$$, "g");
6456 var PCT_ENCODED = new RegExp(PCT_ENCODED$, "g");
6457 var NOT_LOCAL_PART = new RegExp(merge("[^]", ATEXT$$, "[\\.]", '[\\"]', VCHAR$$), "g");
6458 var NOT_HFNAME = new RegExp(merge("[^]", UNRESERVED$$, SOME_DELIMS$$), "g");
6459 var NOT_HFVALUE = NOT_HFNAME;
6460 function decodeUnreserved(str) {
6461     var decStr = pctDecChars(str);
6462     return !decStr.match(UNRESERVED) ? str : decStr;
6463 }
6464 var handler$2 = {
6465     scheme: "mailto",
6466     parse: function parse$$1(components, options) {
6467         var mailtoComponents = components;
6468         var to = mailtoComponents.to = mailtoComponents.path ? mailtoComponents.path.split(",") : [];
6469         mailtoComponents.path = undefined;
6470         if (mailtoComponents.query) {
6471             var unknownHeaders = false;
6472             var headers = {};
6473             var hfields = mailtoComponents.query.split("&");
6474             for (var x = 0, xl = hfields.length; x < xl; ++x) {
6475                 var hfield = hfields[x].split("=");
6476                 switch (hfield[0]) {
6477                     case "to":
6478                         var toAddrs = hfield[1].split(",");
6479                         for (var _x = 0, _xl = toAddrs.length; _x < _xl; ++_x) {
6480                             to.push(toAddrs[_x]);
6481                         }
6482                         break;
6483                     case "subject":
6484                         mailtoComponents.subject = unescapeComponent(hfield[1], options);
6485                         break;
6486                     case "body":
6487                         mailtoComponents.body = unescapeComponent(hfield[1], options);
6488                         break;
6489                     default:
6490                         unknownHeaders = true;
6491                         headers[unescapeComponent(hfield[0], options)] = unescapeComponent(hfield[1], options);
6492                         break;
6493                 }
6494             }
6495             if (unknownHeaders) mailtoComponents.headers = headers;
6496         }
6497         mailtoComponents.query = undefined;
6498         for (var _x2 = 0, _xl2 = to.length; _x2 < _xl2; ++_x2) {
6499             var addr = to[_x2].split("@");
6500             addr[0] = unescapeComponent(addr[0]);
6501             if (!options.unicodeSupport) {
6502                 //convert Unicode IDN -> ASCII IDN
6503                 try {
6504                     addr[1] = punycode.toASCII(unescapeComponent(addr[1], options).toLowerCase());
6505                 } catch (e) {
6506                     mailtoComponents.error = mailtoComponents.error || "Email address's domain name can not be converted to ASCII via punycode: " + e;
6507                 }
6508             } else {
6509                 addr[1] = unescapeComponent(addr[1], options).toLowerCase();
6510             }
6511             to[_x2] = addr.join("@");
6512         }
6513         return mailtoComponents;
6514     },
6515     serialize: function serialize$$1(mailtoComponents, options) {
6516         var components = mailtoComponents;
6517         var to = toArray(mailtoComponents.to);
6518         if (to) {
6519             for (var x = 0, xl = to.length; x < xl; ++x) {
6520                 var toAddr = String(to[x]);
6521                 var atIdx = toAddr.lastIndexOf("@");
6522                 var localPart = toAddr.slice(0, atIdx).replace(PCT_ENCODED, decodeUnreserved).replace(PCT_ENCODED, toUpperCase).replace(NOT_LOCAL_PART, pctEncChar);
6523                 var domain = toAddr.slice(atIdx + 1);
6524                 //convert IDN via punycode
6525                 try {
6526                     domain = !options.iri ? punycode.toASCII(unescapeComponent(domain, options).toLowerCase()) : punycode.toUnicode(domain);
6527                 } catch (e) {
6528                     components.error = components.error || "Email address's domain name can not be converted to " + (!options.iri ? "ASCII" : "Unicode") + " via punycode: " + e;
6529                 }
6530                 to[x] = localPart + "@" + domain;
6531             }
6532             components.path = to.join(",");
6533         }
6534         var headers = mailtoComponents.headers = mailtoComponents.headers || {};
6535         if (mailtoComponents.subject) headers["subject"] = mailtoComponents.subject;
6536         if (mailtoComponents.body) headers["body"] = mailtoComponents.body;
6537         var fields = [];
6538         for (var name in headers) {
6539             if (headers[name] !== O[name]) {
6540                 fields.push(name.replace(PCT_ENCODED, decodeUnreserved).replace(PCT_ENCODED, toUpperCase).replace(NOT_HFNAME, pctEncChar) + "=" + headers[name].replace(PCT_ENCODED, decodeUnreserved).replace(PCT_ENCODED, toUpperCase).replace(NOT_HFVALUE, pctEncChar));
6541             }
6542         }
6543         if (fields.length) {
6544             components.query = fields.join("&");
6545         }
6546         return components;
6547     }
6548 };
6549
6550 var URN_PARSE = /^([^\:]+)\:(.*)/;
6551 //RFC 2141
6552 var handler$3 = {
6553     scheme: "urn",
6554     parse: function parse$$1(components, options) {
6555         var matches = components.path && components.path.match(URN_PARSE);
6556         var urnComponents = components;
6557         if (matches) {
6558             var scheme = options.scheme || urnComponents.scheme || "urn";
6559             var nid = matches[1].toLowerCase();
6560             var nss = matches[2];
6561             var urnScheme = scheme + ":" + (options.nid || nid);
6562             var schemeHandler = SCHEMES[urnScheme];
6563             urnComponents.nid = nid;
6564             urnComponents.nss = nss;
6565             urnComponents.path = undefined;
6566             if (schemeHandler) {
6567                 urnComponents = schemeHandler.parse(urnComponents, options);
6568             }
6569         } else {
6570             urnComponents.error = urnComponents.error || "URN can not be parsed.";
6571         }
6572         return urnComponents;
6573     },
6574     serialize: function serialize$$1(urnComponents, options) {
6575         var scheme = options.scheme || urnComponents.scheme || "urn";
6576         var nid = urnComponents.nid;
6577         var urnScheme = scheme + ":" + (options.nid || nid);
6578         var schemeHandler = SCHEMES[urnScheme];
6579         if (schemeHandler) {
6580             urnComponents = schemeHandler.serialize(urnComponents, options);
6581         }
6582         var uriComponents = urnComponents;
6583         var nss = urnComponents.nss;
6584         uriComponents.path = (nid || options.nid) + ":" + nss;
6585         return uriComponents;
6586     }
6587 };
6588
6589 var UUID = /^[0-9A-Fa-f]{8}(?:\-[0-9A-Fa-f]{4}){3}\-[0-9A-Fa-f]{12}$/;
6590 //RFC 4122
6591 var handler$4 = {
6592     scheme: "urn:uuid",
6593     parse: function parse(urnComponents, options) {
6594         var uuidComponents = urnComponents;
6595         uuidComponents.uuid = uuidComponents.nss;
6596         uuidComponents.nss = undefined;
6597         if (!options.tolerant && (!uuidComponents.uuid || !uuidComponents.uuid.match(UUID))) {
6598             uuidComponents.error = uuidComponents.error || "UUID is not valid.";
6599         }
6600         return uuidComponents;
6601     },
6602     serialize: function serialize(uuidComponents, options) {
6603         var urnComponents = uuidComponents;
6604         //normalize UUID
6605         urnComponents.nss = (uuidComponents.uuid || "").toLowerCase();
6606         return urnComponents;
6607     }
6608 };
6609
6610 SCHEMES[handler.scheme] = handler;
6611 SCHEMES[handler$1.scheme] = handler$1;
6612 SCHEMES[handler$2.scheme] = handler$2;
6613 SCHEMES[handler$3.scheme] = handler$3;
6614 SCHEMES[handler$4.scheme] = handler$4;
6615
6616 exports.SCHEMES = SCHEMES;
6617 exports.pctEncChar = pctEncChar;
6618 exports.pctDecChars = pctDecChars;
6619 exports.parse = parse;
6620 exports.removeDotSegments = removeDotSegments;
6621 exports.serialize = serialize;
6622 exports.resolveComponents = resolveComponents;
6623 exports.resolve = resolve;
6624 exports.normalize = normalize;
6625 exports.equal = equal;
6626 exports.escapeComponent = escapeComponent;
6627 exports.unescapeComponent = unescapeComponent;
6628
6629 Object.defineProperty(exports, '__esModule', { value: true });
6630
6631 })));
6632
6633
6634 },{}],"ajv":[function(require,module,exports){
6635 'use strict';
6636
6637 var compileSchema = require('./compile')
6638   , resolve = require('./compile/resolve')
6639   , Cache = require('./cache')
6640   , SchemaObject = require('./compile/schema_obj')
6641   , stableStringify = require('fast-json-stable-stringify')
6642   , formats = require('./compile/formats')
6643   , rules = require('./compile/rules')
6644   , $dataMetaSchema = require('./data')
6645   , util = require('./compile/util');
6646
6647 module.exports = Ajv;
6648
6649 Ajv.prototype.validate = validate;
6650 Ajv.prototype.compile = compile;
6651 Ajv.prototype.addSchema = addSchema;
6652 Ajv.prototype.addMetaSchema = addMetaSchema;
6653 Ajv.prototype.validateSchema = validateSchema;
6654 Ajv.prototype.getSchema = getSchema;
6655 Ajv.prototype.removeSchema = removeSchema;
6656 Ajv.prototype.addFormat = addFormat;
6657 Ajv.prototype.errorsText = errorsText;
6658
6659 Ajv.prototype._addSchema = _addSchema;
6660 Ajv.prototype._compile = _compile;
6661
6662 Ajv.prototype.compileAsync = require('./compile/async');
6663 var customKeyword = require('./keyword');
6664 Ajv.prototype.addKeyword = customKeyword.add;
6665 Ajv.prototype.getKeyword = customKeyword.get;
6666 Ajv.prototype.removeKeyword = customKeyword.remove;
6667 Ajv.prototype.validateKeyword = customKeyword.validate;
6668
6669 var errorClasses = require('./compile/error_classes');
6670 Ajv.ValidationError = errorClasses.Validation;
6671 Ajv.MissingRefError = errorClasses.MissingRef;
6672 Ajv.$dataMetaSchema = $dataMetaSchema;
6673
6674 var META_SCHEMA_ID = 'http://json-schema.org/draft-07/schema';
6675
6676 var META_IGNORE_OPTIONS = [ 'removeAdditional', 'useDefaults', 'coerceTypes', 'strictDefaults' ];
6677 var META_SUPPORT_DATA = ['/properties'];
6678
6679 /**
6680  * Creates validator instance.
6681  * Usage: `Ajv(opts)`
6682  * @param {Object} opts optional options
6683  * @return {Object} ajv instance
6684  */
6685 function Ajv(opts) {
6686   if (!(this instanceof Ajv)) return new Ajv(opts);
6687   opts = this._opts = util.copy(opts) || {};
6688   setLogger(this);
6689   this._schemas = {};
6690   this._refs = {};
6691   this._fragments = {};
6692   this._formats = formats(opts.format);
6693
6694   this._cache = opts.cache || new Cache;
6695   this._loadingSchemas = {};
6696   this._compilations = [];
6697   this.RULES = rules();
6698   this._getId = chooseGetId(opts);
6699
6700   opts.loopRequired = opts.loopRequired || Infinity;
6701   if (opts.errorDataPath == 'property') opts._errorDataPathProperty = true;
6702   if (opts.serialize === undefined) opts.serialize = stableStringify;
6703   this._metaOpts = getMetaSchemaOptions(this);
6704
6705   if (opts.formats) addInitialFormats(this);
6706   if (opts.keywords) addInitialKeywords(this);
6707   addDefaultMetaSchema(this);
6708   if (typeof opts.meta == 'object') this.addMetaSchema(opts.meta);
6709   if (opts.nullable) this.addKeyword('nullable', {metaSchema: {type: 'boolean'}});
6710   addInitialSchemas(this);
6711 }
6712
6713
6714
6715 /**
6716  * Validate data using schema
6717  * Schema will be compiled and cached (using serialized JSON as key. [fast-json-stable-stringify](https://github.com/epoberezkin/fast-json-stable-stringify) is used to serialize.
6718  * @this   Ajv
6719  * @param  {String|Object} schemaKeyRef key, ref or schema object
6720  * @param  {Any} data to be validated
6721  * @return {Boolean} validation result. Errors from the last validation will be available in `ajv.errors` (and also in compiled schema: `schema.errors`).
6722  */
6723 function validate(schemaKeyRef, data) {
6724   var v;
6725   if (typeof schemaKeyRef == 'string') {
6726     v = this.getSchema(schemaKeyRef);
6727     if (!v) throw new Error('no schema with key or ref "' + schemaKeyRef + '"');
6728   } else {
6729     var schemaObj = this._addSchema(schemaKeyRef);
6730     v = schemaObj.validate || this._compile(schemaObj);
6731   }
6732
6733   var valid = v(data);
6734   if (v.$async !== true) this.errors = v.errors;
6735   return valid;
6736 }
6737
6738
6739 /**
6740  * Create validating function for passed schema.
6741  * @this   Ajv
6742  * @param  {Object} schema schema object
6743  * @param  {Boolean} _meta true if schema is a meta-schema. Used internally to compile meta schemas of custom keywords.
6744  * @return {Function} validating function
6745  */
6746 function compile(schema, _meta) {
6747   var schemaObj = this._addSchema(schema, undefined, _meta);
6748   return schemaObj.validate || this._compile(schemaObj);
6749 }
6750
6751
6752 /**
6753  * Adds schema to the instance.
6754  * @this   Ajv
6755  * @param {Object|Array} schema schema or array of schemas. If array is passed, `key` and other parameters will be ignored.
6756  * @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`.
6757  * @param {Boolean} _skipValidation true to skip schema validation. Used internally, option validateSchema should be used instead.
6758  * @param {Boolean} _meta true if schema is a meta-schema. Used internally, addMetaSchema should be used instead.
6759  * @return {Ajv} this for method chaining
6760  */
6761 function addSchema(schema, key, _skipValidation, _meta) {
6762   if (Array.isArray(schema)){
6763     for (var i=0; i<schema.length; i++) this.addSchema(schema[i], undefined, _skipValidation, _meta);
6764     return this;
6765   }
6766   var id = this._getId(schema);
6767   if (id !== undefined && typeof id != 'string')
6768     throw new Error('schema id must be string');
6769   key = resolve.normalizeId(key || id);
6770   checkUnique(this, key);
6771   this._schemas[key] = this._addSchema(schema, _skipValidation, _meta, true);
6772   return this;
6773 }
6774
6775
6776 /**
6777  * Add schema that will be used to validate other schemas
6778  * options in META_IGNORE_OPTIONS are alway set to false
6779  * @this   Ajv
6780  * @param {Object} schema schema object
6781  * @param {String} key optional schema key
6782  * @param {Boolean} skipValidation true to skip schema validation, can be used to override validateSchema option for meta-schema
6783  * @return {Ajv} this for method chaining
6784  */
6785 function addMetaSchema(schema, key, skipValidation) {
6786   this.addSchema(schema, key, skipValidation, true);
6787   return this;
6788 }
6789
6790
6791 /**
6792  * Validate schema
6793  * @this   Ajv
6794  * @param {Object} schema schema to validate
6795  * @param {Boolean} throwOrLogError pass true to throw (or log) an error if invalid
6796  * @return {Boolean} true if schema is valid
6797  */
6798 function validateSchema(schema, throwOrLogError) {
6799   var $schema = schema.$schema;
6800   if ($schema !== undefined && typeof $schema != 'string')
6801     throw new Error('$schema must be a string');
6802   $schema = $schema || this._opts.defaultMeta || defaultMeta(this);
6803   if (!$schema) {
6804     this.logger.warn('meta-schema not available');
6805     this.errors = null;
6806     return true;
6807   }
6808   var valid = this.validate($schema, schema);
6809   if (!valid && throwOrLogError) {
6810     var message = 'schema is invalid: ' + this.errorsText();
6811     if (this._opts.validateSchema == 'log') this.logger.error(message);
6812     else throw new Error(message);
6813   }
6814   return valid;
6815 }
6816
6817
6818 function defaultMeta(self) {
6819   var meta = self._opts.meta;
6820   self._opts.defaultMeta = typeof meta == 'object'
6821                             ? self._getId(meta) || meta
6822                             : self.getSchema(META_SCHEMA_ID)
6823                               ? META_SCHEMA_ID
6824                               : undefined;
6825   return self._opts.defaultMeta;
6826 }
6827
6828
6829 /**
6830  * Get compiled schema from the instance by `key` or `ref`.
6831  * @this   Ajv
6832  * @param  {String} keyRef `key` that was passed to `addSchema` or full schema reference (`schema.id` or resolved id).
6833  * @return {Function} schema validating function (with property `schema`).
6834  */
6835 function getSchema(keyRef) {
6836   var schemaObj = _getSchemaObj(this, keyRef);
6837   switch (typeof schemaObj) {
6838     case 'object': return schemaObj.validate || this._compile(schemaObj);
6839     case 'string': return this.getSchema(schemaObj);
6840     case 'undefined': return _getSchemaFragment(this, keyRef);
6841   }
6842 }
6843
6844
6845 function _getSchemaFragment(self, ref) {
6846   var res = resolve.schema.call(self, { schema: {} }, ref);
6847   if (res) {
6848     var schema = res.schema
6849       , root = res.root
6850       , baseId = res.baseId;
6851     var v = compileSchema.call(self, schema, root, undefined, baseId);
6852     self._fragments[ref] = new SchemaObject({
6853       ref: ref,
6854       fragment: true,
6855       schema: schema,
6856       root: root,
6857       baseId: baseId,
6858       validate: v
6859     });
6860     return v;
6861   }
6862 }
6863
6864
6865 function _getSchemaObj(self, keyRef) {
6866   keyRef = resolve.normalizeId(keyRef);
6867   return self._schemas[keyRef] || self._refs[keyRef] || self._fragments[keyRef];
6868 }
6869
6870
6871 /**
6872  * Remove cached schema(s).
6873  * If no parameter is passed all schemas but meta-schemas are removed.
6874  * If RegExp is passed all schemas with key/id matching pattern but meta-schemas are removed.
6875  * Even if schema is referenced by other schemas it still can be removed as other schemas have local references.
6876  * @this   Ajv
6877  * @param  {String|Object|RegExp} schemaKeyRef key, ref, pattern to match key/ref or schema object
6878  * @return {Ajv} this for method chaining
6879  */
6880 function removeSchema(schemaKeyRef) {
6881   if (schemaKeyRef instanceof RegExp) {
6882     _removeAllSchemas(this, this._schemas, schemaKeyRef);
6883     _removeAllSchemas(this, this._refs, schemaKeyRef);
6884     return this;
6885   }
6886   switch (typeof schemaKeyRef) {
6887     case 'undefined':
6888       _removeAllSchemas(this, this._schemas);
6889       _removeAllSchemas(this, this._refs);
6890       this._cache.clear();
6891       return this;
6892     case 'string':
6893       var schemaObj = _getSchemaObj(this, schemaKeyRef);
6894       if (schemaObj) this._cache.del(schemaObj.cacheKey);
6895       delete this._schemas[schemaKeyRef];
6896       delete this._refs[schemaKeyRef];
6897       return this;
6898     case 'object':
6899       var serialize = this._opts.serialize;
6900       var cacheKey = serialize ? serialize(schemaKeyRef) : schemaKeyRef;
6901       this._cache.del(cacheKey);
6902       var id = this._getId(schemaKeyRef);
6903       if (id) {
6904         id = resolve.normalizeId(id);
6905         delete this._schemas[id];
6906         delete this._refs[id];
6907       }
6908   }
6909   return this;
6910 }
6911
6912
6913 function _removeAllSchemas(self, schemas, regex) {
6914   for (var keyRef in schemas) {
6915     var schemaObj = schemas[keyRef];
6916     if (!schemaObj.meta && (!regex || regex.test(keyRef))) {
6917       self._cache.del(schemaObj.cacheKey);
6918       delete schemas[keyRef];
6919     }
6920   }
6921 }
6922
6923
6924 /* @this   Ajv */
6925 function _addSchema(schema, skipValidation, meta, shouldAddSchema) {
6926   if (typeof schema != 'object' && typeof schema != 'boolean')
6927     throw new Error('schema should be object or boolean');
6928   var serialize = this._opts.serialize;
6929   var cacheKey = serialize ? serialize(schema) : schema;
6930   var cached = this._cache.get(cacheKey);
6931   if (cached) return cached;
6932
6933   shouldAddSchema = shouldAddSchema || this._opts.addUsedSchema !== false;
6934
6935   var id = resolve.normalizeId(this._getId(schema));
6936   if (id && shouldAddSchema) checkUnique(this, id);
6937
6938   var willValidate = this._opts.validateSchema !== false && !skipValidation;
6939   var recursiveMeta;
6940   if (willValidate && !(recursiveMeta = id && id == resolve.normalizeId(schema.$schema)))
6941     this.validateSchema(schema, true);
6942
6943   var localRefs = resolve.ids.call(this, schema);
6944
6945   var schemaObj = new SchemaObject({
6946     id: id,
6947     schema: schema,
6948     localRefs: localRefs,
6949     cacheKey: cacheKey,
6950     meta: meta
6951   });
6952
6953   if (id[0] != '#' && shouldAddSchema) this._refs[id] = schemaObj;
6954   this._cache.put(cacheKey, schemaObj);
6955
6956   if (willValidate && recursiveMeta) this.validateSchema(schema, true);
6957
6958   return schemaObj;
6959 }
6960
6961
6962 /* @this   Ajv */
6963 function _compile(schemaObj, root) {
6964   if (schemaObj.compiling) {
6965     schemaObj.validate = callValidate;
6966     callValidate.schema = schemaObj.schema;
6967     callValidate.errors = null;
6968     callValidate.root = root ? root : callValidate;
6969     if (schemaObj.schema.$async === true)
6970       callValidate.$async = true;
6971     return callValidate;
6972   }
6973   schemaObj.compiling = true;
6974
6975   var currentOpts;
6976   if (schemaObj.meta) {
6977     currentOpts = this._opts;
6978     this._opts = this._metaOpts;
6979   }
6980
6981   var v;
6982   try { v = compileSchema.call(this, schemaObj.schema, root, schemaObj.localRefs); }
6983   catch(e) {
6984     delete schemaObj.validate;
6985     throw e;
6986   }
6987   finally {
6988     schemaObj.compiling = false;
6989     if (schemaObj.meta) this._opts = currentOpts;
6990   }
6991
6992   schemaObj.validate = v;
6993   schemaObj.refs = v.refs;
6994   schemaObj.refVal = v.refVal;
6995   schemaObj.root = v.root;
6996   return v;
6997
6998
6999   /* @this   {*} - custom context, see passContext option */
7000   function callValidate() {
7001     /* jshint validthis: true */
7002     var _validate = schemaObj.validate;
7003     var result = _validate.apply(this, arguments);
7004     callValidate.errors = _validate.errors;
7005     return result;
7006   }
7007 }
7008
7009
7010 function chooseGetId(opts) {
7011   switch (opts.schemaId) {
7012     case 'auto': return _get$IdOrId;
7013     case 'id': return _getId;
7014     default: return _get$Id;
7015   }
7016 }
7017
7018 /* @this   Ajv */
7019 function _getId(schema) {
7020   if (schema.$id) this.logger.warn('schema $id ignored', schema.$id);
7021   return schema.id;
7022 }
7023
7024 /* @this   Ajv */
7025 function _get$Id(schema) {
7026   if (schema.id) this.logger.warn('schema id ignored', schema.id);
7027   return schema.$id;
7028 }
7029
7030
7031 function _get$IdOrId(schema) {
7032   if (schema.$id && schema.id && schema.$id != schema.id)
7033     throw new Error('schema $id is different from id');
7034   return schema.$id || schema.id;
7035 }
7036
7037
7038 /**
7039  * Convert array of error message objects to string
7040  * @this   Ajv
7041  * @param  {Array<Object>} errors optional array of validation errors, if not passed errors from the instance are used.
7042  * @param  {Object} options optional options with properties `separator` and `dataVar`.
7043  * @return {String} human readable string with all errors descriptions
7044  */
7045 function errorsText(errors, options) {
7046   errors = errors || this.errors;
7047   if (!errors) return 'No errors';
7048   options = options || {};
7049   var separator = options.separator === undefined ? ', ' : options.separator;
7050   var dataVar = options.dataVar === undefined ? 'data' : options.dataVar;
7051
7052   var text = '';
7053   for (var i=0; i<errors.length; i++) {
7054     var e = errors[i];
7055     if (e) text += dataVar + e.dataPath + ' ' + e.message + separator;
7056   }
7057   return text.slice(0, -separator.length);
7058 }
7059
7060
7061 /**
7062  * Add custom format
7063  * @this   Ajv
7064  * @param {String} name format name
7065  * @param {String|RegExp|Function} format string is converted to RegExp; function should return boolean (true when valid)
7066  * @return {Ajv} this for method chaining
7067  */
7068 function addFormat(name, format) {
7069   if (typeof format == 'string') format = new RegExp(format);
7070   this._formats[name] = format;
7071   return this;
7072 }
7073
7074
7075 function addDefaultMetaSchema(self) {
7076   var $dataSchema;
7077   if (self._opts.$data) {
7078     $dataSchema = require('./refs/data.json');
7079     self.addMetaSchema($dataSchema, $dataSchema.$id, true);
7080   }
7081   if (self._opts.meta === false) return;
7082   var metaSchema = require('./refs/json-schema-draft-07.json');
7083   if (self._opts.$data) metaSchema = $dataMetaSchema(metaSchema, META_SUPPORT_DATA);
7084   self.addMetaSchema(metaSchema, META_SCHEMA_ID, true);
7085   self._refs['http://json-schema.org/schema'] = META_SCHEMA_ID;
7086 }
7087
7088
7089 function addInitialSchemas(self) {
7090   var optsSchemas = self._opts.schemas;
7091   if (!optsSchemas) return;
7092   if (Array.isArray(optsSchemas)) self.addSchema(optsSchemas);
7093   else for (var key in optsSchemas) self.addSchema(optsSchemas[key], key);
7094 }
7095
7096
7097 function addInitialFormats(self) {
7098   for (var name in self._opts.formats) {
7099     var format = self._opts.formats[name];
7100     self.addFormat(name, format);
7101   }
7102 }
7103
7104
7105 function addInitialKeywords(self) {
7106   for (var name in self._opts.keywords) {
7107     var keyword = self._opts.keywords[name];
7108     self.addKeyword(name, keyword);
7109   }
7110 }
7111
7112
7113 function checkUnique(self, id) {
7114   if (self._schemas[id] || self._refs[id])
7115     throw new Error('schema with key or id "' + id + '" already exists');
7116 }
7117
7118
7119 function getMetaSchemaOptions(self) {
7120   var metaOpts = util.copy(self._opts);
7121   for (var i=0; i<META_IGNORE_OPTIONS.length; i++)
7122     delete metaOpts[META_IGNORE_OPTIONS[i]];
7123   return metaOpts;
7124 }
7125
7126
7127 function setLogger(self) {
7128   var logger = self._opts.logger;
7129   if (logger === false) {
7130     self.logger = {log: noop, warn: noop, error: noop};
7131   } else {
7132     if (logger === undefined) logger = console;
7133     if (!(typeof logger == 'object' && logger.log && logger.warn && logger.error))
7134       throw new Error('logger must implement log, warn and error methods');
7135     self.logger = logger;
7136   }
7137 }
7138
7139
7140 function noop() {}
7141
7142 },{"./cache":1,"./compile":5,"./compile/async":2,"./compile/error_classes":3,"./compile/formats":4,"./compile/resolve":6,"./compile/rules":7,"./compile/schema_obj":8,"./compile/util":10,"./data":11,"./keyword":39,"./refs/data.json":40,"./refs/json-schema-draft-07.json":41,"fast-json-stable-stringify":43}]},{},[])("ajv")
7143 });