BVB Source Codes

reactide Show ajv.bundle.js Source code

Return Download reactide: download ajv.bundle.js Source code - Download reactide Source code - Type:.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 e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
  2. 'use strict';
  3.  
  4. module.exports = {
  5.   setup: setupAsync,
  6.   compile: compileAsync
  7. };
  8.  
  9.  
  10. var util = require('./compile/util');
  11.  
  12. var ASYNC = {
  13.   '*': checkGenerators,
  14.   'co*': checkGenerators,
  15.   'es7': checkAsyncFunction
  16. };
  17.  
  18. var TRANSPILE = {
  19.   'nodent': getNodent,
  20.   'regenerator': getRegenerator
  21. };
  22.  
  23. var MODES = [
  24.   { async: 'co*' },
  25.   { async: 'es7', transpile: 'nodent' },
  26.   { async: 'co*', transpile: 'regenerator' }
  27. ];
  28.  
  29.  
  30. var regenerator, nodent;
  31.  
  32.  
  33. function setupAsync(opts, required) {
  34.   if (required !== false) required = true;
  35.   var async = opts.async
  36.     , transpile = opts.transpile
  37.     , check;
  38.  
  39.   switch (typeof transpile) {
  40.     case 'string':
  41.       var get = TRANSPILE[transpile];
  42.       if (!get) throw new Error('bad transpiler: ' + transpile);
  43.       return (opts._transpileFunc = get(opts, required));
  44.     case 'undefined':
  45.     case 'boolean':
  46.       if (typeof async == 'string') {
  47.         check = ASYNC[async];
  48.         if (!check) throw new Error('bad async mode: ' + async);
  49.         return (opts.transpile = check(opts, required));
  50.       }
  51.  
  52.       for (var i=0; i<MODES.length; i++) {
  53.         var _opts = MODES[i];
  54.         if (setupAsync(_opts, false)) {
  55.           util.copy(_opts, opts);
  56.           return opts.transpile;
  57.         }
  58.       }
  59.       /* istanbul ignore next */
  60.       throw new Error('generators, nodent and regenerator are not available');
  61.     case 'function':
  62.       return (opts._transpileFunc = opts.transpile);
  63.     default:
  64.       throw new Error('bad transpiler: ' + transpile);
  65.   }
  66. }
  67.  
  68.  
  69. function checkGenerators(opts, required) {
  70.   /* jshint evil: true */
  71.   try {
  72.     (new Function('(function*(){})()'))();
  73.     return true;
  74.   } catch(e) {
  75.     /* istanbul ignore next */
  76.     if (required) throw new Error('generators not supported');
  77.   }
  78. }
  79.  
  80.  
  81. function checkAsyncFunction(opts, required) {
  82.   /* jshint evil: true */
  83.   try {
  84.     (new Function('(async function(){})()'))();
  85.     /* istanbul ignore next */
  86.     return true;
  87.   } catch(e) {
  88.     if (required) throw new Error('es7 async functions not supported');
  89.   }
  90. }
  91.  
  92.  
  93. function getRegenerator(opts, required) {
  94.   try {
  95.     if (!regenerator) {
  96.       var name = 'regenerator';
  97.       regenerator = require(name);
  98.       regenerator.runtime();
  99.     }
  100.     if (!opts.async || opts.async === true)
  101.       opts.async = 'es7';
  102.     return regeneratorTranspile;
  103.   } catch(e) {
  104.     /* istanbul ignore next */
  105.     if (required) throw new Error('regenerator not available');
  106.   }
  107. }
  108.  
  109.  
  110. function regeneratorTranspile(code) {
  111.   return regenerator.compile(code).code;
  112. }
  113.  
  114.  
  115. function getNodent(opts, required) {
  116.   /* jshint evil: true */
  117.   try {
  118.     if (!nodent) {
  119.       var name = 'nodent';
  120.       nodent = require(name)({ log: false, dontInstallRequireHook: true });
  121.     }
  122.     if (opts.async != 'es7') {
  123.       if (opts.async && opts.async !== true) console.warn('nodent transpiles only es7 async functions');
  124.       opts.async = 'es7';
  125.     }
  126.     return nodentTranspile;
  127.   } catch(e) {
  128.     /* istanbul ignore next */
  129.     if (required) throw new Error('nodent not available');
  130.   }
  131. }
  132.  
  133.  
  134. function nodentTranspile(code) {
  135.   return nodent.compile(code, '', { promises: true, sourcemap: false }).code;
  136. }
  137.  
  138.  
  139. /**
  140.  * Creates validating function for passed schema with asynchronous loading of missing schemas.
  141.  * `loadSchema` option should be a function that accepts schema uri and node-style callback.
  142.  * @this  Ajv
  143.  * @param {Object}   schema schema object
  144.  * @param {Function} callback node-style callback, it is always called with 2 parameters: error (or null) and validating function.
  145.  */
  146. function compileAsync(schema, callback) {
  147.   /* eslint no-shadow: 0 */
  148.   /* jshint validthis: true */
  149.   var schemaObj;
  150.   var self = this;
  151.   try {
  152.     schemaObj = this._addSchema(schema);
  153.   } catch(e) {
  154.     setTimeout(function() { callback(e); });
  155.     return;
  156.   }
  157.   if (schemaObj.validate) {
  158.     setTimeout(function() { callback(null, schemaObj.validate); });
  159.   } else {
  160.     if (typeof this._opts.loadSchema != 'function')
  161.       throw new Error('options.loadSchema should be a function');
  162.     _compileAsync(schema, callback, true);
  163.   }
  164.  
  165.  
  166.   function _compileAsync(schema, callback, firstCall) {
  167.     var validate;
  168.     try { validate = self.compile(schema); }
  169.     catch(e) {
  170.       if (e.missingSchema) loadMissingSchema(e);
  171.       else deferCallback(e);
  172.       return;
  173.     }
  174.     deferCallback(null, validate);
  175.  
  176.     function loadMissingSchema(e) {
  177.       var ref = e.missingSchema;
  178.       if (self._refs[ref] || self._schemas[ref])
  179.         return callback(new Error('Schema ' + ref + ' is loaded but ' + e.missingRef + ' cannot be resolved'));
  180.       var _callbacks = self._loadingSchemas[ref];
  181.       if (_callbacks) {
  182.         if (typeof _callbacks == 'function')
  183.           self._loadingSchemas[ref] = [_callbacks, schemaLoaded];
  184.         else
  185.           _callbacks[_callbacks.length] = schemaLoaded;
  186.       } else {
  187.         self._loadingSchemas[ref] = schemaLoaded;
  188.         self._opts.loadSchema(ref, function (err, sch) {
  189.           var _callbacks = self._loadingSchemas[ref];
  190.           delete self._loadingSchemas[ref];
  191.           if (typeof _callbacks == 'function') {
  192.             _callbacks(err, sch);
  193.           } else {
  194.             for (var i=0; i<_callbacks.length; i++)
  195.               _callbacks[i](err, sch);
  196.           }
  197.         });
  198.       }
  199.  
  200.       function schemaLoaded(err, sch) {
  201.         if (err) return callback(err);
  202.         if (!(self._refs[ref] || self._schemas[ref])) {
  203.           try {
  204.             self.addSchema(sch, ref);
  205.           } catch(e) {
  206.             callback(e);
  207.             return;
  208.           }
  209.         }
  210.         _compileAsync(schema, callback);
  211.       }
  212.     }
  213.  
  214.     function deferCallback(err, validate) {
  215.       if (firstCall) setTimeout(function() { callback(err, validate); });
  216.       else return callback(err, validate);
  217.     }
  218.   }
  219. }
  220.  
  221. },{"./compile/util":11}],2:[function(require,module,exports){
  222. 'use strict';
  223.  
  224.  
  225. var Cache = module.exports = function Cache() {
  226.   this._cache = {};
  227. };
  228.  
  229.  
  230. Cache.prototype.put = function Cache_put(key, value) {
  231.   this._cache[key] = value;
  232. };
  233.  
  234.  
  235. Cache.prototype.get = function Cache_get(key) {
  236.   return this._cache[key];
  237. };
  238.  
  239.  
  240. Cache.prototype.del = function Cache_del(key) {
  241.   delete this._cache[key];
  242. };
  243.  
  244.  
  245. Cache.prototype.clear = function Cache_clear() {
  246.   this._cache = {};
  247. };
  248.  
  249. },{}],3:[function(require,module,exports){
  250. 'use strict';
  251.  
  252. //all requires must be explicit because browserify won't work with dynamic requires
  253. module.exports = {
  254.   '$ref': require('../dotjs/ref'),
  255.   allOf: require('../dotjs/allOf'),
  256.   anyOf: require('../dotjs/anyOf'),
  257.   dependencies: require('../dotjs/dependencies'),
  258.   'enum': require('../dotjs/enum'),
  259.   format: require('../dotjs/format'),
  260.   items: require('../dotjs/items'),
  261.   maximum: require('../dotjs/_limit'),
  262.   minimum: require('../dotjs/_limit'),
  263.   maxItems: require('../dotjs/_limitItems'),
  264.   minItems: require('../dotjs/_limitItems'),
  265.   maxLength: require('../dotjs/_limitLength'),
  266.   minLength: require('../dotjs/_limitLength'),
  267.   maxProperties: require('../dotjs/_limitProperties'),
  268.   minProperties: require('../dotjs/_limitProperties'),
  269.   multipleOf: require('../dotjs/multipleOf'),
  270.   not: require('../dotjs/not'),
  271.   oneOf: require('../dotjs/oneOf'),
  272.   pattern: require('../dotjs/pattern'),
  273.   properties: require('../dotjs/properties'),
  274.   required: require('../dotjs/required'),
  275.   uniqueItems: require('../dotjs/uniqueItems'),
  276.   validate: require('../dotjs/validate')
  277. };
  278.  
  279. },{"../dotjs/_limit":14,"../dotjs/_limitItems":15,"../dotjs/_limitLength":16,"../dotjs/_limitProperties":17,"../dotjs/allOf":18,"../dotjs/anyOf":19,"../dotjs/dependencies":22,"../dotjs/enum":23,"../dotjs/format":24,"../dotjs/items":25,"../dotjs/multipleOf":26,"../dotjs/not":27,"../dotjs/oneOf":28,"../dotjs/pattern":29,"../dotjs/properties":31,"../dotjs/ref":32,"../dotjs/required":33,"../dotjs/uniqueItems":35,"../dotjs/validate":36}],4:[function(require,module,exports){
  280. 'use strict';
  281.  
  282. /*eslint complexity: 0*/
  283.  
  284. module.exports = function equal(a, b) {
  285.   if (a === b) return true;
  286.  
  287.   var arrA = Array.isArray(a)
  288.     , arrB = Array.isArray(b)
  289.     , i;
  290.  
  291.   if (arrA && arrB) {
  292.     if (a.length != b.length) return false;
  293.     for (i = 0; i < a.length; i++)
  294.       if (!equal(a[i], b[i])) return false;
  295.     return true;
  296.   }
  297.  
  298.   if (arrA != arrB) return false;
  299.  
  300.   if (a && b && typeof a === 'object' && typeof b === 'object') {
  301.     var keys = Object.keys(a);
  302.     if (keys.length !== Object.keys(b).length) return false;
  303.  
  304.     var dateA = a instanceof Date
  305.       , dateB = b instanceof Date;
  306.     if (dateA && dateB) return a.getTime() == b.getTime();
  307.     if (dateA != dateB) return false;
  308.  
  309.     var regexpA = a instanceof RegExp
  310.       , regexpB = b instanceof RegExp;
  311.     if (regexpA && regexpB) return a.toString() == b.toString();
  312.     if (regexpA != regexpB) return false;
  313.  
  314.     for (i = 0; i < keys.length; i++)
  315.       if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
  316.  
  317.     for (i = 0; i < keys.length; i++)
  318.       if(!equal(a[keys[i]], b[keys[i]])) return false;
  319.  
  320.     return true;
  321.   }
  322.  
  323.   return false;
  324. };
  325.  
  326. },{}],5:[function(require,module,exports){
  327. 'use strict';
  328.  
  329. var util = require('./util');
  330.  
  331. var DATE = /^\d\d\d\d-(\d\d)-(\d\d)$/;
  332. var DAYS = [0,31,29,31,30,31,30,31,31,30,31,30,31];
  333. var TIME = /^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d:\d\d)?$/i;
  334. var HOSTNAME = /^[0-9a-z](?:(?:[-0-9a-z]{0,61})?[0-9a-z])?(\.[0-9a-z](?:(?:[-0-9a-z]{0,61})?[0-9a-z])?)*$/i;
  335. 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;
  336. var UUID = /^(?:urn\:uuid\:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i;
  337. var JSON_POINTER = /^(?:\/(?:[^~\/]|~0|~1)*)*$|^\#(?:\/(?:[a-z0-9_\-\.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i;
  338. var RELATIVE_JSON_POINTER = /^(?:0|[1-9][0-9]*)(?:\#|(?:\/(?:[^~\/]|~0|~1)*)*)$/;
  339.  
  340.  
  341. module.exports = formats;
  342.  
  343. function formats(mode) {
  344.   mode = mode == 'full' ? 'full' : 'fast';
  345.   var formatDefs = util.copy(formats[mode]);
  346.   for (var fName in formats.compare) {
  347.     formatDefs[fName] = {
  348.       validate: formatDefs[fName],
  349.       compare: formats.compare[fName]
  350.     };
  351.   }
  352.   return formatDefs;
  353. }
  354.  
  355.  
  356. formats.fast = {
  357.   // date: http://tools.ietf.org/html/rfc3339#section-5.6
  358.   date: /^\d\d\d\d-[0-1]\d-[0-3]\d$/,
  359.   // date-time: http://tools.ietf.org/html/rfc3339#section-5.6
  360.   time: /^[0-2]\d:[0-5]\d:[0-5]\d(?:\.\d+)?(?:z|[+-]\d\d:\d\d)?$/i,
  361.   'date-time': /^\d\d\d\d-[0-1]\d-[0-3]\d[t\s][0-2]\d:[0-5]\d:[0-5]\d(?:\.\d+)?(?:z|[+-]\d\d:\d\d)$/i,
  362.   // uri: https://github.com/mafintosh/is-my-json-valid/blob/master/formats.js
  363.   uri: /^(?:[a-z][a-z0-9+-.]*)?(?:\:|\/)\/?[^\s]*$/i,
  364.   // email (sources from jsen validator):
  365.   // http://stackoverflow.com/questions/201323/using-a-regular-expression-to-validate-an-email-address#answer-8829363
  366.   // http://www.w3.org/TR/html5/forms.html#valid-e-mail-address (search for 'willful violation')
  367.   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,
  368.   hostname: HOSTNAME,
  369.   // optimized https://www.safaribooksonline.com/library/view/regular-expressions-cookbook/9780596802837/ch07s16.html
  370.   ipv4: /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,
  371.   // optimized http://stackoverflow.com/questions/53497/regular-expression-that-matches-valid-ipv6-addresses
  372.   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,
  373.   regex: regex,
  374.   // uuid: http://tools.ietf.org/html/rfc4122
  375.   uuid: UUID,
  376.   // JSON-pointer: https://tools.ietf.org/html/rfc6901
  377.   // uri fragment: https://tools.ietf.org/html/rfc3986#appendix-A
  378.   'json-pointer': JSON_POINTER,
  379.   // relative JSON-pointer: http://tools.ietf.org/html/draft-luff-relative-json-pointer-00
  380.   'relative-json-pointer': RELATIVE_JSON_POINTER
  381. };
  382.  
  383.  
  384. formats.full = {
  385.   date: date,
  386.   time: time,
  387.   'date-time': date_time,
  388.   uri: uri,
  389.   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,
  390.   hostname: hostname,
  391.   ipv4: /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,
  392.   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,
  393.   regex: regex,
  394.   uuid: UUID,
  395.   'json-pointer': JSON_POINTER,
  396.   'relative-json-pointer': RELATIVE_JSON_POINTER
  397. };
  398.  
  399.  
  400. formats.compare = {
  401.   date: compareDate,
  402.   time: compareTime,
  403.   'date-time': compareDateTime
  404. };
  405.  
  406.  
  407. function date(str) {
  408.   // full-date from http://tools.ietf.org/html/rfc3339#section-5.6
  409.   var matches = str.match(DATE);
  410.   if (!matches) return false;
  411.  
  412.   var month = +matches[1];
  413.   var day = +matches[2];
  414.   return month >= 1 && month <= 12 && day >= 1 && day <= DAYS[month];
  415. }
  416.  
  417.  
  418. function time(str, full) {
  419.   var matches = str.match(TIME);
  420.   if (!matches) return false;
  421.  
  422.   var hour = matches[1];
  423.   var minute = matches[2];
  424.   var second = matches[3];
  425.   var timeZone = matches[5];
  426.   return hour <= 23 && minute <= 59 && second <= 59 && (!full || timeZone);
  427. }
  428.  
  429.  
  430. var DATE_TIME_SEPARATOR = /t|\s/i;
  431. function date_time(str) {
  432.   // http://tools.ietf.org/html/rfc3339#section-5.6
  433.   var dateTime = str.split(DATE_TIME_SEPARATOR);
  434.   return dateTime.length == 2 && date(dateTime[0]) && time(dateTime[1], true);
  435. }
  436.  
  437.  
  438. function hostname(str) {
  439.   // https://tools.ietf.org/html/rfc1034#section-3.5
  440.   // https://tools.ietf.org/html/rfc1123#section-2
  441.   return str.length <= 255 && HOSTNAME.test(str);
  442. }
  443.  
  444.  
  445. var NOT_URI_FRAGMENT = /\/|\:/;
  446. function uri(str) {
  447.   // http://jmrware.com/articles/2009/uri_regexp/URI_regex.html + optional protocol + required "."
  448.   return NOT_URI_FRAGMENT.test(str) && URI.test(str);
  449. }
  450.  
  451.  
  452. function regex(str) {
  453.   try {
  454.     new RegExp(str);
  455.     return true;
  456.   } catch(e) {
  457.     return false;
  458.   }
  459. }
  460.  
  461.  
  462. function compareDate(d1, d2) {
  463.   if (!(d1 && d2)) return;
  464.   if (d1 > d2) return 1;
  465.   if (d1 < d2) return -1;
  466.   if (d1 === d2) return 0;
  467. }
  468.  
  469.  
  470. function compareTime(t1, t2) {
  471.   if (!(t1 && t2)) return;
  472.   t1 = t1.match(TIME);
  473.   t2 = t2.match(TIME);
  474.   if (!(t1 && t2)) return;
  475.   t1 = t1[1] + t1[2] + t1[3] + (t1[4]||'');
  476.   t2 = t2[1] + t2[2] + t2[3] + (t2[4]||'');
  477.   if (t1 > t2) return 1;
  478.   if (t1 < t2) return -1;
  479.   if (t1 === t2) return 0;
  480. }
  481.  
  482.  
  483. function compareDateTime(dt1, dt2) {
  484.   if (!(dt1 && dt2)) return;
  485.   dt1 = dt1.split(DATE_TIME_SEPARATOR);
  486.   dt2 = dt2.split(DATE_TIME_SEPARATOR);
  487.   var res = compareDate(dt1[0], dt2[0]);
  488.   if (res === undefined) return;
  489.   return res || compareTime(dt1[1], dt2[1]);
  490. }
  491.  
  492. },{"./util":11}],6:[function(require,module,exports){
  493. 'use strict';
  494.  
  495. var resolve = require('./resolve')
  496.   , util = require('./util')
  497.   , stableStringify = require('json-stable-stringify')
  498.   , async = require('../async');
  499.  
  500. var beautify;
  501.  
  502. function loadBeautify(){
  503.   if (beautify === undefined) {
  504.     var name = 'js-beautify';
  505.     try { beautify = require(name).js_beautify; }
  506.     catch(e) { beautify = false; }
  507.   }
  508. }
  509.  
  510. var validateGenerator = require('../dotjs/validate');
  511.  
  512. /**
  513.  * Functions below are used inside compiled validations function
  514.  */
  515.  
  516. var co = require('co');
  517. var ucs2length = util.ucs2length;
  518. var equal = require('./equal');
  519.  
  520. // this error is thrown by async schemas to return validation errors via exception
  521. var ValidationError = require('./validation_error');
  522.  
  523. module.exports = compile;
  524.  
  525.  
  526. /**
  527.  * Compiles schema to validation function
  528.  * @this   Ajv
  529.  * @param  {Object} schema schema object
  530.  * @param  {Object} root object with information about the root schema for this schema
  531.  * @param  {Object} localRefs the hash of local references inside the schema (created by resolve.id), used for inline resolution
  532.  * @param  {String} baseId base ID for IDs in the schema
  533.  * @return {Function} validation function
  534.  */
  535. function compile(schema, root, localRefs, baseId) {
  536.   /* jshint validthis: true, evil: true */
  537.   /* eslint no-shadow: 0 */
  538.   var self = this
  539.     , opts = this._opts
  540.     , refVal = [ undefined ]
  541.     , refs = {}
  542.     , patterns = []
  543.     , patternsHash = {}
  544.     , defaults = []
  545.     , defaultsHash = {}
  546.     , customRules = []
  547.     , keepSourceCode = opts.sourceCode !== false;
  548.  
  549.   root = root || { schema: schema, refVal: refVal, refs: refs };
  550.  
  551.   var c = checkCompiling.call(this, schema, root, baseId);
  552.   var compilation = this._compilations[c.index];
  553.   if (c.compiling) return (compilation.callValidate = callValidate);
  554.  
  555.   var formats = this._formats;
  556.   var RULES = this.RULES;
  557.  
  558.   try {
  559.     var v = localCompile(schema, root, localRefs, baseId);
  560.     compilation.validate = v;
  561.     var cv = compilation.callValidate;
  562.     if (cv) {
  563.       cv.schema = v.schema;
  564.       cv.errors = null;
  565.       cv.refs = v.refs;
  566.       cv.refVal = v.refVal;
  567.       cv.root = v.root;
  568.       cv.$async = v.$async;
  569.       if (keepSourceCode) cv.sourceCode = v.sourceCode;
  570.     }
  571.     return v;
  572.   } finally {
  573.     endCompiling.call(this, schema, root, baseId);
  574.   }
  575.  
  576.   function callValidate() {
  577.     var validate = compilation.validate;
  578.     var result = validate.apply(null, arguments);
  579.     callValidate.errors = validate.errors;
  580.     return result;
  581.   }
  582.  
  583.   function localCompile(_schema, _root, localRefs, baseId) {
  584.     var isRoot = !_root || (_root && _root.schema == _schema);
  585.     if (_root.schema != root.schema)
  586.       return compile.call(self, _schema, _root, localRefs, baseId);
  587.  
  588.     var $async = _schema.$async === true;
  589.     if ($async && !opts.transpile) async.setup(opts);
  590.  
  591.     var sourceCode = validateGenerator({
  592.       isTop: true,
  593.       schema: _schema,
  594.       isRoot: isRoot,
  595.       baseId: baseId,
  596.       root: _root,
  597.       schemaPath: '',
  598.       errSchemaPath: '#',
  599.       errorPath: '""',
  600.       RULES: RULES,
  601.       validate: validateGenerator,
  602.       util: util,
  603.       resolve: resolve,
  604.       resolveRef: resolveRef,
  605.       usePattern: usePattern,
  606.       useDefault: useDefault,
  607.       useCustomRule: useCustomRule,
  608.       opts: opts,
  609.       formats: formats,
  610.       self: self
  611.     });
  612.  
  613.     sourceCode = vars(refVal, refValCode) + vars(patterns, patternCode)
  614.                    + vars(defaults, defaultCode) + vars(customRules, customRuleCode)
  615.                    + sourceCode;
  616.  
  617.     if (opts.beautify) {
  618.       loadBeautify();
  619.       /* istanbul ignore else */
  620.       if (beautify) sourceCode = beautify(sourceCode, opts.beautify);
  621.       else console.error('"npm install js-beautify" to use beautify option');
  622.     }
  623.     // console.log('\n\n\n *** \n', sourceCode);
  624.     var validate, validateCode
  625.       , transpile = opts._transpileFunc;
  626.     try {
  627.       validateCode = $async && transpile
  628.                       ? transpile(sourceCode)
  629.                       : sourceCode;
  630.  
  631.       var makeValidate = new Function(
  632.         'self',
  633.         'RULES',
  634.         'formats',
  635.         'root',
  636.         'refVal',
  637.         'defaults',
  638.         'customRules',
  639.         'co',
  640.         'equal',
  641.         'ucs2length',
  642.         'ValidationError',
  643.         validateCode
  644.       );
  645.  
  646.       validate = makeValidate(
  647.         self,
  648.         RULES,
  649.         formats,
  650.         root,
  651.         refVal,
  652.         defaults,
  653.         customRules,
  654.         co,
  655.         equal,
  656.         ucs2length,
  657.         ValidationError
  658.       );
  659.  
  660.       refVal[0] = validate;
  661.     } catch(e) {
  662.       console.error('Error compiling schema, function code:', validateCode);
  663.       throw e;
  664.     }
  665.  
  666.     validate.schema = _schema;
  667.     validate.errors = null;
  668.     validate.refs = refs;
  669.     validate.refVal = refVal;
  670.     validate.root = isRoot ? validate : _root;
  671.     if ($async) validate.$async = true;
  672.     if (keepSourceCode) validate.sourceCode = sourceCode;
  673.     if (opts.sourceCode === true) {
  674.       validate.source = {
  675.         patterns: patterns,
  676.         defaults: defaults
  677.       };
  678.     }
  679.  
  680.     return validate;
  681.   }
  682.  
  683.   function resolveRef(baseId, ref, isRoot) {
  684.     ref = resolve.url(baseId, ref);
  685.     var refIndex = refs[ref];
  686.     var _refVal, refCode;
  687.     if (refIndex !== undefined) {
  688.       _refVal = refVal[refIndex];
  689.       refCode = 'refVal[' + refIndex + ']';
  690.       return resolvedRef(_refVal, refCode);
  691.     }
  692.     if (!isRoot && root.refs) {
  693.       var rootRefId = root.refs[ref];
  694.       if (rootRefId !== undefined) {
  695.         _refVal = root.refVal[rootRefId];
  696.         refCode = addLocalRef(ref, _refVal);
  697.         return resolvedRef(_refVal, refCode);
  698.       }
  699.     }
  700.  
  701.     refCode = addLocalRef(ref);
  702.     var v = resolve.call(self, localCompile, root, ref);
  703.     if (!v) {
  704.       var localSchema = localRefs && localRefs[ref];
  705.       if (localSchema) {
  706.         v = resolve.inlineRef(localSchema, opts.inlineRefs)
  707.             ? localSchema
  708.             : compile.call(self, localSchema, root, localRefs, baseId);
  709.       }
  710.     }
  711.  
  712.     if (v) {
  713.       replaceLocalRef(ref, v);
  714.       return resolvedRef(v, refCode);
  715.     }
  716.   }
  717.  
  718.   function addLocalRef(ref, v) {
  719.     var refId = refVal.length;
  720.     refVal[refId] = v;
  721.     refs[ref] = refId;
  722.     return 'refVal' + refId;
  723.   }
  724.  
  725.   function replaceLocalRef(ref, v) {
  726.     var refId = refs[ref];
  727.     refVal[refId] = v;
  728.   }
  729.  
  730.   function resolvedRef(refVal, code) {
  731.     return typeof refVal == 'object'
  732.             ? { code: code, schema: refVal, inline: true }
  733.             : { code: code, $async: refVal && refVal.$async };
  734.   }
  735.  
  736.   function usePattern(regexStr) {
  737.     var index = patternsHash[regexStr];
  738.     if (index === undefined) {
  739.       index = patternsHash[regexStr] = patterns.length;
  740.       patterns[index] = regexStr;
  741.     }
  742.     return 'pattern' + index;
  743.   }
  744.  
  745.   function useDefault(value) {
  746.     switch (typeof value) {
  747.       case 'boolean':
  748.       case 'number':
  749.         return '' + value;
  750.       case 'string':
  751.         return util.toQuotedString(value);
  752.       case 'object':
  753.         if (value === null) return 'null';
  754.         var valueStr = stableStringify(value);
  755.         var index = defaultsHash[valueStr];
  756.         if (index === undefined) {
  757.           index = defaultsHash[valueStr] = defaults.length;
  758.           defaults[index] = value;
  759.         }
  760.         return 'default' + index;
  761.     }
  762.   }
  763.  
  764.   function useCustomRule(rule, schema, parentSchema, it) {
  765.     var validateSchema = rule.definition.validateSchema;
  766.     if (validateSchema && self._opts.validateSchema !== false) {
  767.       var valid = validateSchema(schema);
  768.       if (!valid) {
  769.         var message = 'keyword schema is invalid: ' + self.errorsText(validateSchema.errors);
  770.         if (self._opts.validateSchema == 'log') console.error(message);
  771.         else throw new Error(message);
  772.       }
  773.     }
  774.  
  775.     var compile = rule.definition.compile
  776.       , inline = rule.definition.inline
  777.       , macro = rule.definition.macro;
  778.  
  779.     var validate;
  780.     if (compile) {
  781.       validate = compile.call(self, schema, parentSchema, it);
  782.     } else if (macro) {
  783.       validate = macro.call(self, schema, parentSchema, it);
  784.       if (opts.validateSchema !== false) self.validateSchema(validate, true);
  785.     } else if (inline) {
  786.       validate = inline.call(self, it, rule.keyword, schema, parentSchema);
  787.     } else {
  788.       validate = rule.definition.validate;
  789.     }
  790.  
  791.     var index = customRules.length;
  792.     customRules[index] = validate;
  793.  
  794.     return {
  795.       code: 'customRule' + index,
  796.       validate: validate
  797.     };
  798.   }
  799. }
  800.  
  801.  
  802. /**
  803.  * Checks if the schema is currently compiled
  804.  * @this   Ajv
  805.  * @param  {Object} schema schema to compile
  806.  * @param  {Object} root root object
  807.  * @param  {String} baseId base schema ID
  808.  * @return {Object} object with properties "index" (compilation index) and "compiling" (boolean)
  809.  */
  810. function checkCompiling(schema, root, baseId) {
  811.   /* jshint validthis: true */
  812.   var index = compIndex.call(this, schema, root, baseId);
  813.   if (index >= 0) return { index: index, compiling: true };
  814.   index = this._compilations.length;
  815.   this._compilations[index] = {
  816.     schema: schema,
  817.     root: root,
  818.     baseId: baseId
  819.   };
  820.   return { index: index, compiling: false };
  821. }
  822.  
  823.  
  824. /**
  825.  * Removes the schema from the currently compiled list
  826.  * @this   Ajv
  827.  * @param  {Object} schema schema to compile
  828.  * @param  {Object} root root object
  829.  * @param  {String} baseId base schema ID
  830.  */
  831. function endCompiling(schema, root, baseId) {
  832.   /* jshint validthis: true */
  833.   var i = compIndex.call(this, schema, root, baseId);
  834.   if (i >= 0) this._compilations.splice(i, 1);
  835. }
  836.  
  837.  
  838. /**
  839.  * Index of schema compilation in the currently compiled list
  840.  * @this   Ajv
  841.  * @param  {Object} schema schema to compile
  842.  * @param  {Object} root root object
  843.  * @param  {String} baseId base schema ID
  844.  * @return {Integer} compilation index
  845.  */
  846. function compIndex(schema, root, baseId) {
  847.   /* jshint validthis: true */
  848.   for (var i=0; i<this._compilations.length; i++) {
  849.     var c = this._compilations[i];
  850.     if (c.schema == schema && c.root == root && c.baseId == baseId) return i;
  851.   }
  852.   return -1;
  853. }
  854.  
  855.  
  856. function patternCode(i, patterns) {
  857.   return 'var pattern' + i + ' = new RegExp(' + util.toQuotedString(patterns[i]) + ');';
  858. }
  859.  
  860.  
  861. function defaultCode(i) {
  862.   return 'var default' + i + ' = defaults[' + i + '];';
  863. }
  864.  
  865.  
  866. function refValCode(i, refVal) {
  867.   return refVal[i] ? 'var refVal' + i + ' = refVal[' + i + '];' : '';
  868. }
  869.  
  870.  
  871. function customRuleCode(i) {
  872.   return 'var customRule' + i + ' = customRules[' + i + '];';
  873. }
  874.  
  875.  
  876. function vars(arr, statement) {
  877.   if (!arr.length) return '';
  878.   var code = '';
  879.   for (var i=0; i<arr.length; i++)
  880.     code += statement(i, arr);
  881.   return code;
  882. }
  883.  
  884. },{"../async":1,"../dotjs/validate":36,"./equal":4,"./resolve":7,"./util":11,"./validation_error":12,"co":47,"json-stable-stringify":48}],7:[function(require,module,exports){
  885. 'use strict';
  886.  
  887. var url = require('url')
  888.   , equal = require('./equal')
  889.   , util = require('./util')
  890.   , SchemaObject = require('./schema_obj');
  891.  
  892. module.exports = resolve;
  893.  
  894. resolve.normalizeId = normalizeId;
  895. resolve.fullPath = getFullPath;
  896. resolve.url = resolveUrl;
  897. resolve.ids = resolveIds;
  898. resolve.inlineRef = inlineRef;
  899. resolve.schema = resolveSchema;
  900.  
  901. /**
  902.  * [resolve and compile the references ($ref)]
  903.  * @this   Ajv
  904.  * @param  {Function} compile reference to schema compilation funciton (localCompile)
  905.  * @param  {Object} root object with information about the root schema for the current schema
  906.  * @param  {String} ref reference to resolve
  907.  * @return {Object|Function} schema object (if the schema can be inlined) or validation function
  908.  */
  909. function resolve(compile, root, ref) {
  910.   /* jshint validthis: true */
  911.   var refVal = this._refs[ref];
  912.   if (typeof refVal == 'string') {
  913.     if (this._refs[refVal]) refVal = this._refs[refVal];
  914.     else return resolve.call(this, compile, root, refVal);
  915.   }
  916.  
  917.   refVal = refVal || this._schemas[ref];
  918.   if (refVal instanceof SchemaObject) {
  919.     return inlineRef(refVal.schema, this._opts.inlineRefs)
  920.             ? refVal.schema
  921.             : refVal.validate || this._compile(refVal);
  922.   }
  923.  
  924.   var res = resolveSchema.call(this, root, ref);
  925.   var schema, v, baseId;
  926.   if (res) {
  927.     schema = res.schema;
  928.     root = res.root;
  929.     baseId = res.baseId;
  930.   }
  931.  
  932.   if (schema instanceof SchemaObject) {
  933.     v = schema.validate || compile.call(this, schema.schema, root, undefined, baseId);
  934.   } else if (schema) {
  935.     v = inlineRef(schema, this._opts.inlineRefs)
  936.         ? schema
  937.         : compile.call(this, schema, root, undefined, baseId);
  938.   }
  939.  
  940.   return v;
  941. }
  942.  
  943.  
  944. /**
  945.  * Resolve schema, its root and baseId
  946.  * @this Ajv
  947.  * @param  {Object} root root object with properties schema, refVal, refs
  948.  * @param  {String} ref  reference to resolve
  949.  * @return {Object} object with properties schema, root, baseId
  950.  */
  951. function resolveSchema(root, ref) {
  952.   /* jshint validthis: true */
  953.   var p = url.parse(ref, false, true)
  954.     , refPath = _getFullPath(p)
  955.     , baseId = getFullPath(root.schema.id);
  956.   if (refPath !== baseId) {
  957.     var id = normalizeId(refPath);
  958.     var refVal = this._refs[id];
  959.     if (typeof refVal == 'string') {
  960.       return resolveRecursive.call(this, root, refVal, p);
  961.     } else if (refVal instanceof SchemaObject) {
  962.       if (!refVal.validate) this._compile(refVal);
  963.       root = refVal;
  964.     } else {
  965.       refVal = this._schemas[id];
  966.       if (refVal instanceof SchemaObject) {
  967.         if (!refVal.validate) this._compile(refVal);
  968.         if (id == normalizeId(ref))
  969.           return { schema: refVal, root: root, baseId: baseId };
  970.         root = refVal;
  971.       } else {
  972.         return;
  973.       }
  974.     }
  975.     if (!root.schema) return;
  976.     baseId = getFullPath(root.schema.id);
  977.   }
  978.   return getJsonPointer.call(this, p, baseId, root.schema, root);
  979. }
  980.  
  981.  
  982. /* @this Ajv */
  983. function resolveRecursive(root, ref, parsedRef) {
  984.   /* jshint validthis: true */
  985.   var res = resolveSchema.call(this, root, ref);
  986.   if (res) {
  987.     var schema = res.schema;
  988.     var baseId = res.baseId;
  989.     root = res.root;
  990.     if (schema.id) baseId = resolveUrl(baseId, schema.id);
  991.     return getJsonPointer.call(this, parsedRef, baseId, schema, root);
  992.   }
  993. }
  994.  
  995.  
  996. var PREVENT_SCOPE_CHANGE = util.toHash(['properties', 'patternProperties', 'enum', 'dependencies', 'definitions']);
  997. /* @this Ajv */
  998. function getJsonPointer(parsedRef, baseId, schema, root) {
  999.   /* jshint validthis: true */
  1000.   parsedRef.hash = parsedRef.hash || '';
  1001.   if (parsedRef.hash.slice(0,2) != '#/') return;
  1002.   var parts = parsedRef.hash.split('/');
  1003.  
  1004.   for (var i = 1; i < parts.length; i++) {
  1005.     var part = parts[i];
  1006.     if (part) {
  1007.       part = util.unescapeFragment(part);
  1008.       schema = schema[part];
  1009.       if (!schema) break;
  1010.       if (schema.id && !PREVENT_SCOPE_CHANGE[part]) baseId = resolveUrl(baseId, schema.id);
  1011.       if (schema.$ref) {
  1012.         var $ref = resolveUrl(baseId, schema.$ref);
  1013.         var res = resolveSchema.call(this, root, $ref);
  1014.         if (res) {
  1015.           schema = res.schema;
  1016.           root = res.root;
  1017.           baseId = res.baseId;
  1018.         }
  1019.       }
  1020.     }
  1021.   }
  1022.   if (schema && schema != root.schema)
  1023.     return { schema: schema, root: root, baseId: baseId };
  1024. }
  1025.  
  1026.  
  1027. var SIMPLE_INLINED = util.toHash([
  1028.   'type', 'format', 'pattern',
  1029.   'maxLength', 'minLength',
  1030.   'maxProperties', 'minProperties',
  1031.   'maxItems', 'minItems',
  1032.   'maximum', 'minimum',
  1033.   'uniqueItems', 'multipleOf',
  1034.   'required', 'enum'
  1035. ]);
  1036. function inlineRef(schema, limit) {
  1037.   if (limit === false) return false;
  1038.   if (limit === undefined || limit === true) return checkNoRef(schema);
  1039.   else if (limit) return countKeys(schema) <= limit;
  1040. }
  1041.  
  1042.  
  1043. function checkNoRef(schema) {
  1044.   var item;
  1045.   if (Array.isArray(schema)) {
  1046.     for (var i=0; i<schema.length; i++) {
  1047.       item = schema[i];
  1048.       if (typeof item == 'object' && !checkNoRef(item)) return false;
  1049.     }
  1050.   } else {
  1051.     for (var key in schema) {
  1052.       if (key == '$ref') return false;
  1053.       item = schema[key];
  1054.       if (typeof item == 'object' && !checkNoRef(item)) return false;
  1055.     }
  1056.   }
  1057.   return true;
  1058. }
  1059.  
  1060.  
  1061. function countKeys(schema) {
  1062.   var count = 0, item;
  1063.   if (Array.isArray(schema)) {
  1064.     for (var i=0; i<schema.length; i++) {
  1065.       item = schema[i];
  1066.       if (typeof item == 'object') count += countKeys(item);
  1067.       if (count == Infinity) return Infinity;
  1068.     }
  1069.   } else {
  1070.     for (var key in schema) {
  1071.       if (key == '$ref') return Infinity;
  1072.       if (SIMPLE_INLINED[key]) {
  1073.         count++;
  1074.       } else {
  1075.         item = schema[key];
  1076.         if (typeof item == 'object') count += countKeys(item) + 1;
  1077.         if (count == Infinity) return Infinity;
  1078.       }
  1079.     }
  1080.   }
  1081.   return count;
  1082. }
  1083.  
  1084.  
  1085. function getFullPath(id, normalize) {
  1086.   if (normalize !== false) id = normalizeId(id);
  1087.   var p = url.parse(id, false, true);
  1088.   return _getFullPath(p);
  1089. }
  1090.  
  1091.  
  1092. function _getFullPath(p) {
  1093.   var protocolSeparator = p.protocol || p.href.slice(0,2) == '//' ? '//' : '';
  1094.   return (p.protocol||'') + protocolSeparator + (p.host||'') + (p.path||'')  + '#';
  1095. }
  1096.  
  1097.  
  1098. var TRAILING_SLASH_HASH = /#\/?$/;
  1099. function normalizeId(id) {
  1100.   return id ? id.replace(TRAILING_SLASH_HASH, '') : '';
  1101. }
  1102.  
  1103.  
  1104. function resolveUrl(baseId, id) {
  1105.   id = normalizeId(id);
  1106.   return url.resolve(baseId, id);
  1107. }
  1108.  
  1109.  
  1110. /* @this Ajv */
  1111. function resolveIds(schema) {
  1112.   /* eslint no-shadow: 0 */
  1113.   /* jshint validthis: true */
  1114.   var id = normalizeId(schema.id);
  1115.   var localRefs = {};
  1116.   _resolveIds.call(this, schema, getFullPath(id, false), id);
  1117.   return localRefs;
  1118.  
  1119.   /* @this Ajv */
  1120.   function _resolveIds(schema, fullPath, baseId) {
  1121.     /* jshint validthis: true */
  1122.     if (Array.isArray(schema)) {
  1123.       for (var i=0; i<schema.length; i++)
  1124.         _resolveIds.call(this, schema[i], fullPath+'/'+i, baseId);
  1125.     } else if (schema && typeof schema == 'object') {
  1126.       if (typeof schema.id == 'string') {
  1127.         var id = baseId = baseId
  1128.                           ? url.resolve(baseId, schema.id)
  1129.                           : schema.id;
  1130.         id = normalizeId(id);
  1131.  
  1132.         var refVal = this._refs[id];
  1133.         if (typeof refVal == 'string') refVal = this._refs[refVal];
  1134.         if (refVal && refVal.schema) {
  1135.           if (!equal(schema, refVal.schema))
  1136.             throw new Error('id "' + id + '" resolves to more than one schema');
  1137.         } else if (id != normalizeId(fullPath)) {
  1138.           if (id[0] == '#') {
  1139.             if (localRefs[id] && !equal(schema, localRefs[id]))
  1140.               throw new Error('id "' + id + '" resolves to more than one schema');
  1141.             localRefs[id] = schema;
  1142.           } else {
  1143.             this._refs[id] = fullPath;
  1144.           }
  1145.         }
  1146.       }
  1147.       for (var key in schema)
  1148.         _resolveIds.call(this, schema[key], fullPath+'/'+util.escapeFragment(key), baseId);
  1149.     }
  1150.   }
  1151. }
  1152.  
  1153. },{"./equal":4,"./schema_obj":9,"./util":11,"url":45}],8:[function(require,module,exports){
  1154. 'use strict';
  1155.  
  1156. var ruleModules = require('./_rules')
  1157.   , toHash = require('./util').toHash;
  1158.  
  1159. module.exports = function rules() {
  1160.   var RULES = [
  1161.     { type: 'number',
  1162.       rules: [ 'maximum', 'minimum', 'multipleOf'] },
  1163.     { type: 'string',
  1164.       rules: [ 'maxLength', 'minLength', 'pattern', 'format' ] },
  1165.     { type: 'array',
  1166.       rules: [ 'maxItems', 'minItems', 'uniqueItems', 'items' ] },
  1167.     { type: 'object',
  1168.       rules: [ 'maxProperties', 'minProperties', 'required', 'dependencies', 'properties' ] },
  1169.     { rules: [ '$ref', 'enum', 'not', 'anyOf', 'oneOf', 'allOf' ] }
  1170.   ];
  1171.  
  1172.   var ALL = [ 'type', 'additionalProperties', 'patternProperties' ];
  1173.   var KEYWORDS = [ 'additionalItems', '$schema', 'id', 'title', 'description', 'default' ];
  1174.   var TYPES = [ 'number', 'integer', 'string', 'array', 'object', 'boolean', 'null' ];
  1175.   RULES.all = toHash(ALL);
  1176.  
  1177.   RULES.forEach(function (group) {
  1178.     group.rules = group.rules.map(function (keyword) {
  1179.       ALL.push(keyword);
  1180.       var rule = RULES.all[keyword] = {
  1181.         keyword: keyword,
  1182.         code: ruleModules[keyword]
  1183.       };
  1184.       return rule;
  1185.     });
  1186.   });
  1187.  
  1188.   RULES.keywords = toHash(ALL.concat(KEYWORDS));
  1189.   RULES.types = toHash(TYPES);
  1190.   RULES.custom = {};
  1191.  
  1192.   return RULES;
  1193. };
  1194.  
  1195. },{"./_rules":3,"./util":11}],9:[function(require,module,exports){
  1196. 'use strict';
  1197.  
  1198. var util = require('./util');
  1199.  
  1200. module.exports = SchemaObject;
  1201.  
  1202. function SchemaObject(obj) {
  1203.   util.copy(obj, this);
  1204. }
  1205.  
  1206. },{"./util":11}],10:[function(require,module,exports){
  1207. 'use strict';
  1208.  
  1209. // https://mathiasbynens.be/notes/javascript-encoding
  1210. // https://github.com/bestiejs/punycode.js - punycode.ucs2.decode
  1211. module.exports = function ucs2length(str) {
  1212.   var length = 0
  1213.     , len = str.length
  1214.     , pos = 0
  1215.     , value;
  1216.   while (pos < len) {
  1217.     length++;
  1218.     value = str.charCodeAt(pos++);
  1219.     if (value >= 0xD800 && value <= 0xDBFF && pos < len) {
  1220.       // high surrogate, and there is a next character
  1221.       value = str.charCodeAt(pos);
  1222.       if ((value & 0xFC00) == 0xDC00) pos++; // low surrogate
  1223.     }
  1224.   }
  1225.   return length;
  1226. };
  1227.  
  1228. },{}],11:[function(require,module,exports){
  1229. 'use strict';
  1230.  
  1231.  
  1232. module.exports = {
  1233.   copy: copy,
  1234.   checkDataType: checkDataType,
  1235.   checkDataTypes: checkDataTypes,
  1236.   coerceToTypes: coerceToTypes,
  1237.   toHash: toHash,
  1238.   getProperty: getProperty,
  1239.   escapeQuotes: escapeQuotes,
  1240.   ucs2length: require('./ucs2length'),
  1241.   varOccurences: varOccurences,
  1242.   varReplace: varReplace,
  1243.   cleanUpCode: cleanUpCode,
  1244.   cleanUpVarErrors: cleanUpVarErrors,
  1245.   schemaHasRules: schemaHasRules,
  1246.   schemaHasRulesExcept: schemaHasRulesExcept,
  1247.   stableStringify: require('json-stable-stringify'),
  1248.   toQuotedString: toQuotedString,
  1249.   getPathExpr: getPathExpr,
  1250.   getPath: getPath,
  1251.   getData: getData,
  1252.   unescapeFragment: unescapeFragment,
  1253.   escapeFragment: escapeFragment,
  1254.   escapeJsonPointer: escapeJsonPointer
  1255. };
  1256.  
  1257.  
  1258. function copy(o, to) {
  1259.   to = to || {};
  1260.   for (var key in o) to[key] = o[key];
  1261.   return to;
  1262. }
  1263.  
  1264.  
  1265. function checkDataType(dataType, data, negate) {
  1266.   var EQUAL = negate ? ' !== ' : ' === '
  1267.     , AND = negate ? ' || ' : ' && '
  1268.     , OK = negate ? '!' : ''
  1269.     , NOT = negate ? '' : '!';
  1270.   switch (dataType) {
  1271.     case 'null': return data + EQUAL + 'null';
  1272.     case 'array': return OK + 'Array.isArray(' + data + ')';
  1273.     case 'object': return '(' + OK + data + AND +
  1274.                           'typeof ' + data + EQUAL + '"object"' + AND +
  1275.                           NOT + 'Array.isArray(' + data + '))';
  1276.     case 'integer': return '(typeof ' + data + EQUAL + '"number"' + AND +
  1277.                            NOT + '(' + data + ' % 1)' +
  1278.                            AND + data + EQUAL + data + ')';
  1279.     default: return 'typeof ' + data + EQUAL + '"' + dataType + '"';
  1280.   }
  1281. }
  1282.  
  1283.  
  1284. function checkDataTypes(dataTypes, data) {
  1285.   switch (dataTypes.length) {
  1286.     case 1: return checkDataType(dataTypes[0], data, true);
  1287.     default:
  1288.       var code = '';
  1289.       var types = toHash(dataTypes);
  1290.       if (types.array && types.object) {
  1291.         code = types.null ? '(': '(!' + data + ' || ';
  1292.         code += 'typeof ' + data + ' !== "object")';
  1293.         delete types.null;
  1294.         delete types.array;
  1295.         delete types.object;
  1296.       }
  1297.       if (types.number) delete types.integer;
  1298.       for (var t in types)
  1299.         code += (code ? ' && ' : '' ) + checkDataType(t, data, true);
  1300.  
  1301.       return code;
  1302.   }
  1303. }
  1304.  
  1305.  
  1306. var COERCE_TO_TYPES = toHash([ 'string', 'number', 'integer', 'boolean', 'null' ]);
  1307. function coerceToTypes(optionCoerceTypes, dataTypes) {
  1308.   if (Array.isArray(dataTypes)) {
  1309.     var types = [];
  1310.     for (var i=0; i<dataTypes.length; i++) {
  1311.       var t = dataTypes[i];
  1312.       if (COERCE_TO_TYPES[t]) types[types.length] = t;
  1313.       else if (optionCoerceTypes === 'array' && t === 'array') types[types.length] = t;
  1314.     }
  1315.     if (types.length) return types;
  1316.   } else if (COERCE_TO_TYPES[dataTypes]) {
  1317.     return [dataTypes];
  1318.   } else if (optionCoerceTypes === 'array' && dataTypes === 'array') {
  1319.     return ['array'];
  1320.   }
  1321. }
  1322.  
  1323.  
  1324. function toHash(arr) {
  1325.   var hash = {};
  1326.   for (var i=0; i<arr.length; i++) hash[arr[i]] = true;
  1327.   return hash;
  1328. }
  1329.  
  1330.  
  1331. var IDENTIFIER = /^[a-z$_][a-z$_0-9]*$/i;
  1332. var SINGLE_QUOTE = /'|\\/g;
  1333. function getProperty(key) {
  1334.   return typeof key == 'number'
  1335.           ? '[' + key + ']'
  1336.           : IDENTIFIER.test(key)
  1337.             ? '.' + key
  1338.             : "['" + escapeQuotes(key) + "']";
  1339. }
  1340.  
  1341.  
  1342. function escapeQuotes(str) {
  1343.   return str.replace(SINGLE_QUOTE, '\\$&')
  1344.             .replace(/\n/g, '\\n')
  1345.             .replace(/\r/g, '\\r')
  1346.             .replace(/\f/g, '\\f')
  1347.             .replace(/\t/g, '\\t');
  1348. }
  1349.  
  1350.  
  1351. function varOccurences(str, dataVar) {
  1352.   dataVar += '[^0-9]';
  1353.   var matches = str.match(new RegExp(dataVar, 'g'));
  1354.   return matches ? matches.length : 0;
  1355. }
  1356.  
  1357.  
  1358. function varReplace(str, dataVar, expr) {
  1359.   dataVar += '([^0-9])';
  1360.   expr = expr.replace(/\$/g, '$$$$');
  1361.   return str.replace(new RegExp(dataVar, 'g'), expr + '$1');
  1362. }
  1363.  
  1364.  
  1365. var EMPTY_ELSE = /else\s*{\s*}/g
  1366.   , EMPTY_IF_NO_ELSE = /if\s*\([^)]+\)\s*\{\s*\}(?!\s*else)/g
  1367.   , EMPTY_IF_WITH_ELSE = /if\s*\(([^)]+)\)\s*\{\s*\}\s*else(?!\s*if)/g;
  1368. function cleanUpCode(out) {
  1369.   return out.replace(EMPTY_ELSE, '')
  1370.             .replace(EMPTY_IF_NO_ELSE, '')
  1371.             .replace(EMPTY_IF_WITH_ELSE, 'if (!($1))');
  1372. }
  1373.  
  1374.  
  1375. var ERRORS_REGEXP = /[^v\.]errors/g
  1376.   , REMOVE_ERRORS = /var errors = 0;|var vErrors = null;|validate.errors = vErrors;/g
  1377.   , REMOVE_ERRORS_ASYNC = /var errors = 0;|var vErrors = null;/g
  1378.   , RETURN_VALID = 'return errors === 0;'
  1379.   , RETURN_TRUE = 'validate.errors = null; return true;'
  1380.   , RETURN_ASYNC = /if \(errors === 0\) return true;\s*else throw new ValidationError\(vErrors\);/
  1381.   , RETURN_TRUE_ASYNC = 'return true;';
  1382.  
  1383. function cleanUpVarErrors(out, async) {
  1384.   var matches = out.match(ERRORS_REGEXP);
  1385.   if (!matches || matches.length !== 2) return out;
  1386.   return async
  1387.           ? out.replace(REMOVE_ERRORS_ASYNC, '')
  1388.                .replace(RETURN_ASYNC, RETURN_TRUE_ASYNC)
  1389.           : out.replace(REMOVE_ERRORS, '')
  1390.                .replace(RETURN_VALID, RETURN_TRUE);
  1391. }
  1392.  
  1393.  
  1394. function schemaHasRules(schema, rules) {
  1395.   for (var key in schema) if (rules[key]) return true;
  1396. }
  1397.  
  1398.  
  1399. function schemaHasRulesExcept(schema, rules, exceptKeyword) {
  1400.   for (var key in schema) if (key != exceptKeyword && rules[key]) return true;
  1401. }
  1402.  
  1403.  
  1404. function toQuotedString(str) {
  1405.   return '\'' + escapeQuotes(str) + '\'';
  1406. }
  1407.  
  1408.  
  1409. function getPathExpr(currentPath, expr, jsonPointers, isNumber) {
  1410.   var path = jsonPointers // false by default
  1411.               ? '\'/\' + ' + expr + (isNumber ? '' : '.replace(/~/g, \'~0\').replace(/\\//g, \'~1\')')
  1412.               : (isNumber ? '\'[\' + ' + expr + ' + \']\'' : '\'[\\\'\' + ' + expr + ' + \'\\\']\'');
  1413.   return joinPaths(currentPath, path);
  1414. }
  1415.  
  1416.  
  1417. function getPath(currentPath, prop, jsonPointers) {
  1418.   var path = jsonPointers // false by default
  1419.               ? toQuotedString('/' + escapeJsonPointer(prop))
  1420.               : toQuotedString(getProperty(prop));
  1421.   return joinPaths(currentPath, path);
  1422. }
  1423.  
  1424.  
  1425. var JSON_POINTER = /^\/(?:[^~]|~0|~1)*$/;
  1426. var RELATIVE_JSON_POINTER = /^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;
  1427. function getData($data, lvl, paths) {
  1428.   var up, jsonPointer, data, matches;
  1429.   if ($data === '') return 'rootData';
  1430.   if ($data[0] == '/') {
  1431.     if (!JSON_POINTER.test($data)) throw new Error('Invalid JSON-pointer: ' + $data);
  1432.     jsonPointer = $data;
  1433.     data = 'rootData';
  1434.   } else {
  1435.     matches = $data.match(RELATIVE_JSON_POINTER);
  1436.     if (!matches) throw new Error('Invalid JSON-pointer: ' + $data);
  1437.     up = +matches[1];
  1438.     jsonPointer = matches[2];
  1439.     if (jsonPointer == '#') {
  1440.       if (up >= lvl) throw new Error('Cannot access property/index ' + up + ' levels up, current level is ' + lvl);
  1441.       return paths[lvl - up];
  1442.     }
  1443.  
  1444.     if (up > lvl) throw new Error('Cannot access data ' + up + ' levels up, current level is ' + lvl);
  1445.     data = 'data' + ((lvl - up) || '');
  1446.     if (!jsonPointer) return data;
  1447.   }
  1448.  
  1449.   var expr = data;
  1450.   var segments = jsonPointer.split('/');
  1451.   for (var i=0; i<segments.length; i++) {
  1452.     var segment = segments[i];
  1453.     if (segment) {
  1454.       data += getProperty(unescapeJsonPointer(segment));
  1455.       expr += ' && ' + data;
  1456.     }
  1457.   }
  1458.   return expr;
  1459. }
  1460.  
  1461.  
  1462. function joinPaths (a, b) {
  1463.   if (a == '""') return b;
  1464.   return (a + ' + ' + b).replace(/' \+ '/g, '');
  1465. }
  1466.  
  1467.  
  1468. function unescapeFragment(str) {
  1469.   return unescapeJsonPointer(decodeURIComponent(str));
  1470. }
  1471.  
  1472.  
  1473. function escapeFragment(str) {
  1474.   return encodeURIComponent(escapeJsonPointer(str));
  1475. }
  1476.  
  1477.  
  1478. function escapeJsonPointer(str) {
  1479.   return str.replace(/~/g, '~0').replace(/\//g, '~1');
  1480. }
  1481.  
  1482.  
  1483. function unescapeJsonPointer(str) {
  1484.   return str.replace(/~1/g, '/').replace(/~0/g, '~');
  1485. }
  1486.  
  1487. },{"./ucs2length":10,"json-stable-stringify":48}],12:[function(require,module,exports){
  1488. 'use strict';
  1489.  
  1490. module.exports = ValidationError;
  1491.  
  1492.  
  1493. function ValidationError(errors) {
  1494.   this.message = 'validation failed';
  1495.   this.errors = errors;
  1496.   this.ajv = this.validation = true;
  1497. }
  1498.  
  1499.  
  1500. ValidationError.prototype = Object.create(Error.prototype);
  1501. ValidationError.prototype.constructor = ValidationError;
  1502.  
  1503. },{}],13:[function(require,module,exports){
  1504. 'use strict';
  1505. module.exports = function generate__formatLimit(it, $keyword) {
  1506.   var out = ' ';
  1507.   var $lvl = it.level;
  1508.   var $dataLvl = it.dataLevel;
  1509.   var $schema = it.schema[$keyword];
  1510.   var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
  1511.   var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
  1512.   var $breakOnError = !it.opts.allErrors;
  1513.   var $errorKeyword;
  1514.   var $data = 'data' + ($dataLvl || '');
  1515.   var $valid = 'valid' + $lvl;
  1516.   out += 'var ' + ($valid) + ' = undefined;';
  1517.   if (it.opts.format === false) {
  1518.     out += ' ' + ($valid) + ' = true; ';
  1519.     return out;
  1520.   }
  1521.   var $schemaFormat = it.schema.format,
  1522.     $isDataFormat = it.opts.v5 && $schemaFormat.$data,
  1523.     $closingBraces = '';
  1524.   if ($isDataFormat) {
  1525.     var $schemaValueFormat = it.util.getData($schemaFormat.$data, $dataLvl, it.dataPathArr),
  1526.       $format = 'format' + $lvl,
  1527.       $compare = 'compare' + $lvl;
  1528.     out += ' var ' + ($format) + ' = formats[' + ($schemaValueFormat) + '] , ' + ($compare) + ' = ' + ($format) + ' && ' + ($format) + '.compare;';
  1529.   } else {
  1530.     var $format = it.formats[$schemaFormat];
  1531.     if (!($format && $format.compare)) {
  1532.       out += '  ' + ($valid) + ' = true; ';
  1533.       return out;
  1534.     }
  1535.     var $compare = 'formats' + it.util.getProperty($schemaFormat) + '.compare';
  1536.   }
  1537.   var $isMax = $keyword == 'formatMaximum',
  1538.     $exclusiveKeyword = 'formatExclusive' + ($isMax ? 'Maximum' : 'Minimum'),
  1539.     $schemaExcl = it.schema[$exclusiveKeyword],
  1540.     $isDataExcl = it.opts.v5 && $schemaExcl && $schemaExcl.$data,
  1541.     $op = $isMax ? '<' : '>',
  1542.     $result = 'result' + $lvl;
  1543.   var $isData = it.opts.v5 && $schema && $schema.$data,
  1544.     $schemaValue;
  1545.   if ($isData) {
  1546.     out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; ';
  1547.     $schemaValue = 'schema' + $lvl;
  1548.   } else {
  1549.     $schemaValue = $schema;
  1550.   }
  1551.   if ($isDataExcl) {
  1552.     var $schemaValueExcl = it.util.getData($schemaExcl.$data, $dataLvl, it.dataPathArr),
  1553.       $exclusive = 'exclusive' + $lvl,
  1554.       $opExpr = 'op' + $lvl,
  1555.       $opStr = '\' + ' + $opExpr + ' + \'';
  1556.     out += ' var schemaExcl' + ($lvl) + ' = ' + ($schemaValueExcl) + '; ';
  1557.     $schemaValueExcl = 'schemaExcl' + $lvl;
  1558.     out += ' if (typeof ' + ($schemaValueExcl) + ' != \'boolean\' && ' + ($schemaValueExcl) + ' !== undefined) { ' + ($valid) + ' = false; ';
  1559.     var $errorKeyword = $exclusiveKeyword;
  1560.     var $$outStack = $$outStack || [];
  1561.     $$outStack.push(out);
  1562.     out = ''; /* istanbul ignore else */
  1563.     if (it.createErrors !== false) {
  1564.       out += ' { keyword: \'' + ($errorKeyword || '_formatExclusiveLimit') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: {} ';
  1565.       if (it.opts.messages !== false) {
  1566.         out += ' , message: \'' + ($exclusiveKeyword) + ' should be boolean\' ';
  1567.       }
  1568.       if (it.opts.verbose) {
  1569.         out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
  1570.       }
  1571.       out += ' } ';
  1572.     } else {
  1573.       out += ' {} ';
  1574.     }
  1575.     var __err = out;
  1576.     out = $$outStack.pop();
  1577.     if (!it.compositeRule && $breakOnError) { /* istanbul ignore if */
  1578.       if (it.async) {
  1579.         out += ' throw new ValidationError([' + (__err) + ']); ';
  1580.       } else {
  1581.         out += ' validate.errors = [' + (__err) + ']; return false; ';
  1582.       }
  1583.     } else {
  1584.       out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  1585.     }
  1586.     out += ' }  ';
  1587.     if ($breakOnError) {
  1588.       $closingBraces += '}';
  1589.       out += ' else { ';
  1590.     }
  1591.     if ($isData) {
  1592.       out += ' if (' + ($schemaValue) + ' === undefined) ' + ($valid) + ' = true; else if (typeof ' + ($schemaValue) + ' != \'string\') ' + ($valid) + ' = false; else { ';
  1593.       $closingBraces += '}';
  1594.     }
  1595.     if ($isDataFormat) {
  1596.       out += ' if (!' + ($compare) + ') ' + ($valid) + ' = true; else { ';
  1597.       $closingBraces += '}';
  1598.     }
  1599.     out += ' var ' + ($result) + ' = ' + ($compare) + '(' + ($data) + ',  ';
  1600.     if ($isData) {
  1601.       out += '' + ($schemaValue);
  1602.     } else {
  1603.       out += '' + (it.util.toQuotedString($schema));
  1604.     }
  1605.     out += ' ); if (' + ($result) + ' === undefined) ' + ($valid) + ' = false; var ' + ($exclusive) + ' = ' + ($schemaValueExcl) + ' === true; if (' + ($valid) + ' === undefined) { ' + ($valid) + ' = ' + ($exclusive) + ' ? ' + ($result) + ' ' + ($op) + ' 0 : ' + ($result) + ' ' + ($op) + '= 0; } if (!' + ($valid) + ') var op' + ($lvl) + ' = ' + ($exclusive) + ' ? \'' + ($op) + '\' : \'' + ($op) + '=\';';
  1606.   } else {
  1607.     var $exclusive = $schemaExcl === true,
  1608.       $opStr = $op;
  1609.     if (!$exclusive) $opStr += '=';
  1610.     var $opExpr = '\'' + $opStr + '\'';
  1611.     if ($isData) {
  1612.       out += ' if (' + ($schemaValue) + ' === undefined) ' + ($valid) + ' = true; else if (typeof ' + ($schemaValue) + ' != \'string\') ' + ($valid) + ' = false; else { ';
  1613.       $closingBraces += '}';
  1614.     }
  1615.     if ($isDataFormat) {
  1616.       out += ' if (!' + ($compare) + ') ' + ($valid) + ' = true; else { ';
  1617.       $closingBraces += '}';
  1618.     }
  1619.     out += ' var ' + ($result) + ' = ' + ($compare) + '(' + ($data) + ',  ';
  1620.     if ($isData) {
  1621.       out += '' + ($schemaValue);
  1622.     } else {
  1623.       out += '' + (it.util.toQuotedString($schema));
  1624.     }
  1625.     out += ' ); if (' + ($result) + ' === undefined) ' + ($valid) + ' = false; if (' + ($valid) + ' === undefined) ' + ($valid) + ' = ' + ($result) + ' ' + ($op);
  1626.     if (!$exclusive) {
  1627.       out += '=';
  1628.     }
  1629.     out += ' 0;';
  1630.   }
  1631.   out += '' + ($closingBraces) + 'if (!' + ($valid) + ') { ';
  1632.   var $errorKeyword = $keyword;
  1633.   var $$outStack = $$outStack || [];
  1634.   $$outStack.push(out);
  1635.   out = ''; /* istanbul ignore else */
  1636.   if (it.createErrors !== false) {
  1637.     out += ' { keyword: \'' + ($errorKeyword || '_formatLimit') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { comparison: ' + ($opExpr) + ', limit:  ';
  1638.     if ($isData) {
  1639.       out += '' + ($schemaValue);
  1640.     } else {
  1641.       out += '' + (it.util.toQuotedString($schema));
  1642.     }
  1643.     out += ' , exclusive: ' + ($exclusive) + ' } ';
  1644.     if (it.opts.messages !== false) {
  1645.       out += ' , message: \'should be ' + ($opStr) + ' "';
  1646.       if ($isData) {
  1647.         out += '\' + ' + ($schemaValue) + ' + \'';
  1648.       } else {
  1649.         out += '' + (it.util.escapeQuotes($schema));
  1650.       }
  1651.       out += '"\' ';
  1652.     }
  1653.     if (it.opts.verbose) {
  1654.       out += ' , schema:  ';
  1655.       if ($isData) {
  1656.         out += 'validate.schema' + ($schemaPath);
  1657.       } else {
  1658.         out += '' + (it.util.toQuotedString($schema));
  1659.       }
  1660.       out += '         , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
  1661.     }
  1662.     out += ' } ';
  1663.   } else {
  1664.     out += ' {} ';
  1665.   }
  1666.   var __err = out;
  1667.   out = $$outStack.pop();
  1668.   if (!it.compositeRule && $breakOnError) { /* istanbul ignore if */
  1669.     if (it.async) {
  1670.       out += ' throw new ValidationError([' + (__err) + ']); ';
  1671.     } else {
  1672.       out += ' validate.errors = [' + (__err) + ']; return false; ';
  1673.     }
  1674.   } else {
  1675.     out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  1676.   }
  1677.   out += '}';
  1678.   return out;
  1679. }
  1680.  
  1681. },{}],14:[function(require,module,exports){
  1682. 'use strict';
  1683. module.exports = function generate__limit(it, $keyword) {
  1684.   var out = ' ';
  1685.   var $lvl = it.level;
  1686.   var $dataLvl = it.dataLevel;
  1687.   var $schema = it.schema[$keyword];
  1688.   var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
  1689.   var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
  1690.   var $breakOnError = !it.opts.allErrors;
  1691.   var $errorKeyword;
  1692.   var $data = 'data' + ($dataLvl || '');
  1693.   var $isData = it.opts.v5 && $schema && $schema.$data,
  1694.     $schemaValue;
  1695.   if ($isData) {
  1696.     out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; ';
  1697.     $schemaValue = 'schema' + $lvl;
  1698.   } else {
  1699.     $schemaValue = $schema;
  1700.   }
  1701.   var $isMax = $keyword == 'maximum',
  1702.     $exclusiveKeyword = $isMax ? 'exclusiveMaximum' : 'exclusiveMinimum',
  1703.     $schemaExcl = it.schema[$exclusiveKeyword],
  1704.     $isDataExcl = it.opts.v5 && $schemaExcl && $schemaExcl.$data,
  1705.     $op = $isMax ? '<' : '>',
  1706.     $notOp = $isMax ? '>' : '<';
  1707.   if ($isDataExcl) {
  1708.     var $schemaValueExcl = it.util.getData($schemaExcl.$data, $dataLvl, it.dataPathArr),
  1709.       $exclusive = 'exclusive' + $lvl,
  1710.       $opExpr = 'op' + $lvl,
  1711.       $opStr = '\' + ' + $opExpr + ' + \'';
  1712.     out += ' var schemaExcl' + ($lvl) + ' = ' + ($schemaValueExcl) + '; ';
  1713.     $schemaValueExcl = 'schemaExcl' + $lvl;
  1714.     out += ' var exclusive' + ($lvl) + '; if (typeof ' + ($schemaValueExcl) + ' != \'boolean\' && typeof ' + ($schemaValueExcl) + ' != \'undefined\') { ';
  1715.     var $errorKeyword = $exclusiveKeyword;
  1716.     var $$outStack = $$outStack || [];
  1717.     $$outStack.push(out);
  1718.     out = ''; /* istanbul ignore else */
  1719.     if (it.createErrors !== false) {
  1720.       out += ' { keyword: \'' + ($errorKeyword || '_exclusiveLimit') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: {} ';
  1721.       if (it.opts.messages !== false) {
  1722.         out += ' , message: \'' + ($exclusiveKeyword) + ' should be boolean\' ';
  1723.       }
  1724.       if (it.opts.verbose) {
  1725.         out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
  1726.       }
  1727.       out += ' } ';
  1728.     } else {
  1729.       out += ' {} ';
  1730.     }
  1731.     var __err = out;
  1732.     out = $$outStack.pop();
  1733.     if (!it.compositeRule && $breakOnError) { /* istanbul ignore if */
  1734.       if (it.async) {
  1735.         out += ' throw new ValidationError([' + (__err) + ']); ';
  1736.       } else {
  1737.         out += ' validate.errors = [' + (__err) + ']; return false; ';
  1738.       }
  1739.     } else {
  1740.       out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  1741.     }
  1742.     out += ' } else if( ';
  1743.     if ($isData) {
  1744.       out += ' (' + ($schemaValue) + ' !== undefined && typeof ' + ($schemaValue) + ' != \'number\') || ';
  1745.     }
  1746.     out += ' ((exclusive' + ($lvl) + ' = ' + ($schemaValueExcl) + ' === true) ? ' + ($data) + ' ' + ($notOp) + '= ' + ($schemaValue) + ' : ' + ($data) + ' ' + ($notOp) + ' ' + ($schemaValue) + ') || ' + ($data) + ' !== ' + ($data) + ') { var op' + ($lvl) + ' = exclusive' + ($lvl) + ' ? \'' + ($op) + '\' : \'' + ($op) + '=\';';
  1747.   } else {
  1748.     var $exclusive = $schemaExcl === true,
  1749.       $opStr = $op;
  1750.     if (!$exclusive) $opStr += '=';
  1751.     var $opExpr = '\'' + $opStr + '\'';
  1752.     out += ' if ( ';
  1753.     if ($isData) {
  1754.       out += ' (' + ($schemaValue) + ' !== undefined && typeof ' + ($schemaValue) + ' != \'number\') || ';
  1755.     }
  1756.     out += ' ' + ($data) + ' ' + ($notOp);
  1757.     if ($exclusive) {
  1758.       out += '=';
  1759.     }
  1760.     out += ' ' + ($schemaValue) + ' || ' + ($data) + ' !== ' + ($data) + ') {';
  1761.   }
  1762.   var $errorKeyword = $keyword;
  1763.   var $$outStack = $$outStack || [];
  1764.   $$outStack.push(out);
  1765.   out = ''; /* istanbul ignore else */
  1766.   if (it.createErrors !== false) {
  1767.     out += ' { keyword: \'' + ($errorKeyword || '_limit') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { comparison: ' + ($opExpr) + ', limit: ' + ($schemaValue) + ', exclusive: ' + ($exclusive) + ' } ';
  1768.     if (it.opts.messages !== false) {
  1769.       out += ' , message: \'should be ' + ($opStr) + ' ';
  1770.       if ($isData) {
  1771.         out += '\' + ' + ($schemaValue);
  1772.       } else {
  1773.         out += '' + ($schema) + '\'';
  1774.       }
  1775.     }
  1776.     if (it.opts.verbose) {
  1777.       out += ' , schema:  ';
  1778.       if ($isData) {
  1779.         out += 'validate.schema' + ($schemaPath);
  1780.       } else {
  1781.         out += '' + ($schema);
  1782.       }
  1783.       out += '         , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
  1784.     }
  1785.     out += ' } ';
  1786.   } else {
  1787.     out += ' {} ';
  1788.   }
  1789.   var __err = out;
  1790.   out = $$outStack.pop();
  1791.   if (!it.compositeRule && $breakOnError) { /* istanbul ignore if */
  1792.     if (it.async) {
  1793.       out += ' throw new ValidationError([' + (__err) + ']); ';
  1794.     } else {
  1795.       out += ' validate.errors = [' + (__err) + ']; return false; ';
  1796.     }
  1797.   } else {
  1798.     out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  1799.   }
  1800.   out += ' } ';
  1801.   if ($breakOnError) {
  1802.     out += ' else { ';
  1803.   }
  1804.   return out;
  1805. }
  1806.  
  1807. },{}],15:[function(require,module,exports){
  1808. 'use strict';
  1809. module.exports = function generate__limitItems(it, $keyword) {
  1810.   var out = ' ';
  1811.   var $lvl = it.level;
  1812.   var $dataLvl = it.dataLevel;
  1813.   var $schema = it.schema[$keyword];
  1814.   var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
  1815.   var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
  1816.   var $breakOnError = !it.opts.allErrors;
  1817.   var $errorKeyword;
  1818.   var $data = 'data' + ($dataLvl || '');
  1819.   var $isData = it.opts.v5 && $schema && $schema.$data,
  1820.     $schemaValue;
  1821.   if ($isData) {
  1822.     out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; ';
  1823.     $schemaValue = 'schema' + $lvl;
  1824.   } else {
  1825.     $schemaValue = $schema;
  1826.   }
  1827.   var $op = $keyword == 'maxItems' ? '>' : '<';
  1828.   out += 'if ( ';
  1829.   if ($isData) {
  1830.     out += ' (' + ($schemaValue) + ' !== undefined && typeof ' + ($schemaValue) + ' != \'number\') || ';
  1831.   }
  1832.   out += ' ' + ($data) + '.length ' + ($op) + ' ' + ($schemaValue) + ') { ';
  1833.   var $errorKeyword = $keyword;
  1834.   var $$outStack = $$outStack || [];
  1835.   $$outStack.push(out);
  1836.   out = ''; /* istanbul ignore else */
  1837.   if (it.createErrors !== false) {
  1838.     out += ' { keyword: \'' + ($errorKeyword || '_limitItems') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { limit: ' + ($schemaValue) + ' } ';
  1839.     if (it.opts.messages !== false) {
  1840.       out += ' , message: \'should NOT have ';
  1841.       if ($keyword == 'maxItems') {
  1842.         out += 'more';
  1843.       } else {
  1844.         out += 'less';
  1845.       }
  1846.       out += ' than ';
  1847.       if ($isData) {
  1848.         out += '\' + ' + ($schemaValue) + ' + \'';
  1849.       } else {
  1850.         out += '' + ($schema);
  1851.       }
  1852.       out += ' items\' ';
  1853.     }
  1854.     if (it.opts.verbose) {
  1855.       out += ' , schema:  ';
  1856.       if ($isData) {
  1857.         out += 'validate.schema' + ($schemaPath);
  1858.       } else {
  1859.         out += '' + ($schema);
  1860.       }
  1861.       out += '         , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
  1862.     }
  1863.     out += ' } ';
  1864.   } else {
  1865.     out += ' {} ';
  1866.   }
  1867.   var __err = out;
  1868.   out = $$outStack.pop();
  1869.   if (!it.compositeRule && $breakOnError) { /* istanbul ignore if */
  1870.     if (it.async) {
  1871.       out += ' throw new ValidationError([' + (__err) + ']); ';
  1872.     } else {
  1873.       out += ' validate.errors = [' + (__err) + ']; return false; ';
  1874.     }
  1875.   } else {
  1876.     out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  1877.   }
  1878.   out += '} ';
  1879.   if ($breakOnError) {
  1880.     out += ' else { ';
  1881.   }
  1882.   return out;
  1883. }
  1884.  
  1885. },{}],16:[function(require,module,exports){
  1886. 'use strict';
  1887. module.exports = function generate__limitLength(it, $keyword) {
  1888.   var out = ' ';
  1889.   var $lvl = it.level;
  1890.   var $dataLvl = it.dataLevel;
  1891.   var $schema = it.schema[$keyword];
  1892.   var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
  1893.   var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
  1894.   var $breakOnError = !it.opts.allErrors;
  1895.   var $errorKeyword;
  1896.   var $data = 'data' + ($dataLvl || '');
  1897.   var $isData = it.opts.v5 && $schema && $schema.$data,
  1898.     $schemaValue;
  1899.   if ($isData) {
  1900.     out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; ';
  1901.     $schemaValue = 'schema' + $lvl;
  1902.   } else {
  1903.     $schemaValue = $schema;
  1904.   }
  1905.   var $op = $keyword == 'maxLength' ? '>' : '<';
  1906.   out += 'if ( ';
  1907.   if ($isData) {
  1908.     out += ' (' + ($schemaValue) + ' !== undefined && typeof ' + ($schemaValue) + ' != \'number\') || ';
  1909.   }
  1910.   if (it.opts.unicode === false) {
  1911.     out += ' ' + ($data) + '.length ';
  1912.   } else {
  1913.     out += ' ucs2length(' + ($data) + ') ';
  1914.   }
  1915.   out += ' ' + ($op) + ' ' + ($schemaValue) + ') { ';
  1916.   var $errorKeyword = $keyword;
  1917.   var $$outStack = $$outStack || [];
  1918.   $$outStack.push(out);
  1919.   out = ''; /* istanbul ignore else */
  1920.   if (it.createErrors !== false) {
  1921.     out += ' { keyword: \'' + ($errorKeyword || '_limitLength') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { limit: ' + ($schemaValue) + ' } ';
  1922.     if (it.opts.messages !== false) {
  1923.       out += ' , message: \'should NOT be ';
  1924.       if ($keyword == 'maxLength') {
  1925.         out += 'longer';
  1926.       } else {
  1927.         out += 'shorter';
  1928.       }
  1929.       out += ' than ';
  1930.       if ($isData) {
  1931.         out += '\' + ' + ($schemaValue) + ' + \'';
  1932.       } else {
  1933.         out += '' + ($schema);
  1934.       }
  1935.       out += ' characters\' ';
  1936.     }
  1937.     if (it.opts.verbose) {
  1938.       out += ' , schema:  ';
  1939.       if ($isData) {
  1940.         out += 'validate.schema' + ($schemaPath);
  1941.       } else {
  1942.         out += '' + ($schema);
  1943.       }
  1944.       out += '         , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
  1945.     }
  1946.     out += ' } ';
  1947.   } else {
  1948.     out += ' {} ';
  1949.   }
  1950.   var __err = out;
  1951.   out = $$outStack.pop();
  1952.   if (!it.compositeRule && $breakOnError) { /* istanbul ignore if */
  1953.     if (it.async) {
  1954.       out += ' throw new ValidationError([' + (__err) + ']); ';
  1955.     } else {
  1956.       out += ' validate.errors = [' + (__err) + ']; return false; ';
  1957.     }
  1958.   } else {
  1959.     out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  1960.   }
  1961.   out += '} ';
  1962.   if ($breakOnError) {
  1963.     out += ' else { ';
  1964.   }
  1965.   return out;
  1966. }
  1967.  
  1968. },{}],17:[function(require,module,exports){
  1969. 'use strict';
  1970. module.exports = function generate__limitProperties(it, $keyword) {
  1971.   var out = ' ';
  1972.   var $lvl = it.level;
  1973.   var $dataLvl = it.dataLevel;
  1974.   var $schema = it.schema[$keyword];
  1975.   var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
  1976.   var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
  1977.   var $breakOnError = !it.opts.allErrors;
  1978.   var $errorKeyword;
  1979.   var $data = 'data' + ($dataLvl || '');
  1980.   var $isData = it.opts.v5 && $schema && $schema.$data,
  1981.     $schemaValue;
  1982.   if ($isData) {
  1983.     out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; ';
  1984.     $schemaValue = 'schema' + $lvl;
  1985.   } else {
  1986.     $schemaValue = $schema;
  1987.   }
  1988.   var $op = $keyword == 'maxProperties' ? '>' : '<';
  1989.   out += 'if ( ';
  1990.   if ($isData) {
  1991.     out += ' (' + ($schemaValue) + ' !== undefined && typeof ' + ($schemaValue) + ' != \'number\') || ';
  1992.   }
  1993.   out += ' Object.keys(' + ($data) + ').length ' + ($op) + ' ' + ($schemaValue) + ') { ';
  1994.   var $errorKeyword = $keyword;
  1995.   var $$outStack = $$outStack || [];
  1996.   $$outStack.push(out);
  1997.   out = ''; /* istanbul ignore else */
  1998.   if (it.createErrors !== false) {
  1999.     out += ' { keyword: \'' + ($errorKeyword || '_limitProperties') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { limit: ' + ($schemaValue) + ' } ';
  2000.     if (it.opts.messages !== false) {
  2001.       out += ' , message: \'should NOT have ';
  2002.       if ($keyword == 'maxProperties') {
  2003.         out += 'more';
  2004.       } else {
  2005.         out += 'less';
  2006.       }
  2007.       out += ' than ';
  2008.       if ($isData) {
  2009.         out += '\' + ' + ($schemaValue) + ' + \'';
  2010.       } else {
  2011.         out += '' + ($schema);
  2012.       }
  2013.       out += ' properties\' ';
  2014.     }
  2015.     if (it.opts.verbose) {
  2016.       out += ' , schema:  ';
  2017.       if ($isData) {
  2018.         out += 'validate.schema' + ($schemaPath);
  2019.       } else {
  2020.         out += '' + ($schema);
  2021.       }
  2022.       out += '         , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
  2023.     }
  2024.     out += ' } ';
  2025.   } else {
  2026.     out += ' {} ';
  2027.   }
  2028.   var __err = out;
  2029.   out = $$outStack.pop();
  2030.   if (!it.compositeRule && $breakOnError) { /* istanbul ignore if */
  2031.     if (it.async) {
  2032.       out += ' throw new ValidationError([' + (__err) + ']); ';
  2033.     } else {
  2034.       out += ' validate.errors = [' + (__err) + ']; return false; ';
  2035.     }
  2036.   } else {
  2037.     out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  2038.   }
  2039.   out += '} ';
  2040.   if ($breakOnError) {
  2041.     out += ' else { ';
  2042.   }
  2043.   return out;
  2044. }
  2045.  
  2046. },{}],18:[function(require,module,exports){
  2047. 'use strict';
  2048. module.exports = function generate_allOf(it, $keyword) {
  2049.   var out = ' ';
  2050.   var $schema = it.schema[$keyword];
  2051.   var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
  2052.   var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
  2053.   var $breakOnError = !it.opts.allErrors;
  2054.   var $it = it.util.copy(it);
  2055.   var $closingBraces = '';
  2056.   $it.level++;
  2057.   var $nextValid = 'valid' + $it.level;
  2058.   var $currentBaseId = $it.baseId,
  2059.     $allSchemasEmpty = true;
  2060.   var arr1 = $schema;
  2061.   if (arr1) {
  2062.     var $sch, $i = -1,
  2063.       l1 = arr1.length - 1;
  2064.     while ($i < l1) {
  2065.       $sch = arr1[$i += 1];
  2066.       if (it.util.schemaHasRules($sch, it.RULES.all)) {
  2067.         $allSchemasEmpty = false;
  2068.         $it.schema = $sch;
  2069.         $it.schemaPath = $schemaPath + '[' + $i + ']';
  2070.         $it.errSchemaPath = $errSchemaPath + '/' + $i;
  2071.         out += '  ' + (it.validate($it)) + ' ';
  2072.         $it.baseId = $currentBaseId;
  2073.         if ($breakOnError) {
  2074.           out += ' if (' + ($nextValid) + ') { ';
  2075.           $closingBraces += '}';
  2076.         }
  2077.       }
  2078.     }
  2079.   }
  2080.   if ($breakOnError) {
  2081.     if ($allSchemasEmpty) {
  2082.       out += ' if (true) { ';
  2083.     } else {
  2084.       out += ' ' + ($closingBraces.slice(0, -1)) + ' ';
  2085.     }
  2086.   }
  2087.   out = it.util.cleanUpCode(out);
  2088.   return out;
  2089. }
  2090.  
  2091. },{}],19:[function(require,module,exports){
  2092. 'use strict';
  2093. module.exports = function generate_anyOf(it, $keyword) {
  2094.   var out = ' ';
  2095.   var $lvl = it.level;
  2096.   var $dataLvl = it.dataLevel;
  2097.   var $schema = it.schema[$keyword];
  2098.   var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
  2099.   var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
  2100.   var $breakOnError = !it.opts.allErrors;
  2101.   var $errorKeyword;
  2102.   var $data = 'data' + ($dataLvl || '');
  2103.   var $valid = 'valid' + $lvl;
  2104.   var $errs = 'errs__' + $lvl;
  2105.   var $it = it.util.copy(it);
  2106.   var $closingBraces = '';
  2107.   $it.level++;
  2108.   var $nextValid = 'valid' + $it.level;
  2109.   var $noEmptySchema = $schema.every(function($sch) {
  2110.     return it.util.schemaHasRules($sch, it.RULES.all);
  2111.   });
  2112.   if ($noEmptySchema) {
  2113.     var $currentBaseId = $it.baseId;
  2114.     out += ' var ' + ($errs) + ' = errors; var ' + ($valid) + ' = false;  ';
  2115.     var $wasComposite = it.compositeRule;
  2116.     it.compositeRule = $it.compositeRule = true;
  2117.     var arr1 = $schema;
  2118.     if (arr1) {
  2119.       var $sch, $i = -1,
  2120.         l1 = arr1.length - 1;
  2121.       while ($i < l1) {
  2122.         $sch = arr1[$i += 1];
  2123.         $it.schema = $sch;
  2124.         $it.schemaPath = $schemaPath + '[' + $i + ']';
  2125.         $it.errSchemaPath = $errSchemaPath + '/' + $i;
  2126.         out += '  ' + (it.validate($it)) + ' ';
  2127.         $it.baseId = $currentBaseId;
  2128.         out += ' ' + ($valid) + ' = ' + ($valid) + ' || ' + ($nextValid) + '; if (!' + ($valid) + ') { ';
  2129.         $closingBraces += '}';
  2130.       }
  2131.     }
  2132.     it.compositeRule = $it.compositeRule = $wasComposite;
  2133.     out += ' ' + ($closingBraces) + ' if (!' + ($valid) + ') {  var err =   '; /* istanbul ignore else */
  2134.     if (it.createErrors !== false) {
  2135.       out += ' { keyword: \'' + ($errorKeyword || 'anyOf') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: {} ';
  2136.       if (it.opts.messages !== false) {
  2137.         out += ' , message: \'should match some schema in anyOf\' ';
  2138.       }
  2139.       if (it.opts.verbose) {
  2140.         out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
  2141.       }
  2142.       out += ' } ';
  2143.     } else {
  2144.       out += ' {} ';
  2145.     }
  2146.     out += ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } else {  errors = ' + ($errs) + '; if (vErrors !== null) { if (' + ($errs) + ') vErrors.length = ' + ($errs) + '; else vErrors = null; } ';
  2147.     if (it.opts.allErrors) {
  2148.       out += ' } ';
  2149.     }
  2150.     out = it.util.cleanUpCode(out);
  2151.   } else {
  2152.     if ($breakOnError) {
  2153.       out += ' if (true) { ';
  2154.     }
  2155.   }
  2156.   return out;
  2157. }
  2158.  
  2159. },{}],20:[function(require,module,exports){
  2160. 'use strict';
  2161. module.exports = function generate_constant(it, $keyword) {
  2162.   var out = ' ';
  2163.   var $lvl = it.level;
  2164.   var $dataLvl = it.dataLevel;
  2165.   var $schema = it.schema[$keyword];
  2166.   var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
  2167.   var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
  2168.   var $breakOnError = !it.opts.allErrors;
  2169.   var $errorKeyword;
  2170.   var $data = 'data' + ($dataLvl || '');
  2171.   var $valid = 'valid' + $lvl;
  2172.   var $isData = it.opts.v5 && $schema && $schema.$data,
  2173.     $schemaValue;
  2174.   if ($isData) {
  2175.     out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; ';
  2176.     $schemaValue = 'schema' + $lvl;
  2177.   } else {
  2178.     $schemaValue = $schema;
  2179.   }
  2180.   if (!$isData) {
  2181.     out += ' var schema' + ($lvl) + ' = validate.schema' + ($schemaPath) + ';';
  2182.   }
  2183.   out += 'var ' + ($valid) + ' = equal(' + ($data) + ', schema' + ($lvl) + '); if (!' + ($valid) + ') {   ';
  2184.   var $$outStack = $$outStack || [];
  2185.   $$outStack.push(out);
  2186.   out = ''; /* istanbul ignore else */
  2187.   if (it.createErrors !== false) {
  2188.     out += ' { keyword: \'' + ($errorKeyword || 'constant') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: {} ';
  2189.     if (it.opts.messages !== false) {
  2190.       out += ' , message: \'should be equal to constant\' ';
  2191.     }
  2192.     if (it.opts.verbose) {
  2193.       out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
  2194.     }
  2195.     out += ' } ';
  2196.   } else {
  2197.     out += ' {} ';
  2198.   }
  2199.   var __err = out;
  2200.   out = $$outStack.pop();
  2201.   if (!it.compositeRule && $breakOnError) { /* istanbul ignore if */
  2202.     if (it.async) {
  2203.       out += ' throw new ValidationError([' + (__err) + ']); ';
  2204.     } else {
  2205.       out += ' validate.errors = [' + (__err) + ']; return false; ';
  2206.     }
  2207.   } else {
  2208.     out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  2209.   }
  2210.   out += ' }';
  2211.   return out;
  2212. }
  2213.  
  2214. },{}],21:[function(require,module,exports){
  2215. 'use strict';
  2216. module.exports = function generate_custom(it, $keyword) {
  2217.   var out = ' ';
  2218.   var $lvl = it.level;
  2219.   var $dataLvl = it.dataLevel;
  2220.   var $schema = it.schema[$keyword];
  2221.   var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
  2222.   var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
  2223.   var $breakOnError = !it.opts.allErrors;
  2224.   var $errorKeyword;
  2225.   var $data = 'data' + ($dataLvl || '');
  2226.   var $valid = 'valid' + $lvl;
  2227.   var $errs = 'errs__' + $lvl;
  2228.   var $isData = it.opts.v5 && $schema && $schema.$data,
  2229.     $schemaValue;
  2230.   if ($isData) {
  2231.     out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; ';
  2232.     $schemaValue = 'schema' + $lvl;
  2233.   } else {
  2234.     $schemaValue = $schema;
  2235.   }
  2236.   var $rule = this,
  2237.     $definition = 'definition' + $lvl,
  2238.     $rDef = $rule.definition,
  2239.     $validate = $rDef.validate,
  2240.     $compile, $inline, $macro, $ruleValidate, $validateCode;
  2241.   if ($isData && $rDef.$data) {
  2242.     $validateCode = 'keywordValidate' + $lvl;
  2243.     var $validateSchema = $rDef.validateSchema;
  2244.     out += ' var ' + ($definition) + ' = RULES.custom[\'' + ($keyword) + '\'].definition; var ' + ($validateCode) + ' = ' + ($definition) + '.validate;';
  2245.   } else {
  2246.     $ruleValidate = it.useCustomRule($rule, $schema, it.schema, it);
  2247.     $schemaValue = 'validate.schema' + $schemaPath;
  2248.     $validateCode = $ruleValidate.code;
  2249.     $compile = $rDef.compile;
  2250.     $inline = $rDef.inline;
  2251.     $macro = $rDef.macro;
  2252.   }
  2253.   var $ruleErrs = $validateCode + '.errors',
  2254.     $i = 'i' + $lvl,
  2255.     $ruleErr = 'ruleErr' + $lvl,
  2256.     $asyncKeyword = $rDef.async;
  2257.   if ($asyncKeyword && !it.async) throw new Error('async keyword in sync schema');
  2258.   if (!($inline || $macro)) {
  2259.     out += '' + ($ruleErrs) + ' = null;';
  2260.   }
  2261.   out += 'var ' + ($errs) + ' = errors;var ' + ($valid) + ';';
  2262.   if ($validateSchema) {
  2263.     out += ' ' + ($valid) + ' = ' + ($definition) + '.validateSchema(' + ($schemaValue) + '); if (' + ($valid) + ') {';
  2264.   }
  2265.   if ($inline) {
  2266.     if ($rDef.statements) {
  2267.       out += ' ' + ($ruleValidate.validate) + ' ';
  2268.     } else {
  2269.       out += ' ' + ($valid) + ' = ' + ($ruleValidate.validate) + '; ';
  2270.     }
  2271.   } else if ($macro) {
  2272.     var $it = it.util.copy(it);
  2273.     $it.level++;
  2274.     var $nextValid = 'valid' + $it.level;
  2275.     $it.schema = $ruleValidate.validate;
  2276.     $it.schemaPath = '';
  2277.     var $wasComposite = it.compositeRule;
  2278.     it.compositeRule = $it.compositeRule = true;
  2279.     var $code = it.validate($it).replace(/validate\.schema/g, $validateCode);
  2280.     it.compositeRule = $it.compositeRule = $wasComposite;
  2281.     out += ' ' + ($code);
  2282.   } else {
  2283.     var $$outStack = $$outStack || [];
  2284.     $$outStack.push(out);
  2285.     out = '';
  2286.     out += '  ' + ($validateCode) + '.call( ';
  2287.     if (it.opts.passContext) {
  2288.       out += 'this';
  2289.     } else {
  2290.       out += 'self';
  2291.     }
  2292.     if ($compile || $rDef.schema === false) {
  2293.       out += ' , ' + ($data) + ' ';
  2294.     } else {
  2295.       out += ' , ' + ($schemaValue) + ' , ' + ($data) + ' , validate.schema' + (it.schemaPath) + ' ';
  2296.     }
  2297.     out += ' , (dataPath || \'\')';
  2298.     if (it.errorPath != '""') {
  2299.       out += ' + ' + (it.errorPath);
  2300.     }
  2301.     var $parentData = $dataLvl ? 'data' + (($dataLvl - 1) || '') : 'parentData',
  2302.       $parentDataProperty = $dataLvl ? it.dataPathArr[$dataLvl] : 'parentDataProperty';
  2303.     out += ' , ' + ($parentData) + ' , ' + ($parentDataProperty) + ' , rootData )  ';
  2304.     var def_callRuleValidate = out;
  2305.     out = $$outStack.pop();
  2306.     if ($rDef.errors === false) {
  2307.       out += ' ' + ($valid) + ' = ';
  2308.       if ($asyncKeyword) {
  2309.         out += '' + (it.yieldAwait);
  2310.       }
  2311.       out += '' + (def_callRuleValidate) + '; ';
  2312.     } else {
  2313.       if ($asyncKeyword) {
  2314.         $ruleErrs = 'customErrors' + $lvl;
  2315.         out += ' var ' + ($ruleErrs) + ' = null; try { ' + ($valid) + ' = ' + (it.yieldAwait) + (def_callRuleValidate) + '; } catch (e) { ' + ($valid) + ' = false; if (e instanceof ValidationError) ' + ($ruleErrs) + ' = e.errors; else throw e; } ';
  2316.       } else {
  2317.         out += ' ' + ($ruleErrs) + ' = null; ' + ($valid) + ' = ' + (def_callRuleValidate) + '; ';
  2318.       }
  2319.     }
  2320.   }
  2321.   if ($rDef.modifying) {
  2322.     out += ' ' + ($data) + ' = ' + ($parentData) + '[' + ($parentDataProperty) + '];';
  2323.   }
  2324.   if ($validateSchema) {
  2325.     out += ' }';
  2326.   }
  2327.   if ($rDef.valid) {
  2328.     if ($breakOnError) {
  2329.       out += ' if (true) { ';
  2330.     }
  2331.   } else {
  2332.     out += ' if ( ';
  2333.     if ($rDef.valid === undefined) {
  2334.       out += ' !';
  2335.       if ($macro) {
  2336.         out += '' + ($nextValid);
  2337.       } else {
  2338.         out += '' + ($valid);
  2339.       }
  2340.     } else {
  2341.       out += ' ' + (!$rDef.valid) + ' ';
  2342.     }
  2343.     out += ') { ';
  2344.     $errorKeyword = $rule.keyword;
  2345.     var $$outStack = $$outStack || [];
  2346.     $$outStack.push(out);
  2347.     out = '';
  2348.     var $$outStack = $$outStack || [];
  2349.     $$outStack.push(out);
  2350.     out = ''; /* istanbul ignore else */
  2351.     if (it.createErrors !== false) {
  2352.       out += ' { keyword: \'' + ($errorKeyword || 'custom') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { keyword: \'' + ($rule.keyword) + '\' } ';
  2353.       if (it.opts.messages !== false) {
  2354.         out += ' , message: \'should pass "' + ($rule.keyword) + '" keyword validation\' ';
  2355.       }
  2356.       if (it.opts.verbose) {
  2357.         out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
  2358.       }
  2359.       out += ' } ';
  2360.     } else {
  2361.       out += ' {} ';
  2362.     }
  2363.     var __err = out;
  2364.     out = $$outStack.pop();
  2365.     if (!it.compositeRule && $breakOnError) { /* istanbul ignore if */
  2366.       if (it.async) {
  2367.         out += ' throw new ValidationError([' + (__err) + ']); ';
  2368.       } else {
  2369.         out += ' validate.errors = [' + (__err) + ']; return false; ';
  2370.       }
  2371.     } else {
  2372.       out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  2373.     }
  2374.     var def_customError = out;
  2375.     out = $$outStack.pop();
  2376.     if ($inline) {
  2377.       if ($rDef.errors) {
  2378.         if ($rDef.errors != 'full') {
  2379.           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) + '"; } ';
  2380.           if (it.opts.verbose) {
  2381.             out += ' ' + ($ruleErr) + '.schema = ' + ($schemaValue) + '; ' + ($ruleErr) + '.data = ' + ($data) + '; ';
  2382.           }
  2383.           out += ' } ';
  2384.         }
  2385.       } else {
  2386.         if ($rDef.errors === false) {
  2387.           out += ' ' + (def_customError) + ' ';
  2388.         } else {
  2389.           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) + '"; } ';
  2390.           if (it.opts.verbose) {
  2391.             out += ' ' + ($ruleErr) + '.schema = ' + ($schemaValue) + '; ' + ($ruleErr) + '.data = ' + ($data) + '; ';
  2392.           }
  2393.           out += ' } } ';
  2394.         }
  2395.       }
  2396.     } else if ($macro) {
  2397.       out += '   var err =   '; /* istanbul ignore else */
  2398.       if (it.createErrors !== false) {
  2399.         out += ' { keyword: \'' + ($errorKeyword || 'custom') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { keyword: \'' + ($rule.keyword) + '\' } ';
  2400.         if (it.opts.messages !== false) {
  2401.           out += ' , message: \'should pass "' + ($rule.keyword) + '" keyword validation\' ';
  2402.         }
  2403.         if (it.opts.verbose) {
  2404.           out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
  2405.         }
  2406.         out += ' } ';
  2407.       } else {
  2408.         out += ' {} ';
  2409.       }
  2410.       out += ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  2411.       if (!it.compositeRule && $breakOnError) { /* istanbul ignore if */
  2412.         if (it.async) {
  2413.           out += ' throw new ValidationError(vErrors); ';
  2414.         } else {
  2415.           out += ' validate.errors = vErrors; return false; ';
  2416.         }
  2417.       }
  2418.     } else {
  2419.       if ($rDef.errors === false) {
  2420.         out += ' ' + (def_customError) + ' ';
  2421.       } else {
  2422.         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) + '";  ';
  2423.         if (it.opts.verbose) {
  2424.           out += ' ' + ($ruleErr) + '.schema = ' + ($schemaValue) + '; ' + ($ruleErr) + '.data = ' + ($data) + '; ';
  2425.         }
  2426.         out += ' } } else { ' + (def_customError) + ' } ';
  2427.       }
  2428.     }
  2429.     out += ' } ';
  2430.     if ($breakOnError) {
  2431.       out += ' else { ';
  2432.     }
  2433.   }
  2434.   return out;
  2435. }
  2436.  
  2437. },{}],22:[function(require,module,exports){
  2438. 'use strict';
  2439. module.exports = function generate_dependencies(it, $keyword) {
  2440.   var out = ' ';
  2441.   var $lvl = it.level;
  2442.   var $dataLvl = it.dataLevel;
  2443.   var $schema = it.schema[$keyword];
  2444.   var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
  2445.   var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
  2446.   var $breakOnError = !it.opts.allErrors;
  2447.   var $errorKeyword;
  2448.   var $data = 'data' + ($dataLvl || '');
  2449.   var $errs = 'errs__' + $lvl;
  2450.   var $it = it.util.copy(it);
  2451.   var $closingBraces = '';
  2452.   $it.level++;
  2453.   var $nextValid = 'valid' + $it.level;
  2454.   var $schemaDeps = {},
  2455.     $propertyDeps = {};
  2456.   for ($property in $schema) {
  2457.     var $sch = $schema[$property];
  2458.     var $deps = Array.isArray($sch) ? $propertyDeps : $schemaDeps;
  2459.     $deps[$property] = $sch;
  2460.   }
  2461.   out += 'var ' + ($errs) + ' = errors;';
  2462.   var $currentErrorPath = it.errorPath;
  2463.   out += 'var missing' + ($lvl) + ';';
  2464.   for (var $property in $propertyDeps) {
  2465.     $deps = $propertyDeps[$property];
  2466.     out += ' if (' + ($data) + (it.util.getProperty($property)) + ' !== undefined ';
  2467.     if ($breakOnError) {
  2468.       out += ' && ( ';
  2469.       var arr1 = $deps;
  2470.       if (arr1) {
  2471.         var _$property, $i = -1,
  2472.           l1 = arr1.length - 1;
  2473.         while ($i < l1) {
  2474.           _$property = arr1[$i += 1];
  2475.           if ($i) {
  2476.             out += ' || ';
  2477.           }
  2478.           var $prop = it.util.getProperty(_$property);
  2479.           out += ' ( ' + ($data) + ($prop) + ' === undefined && (missing' + ($lvl) + ' = ' + (it.util.toQuotedString(it.opts.jsonPointers ? _$property : $prop)) + ') ) ';
  2480.         }
  2481.       }
  2482.       out += ')) {  ';
  2483.       var $propertyPath = 'missing' + $lvl,
  2484.         $missingProperty = '\' + ' + $propertyPath + ' + \'';
  2485.       if (it.opts._errorDataPathProperty) {
  2486.         it.errorPath = it.opts.jsonPointers ? it.util.getPathExpr($currentErrorPath, $propertyPath, true) : $currentErrorPath + ' + ' + $propertyPath;
  2487.       }
  2488.       var $$outStack = $$outStack || [];
  2489.       $$outStack.push(out)