aboutsummaryrefslogtreecommitdiff
path: root/node_modules/ajv/lib/compile
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/ajv/lib/compile')
-rw-r--r--node_modules/ajv/lib/compile/_rules.js3
-rw-r--r--node_modules/ajv/lib/compile/async.js90
-rw-r--r--node_modules/ajv/lib/compile/equal.js44
-rw-r--r--node_modules/ajv/lib/compile/error_classes.js34
-rw-r--r--node_modules/ajv/lib/compile/formats.js79
-rw-r--r--node_modules/ajv/lib/compile/index.js65
-rw-r--r--node_modules/ajv/lib/compile/resolve.js104
-rw-r--r--node_modules/ajv/lib/compile/rules.js34
-rw-r--r--node_modules/ajv/lib/compile/util.js28
-rw-r--r--node_modules/ajv/lib/compile/validation_error.js14
10 files changed, 279 insertions, 216 deletions
diff --git a/node_modules/ajv/lib/compile/_rules.js b/node_modules/ajv/lib/compile/_rules.js
index c98610e41..3fe69973a 100644
--- a/node_modules/ajv/lib/compile/_rules.js
+++ b/node_modules/ajv/lib/compile/_rules.js
@@ -5,6 +5,8 @@ module.exports = {
'$ref': require('../dotjs/ref'),
allOf: require('../dotjs/allOf'),
anyOf: require('../dotjs/anyOf'),
+ const: require('../dotjs/const'),
+ contains: require('../dotjs/contains'),
dependencies: require('../dotjs/dependencies'),
'enum': require('../dotjs/enum'),
format: require('../dotjs/format'),
@@ -22,6 +24,7 @@ module.exports = {
oneOf: require('../dotjs/oneOf'),
pattern: require('../dotjs/pattern'),
properties: require('../dotjs/properties'),
+ propertyNames: require('../dotjs/propertyNames'),
required: require('../dotjs/required'),
uniqueItems: require('../dotjs/uniqueItems'),
validate: require('../dotjs/validate')
diff --git a/node_modules/ajv/lib/compile/async.js b/node_modules/ajv/lib/compile/async.js
new file mode 100644
index 000000000..6a30b8892
--- /dev/null
+++ b/node_modules/ajv/lib/compile/async.js
@@ -0,0 +1,90 @@
+'use strict';
+
+var MissingRefError = require('./error_classes').MissingRef;
+
+module.exports = compileAsync;
+
+
+/**
+ * Creates validating function for passed schema with asynchronous loading of missing schemas.
+ * `loadSchema` option should be a function that accepts schema uri and returns promise that resolves with the schema.
+ * @this Ajv
+ * @param {Object} schema schema object
+ * @param {Boolean} meta optional true to compile meta-schema; this parameter can be skipped
+ * @param {Function} callback an optional node-style callback, it is called with 2 parameters: error (or null) and validating function.
+ * @return {Promise} promise that resolves with a validating function.
+ */
+function compileAsync(schema, meta, callback) {
+ /* eslint no-shadow: 0 */
+ /* global Promise */
+ /* jshint validthis: true */
+ var self = this;
+ if (typeof this._opts.loadSchema != 'function')
+ throw new Error('options.loadSchema should be a function');
+
+ if (typeof meta == 'function') {
+ callback = meta;
+ meta = undefined;
+ }
+
+ var p = loadMetaSchemaOf(schema).then(function () {
+ var schemaObj = self._addSchema(schema, undefined, meta);
+ return schemaObj.validate || _compileAsync(schemaObj);
+ });
+
+ if (callback) {
+ p.then(
+ function(v) { callback(null, v); },
+ callback
+ );
+ }
+
+ return p;
+
+
+ function loadMetaSchemaOf(sch) {
+ var $schema = sch.$schema;
+ return $schema && !self.getSchema($schema)
+ ? compileAsync.call(self, { $ref: $schema }, true)
+ : Promise.resolve();
+ }
+
+
+ function _compileAsync(schemaObj) {
+ try { return self._compile(schemaObj); }
+ catch(e) {
+ if (e instanceof MissingRefError) return loadMissingSchema(e);
+ throw e;
+ }
+
+
+ function loadMissingSchema(e) {
+ var ref = e.missingSchema;
+ if (added(ref)) throw new Error('Schema ' + ref + ' is loaded but ' + e.missingRef + ' cannot be resolved');
+
+ var schemaPromise = self._loadingSchemas[ref];
+ if (!schemaPromise) {
+ schemaPromise = self._loadingSchemas[ref] = self._opts.loadSchema(ref);
+ schemaPromise.then(removePromise, removePromise);
+ }
+
+ return schemaPromise.then(function (sch) {
+ if (!added(ref)) {
+ return loadMetaSchemaOf(sch).then(function () {
+ if (!added(ref)) self.addSchema(sch, ref, undefined, meta);
+ });
+ }
+ }).then(function() {
+ return _compileAsync(schemaObj);
+ });
+
+ function removePromise() {
+ delete self._loadingSchemas[ref];
+ }
+
+ function added(ref) {
+ return self._refs[ref] || self._schemas[ref];
+ }
+ }
+ }
+}
diff --git a/node_modules/ajv/lib/compile/equal.js b/node_modules/ajv/lib/compile/equal.js
index 2a918746c..911774c85 100644
--- a/node_modules/ajv/lib/compile/equal.js
+++ b/node_modules/ajv/lib/compile/equal.js
@@ -1,45 +1,3 @@
'use strict';
-/*eslint complexity: 0*/
-
-module.exports = function equal(a, b) {
- if (a === b) return true;
-
- var arrA = Array.isArray(a)
- , arrB = Array.isArray(b)
- , i;
-
- if (arrA && arrB) {
- if (a.length != b.length) return false;
- for (i = 0; i < a.length; i++)
- if (!equal(a[i], b[i])) return false;
- return true;
- }
-
- if (arrA != arrB) return false;
-
- if (a && b && typeof a === 'object' && typeof b === 'object') {
- var keys = Object.keys(a);
- if (keys.length !== Object.keys(b).length) return false;
-
- var dateA = a instanceof Date
- , dateB = b instanceof Date;
- if (dateA && dateB) return a.getTime() == b.getTime();
- if (dateA != dateB) return false;
-
- var regexpA = a instanceof RegExp
- , regexpB = b instanceof RegExp;
- if (regexpA && regexpB) return a.toString() == b.toString();
- if (regexpA != regexpB) return false;
-
- for (i = 0; i < keys.length; i++)
- if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
-
- for (i = 0; i < keys.length; i++)
- if(!equal(a[keys[i]], b[keys[i]])) return false;
-
- return true;
- }
-
- return false;
-};
+module.exports = require('fast-deep-equal');
diff --git a/node_modules/ajv/lib/compile/error_classes.js b/node_modules/ajv/lib/compile/error_classes.js
new file mode 100644
index 000000000..0b0ec4e4e
--- /dev/null
+++ b/node_modules/ajv/lib/compile/error_classes.js
@@ -0,0 +1,34 @@
+'use strict';
+
+var resolve = require('./resolve');
+
+module.exports = {
+ Validation: errorSubclass(ValidationError),
+ MissingRef: errorSubclass(MissingRefError)
+};
+
+
+function ValidationError(errors) {
+ this.message = 'validation failed';
+ this.errors = errors;
+ this.ajv = this.validation = true;
+}
+
+
+MissingRefError.message = function (baseId, ref) {
+ return 'can\'t resolve reference ' + ref + ' from id ' + baseId;
+};
+
+
+function MissingRefError(baseId, ref, message) {
+ this.message = message || MissingRefError.message(baseId, ref);
+ this.missingRef = resolve.url(baseId, ref);
+ this.missingSchema = resolve.normalizeId(resolve.fullPath(this.missingRef));
+}
+
+
+function errorSubclass(Subclass) {
+ Subclass.prototype = Object.create(Error.prototype);
+ Subclass.prototype.constructor = Subclass;
+ return Subclass;
+}
diff --git a/node_modules/ajv/lib/compile/formats.js b/node_modules/ajv/lib/compile/formats.js
index 2130a31b0..b3a1541a6 100644
--- a/node_modules/ajv/lib/compile/formats.js
+++ b/node_modules/ajv/lib/compile/formats.js
@@ -6,24 +6,25 @@ var DATE = /^\d\d\d\d-(\d\d)-(\d\d)$/;
var DAYS = [0,31,29,31,30,31,30,31,31,30,31,30,31];
var TIME = /^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d:\d\d)?$/i;
var HOSTNAME = /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*$/i;
-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]\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EMPLATE = /^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i;
+// For the source: https://gist.github.com/dperini/729294
+// For test cases: https://mathiasbynens.be/demo/url-regex
+// @todo Delete current URL in favour of the commented out URL rule when this issue is fixed https://github.com/eslint/eslint/issues/7983.
+// var URL = /^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)(?:\.(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu;
+var URL = /^(?:(?:http[s\u017F]?|ftp):\/\/)(?:(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+(?::(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)?@)?(?:(?!10(?:\.[0-9]{1,3}){3})(?!127(?:\.[0-9]{1,3}){3})(?!169\.254(?:\.[0-9]{1,3}){2})(?!192\.168(?:\.[0-9]{1,3}){2})(?!172\.(?:1[6-9]|2[0-9]|3[01])(?:\.[0-9]{1,3}){2})(?:[1-9][0-9]?|1[0-9][0-9]|2[01][0-9]|22[0-3])(?:\.(?:1?[0-9]{1,2}|2[0-4][0-9]|25[0-5])){2}(?:\.(?:[1-9][0-9]?|1[0-9][0-9]|2[0-4][0-9]|25[0-4]))|(?:(?:(?:[0-9KSa-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+-?)*(?:[0-9KSa-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+)(?:\.(?:(?:[0-9KSa-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+-?)*(?:[0-9KSa-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+)*(?:\.(?:(?:[KSa-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]){2,})))(?::[0-9]{2,5})?(?:\/(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)?$/i;
+var UUID = /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i;
+var JSON_POINTER = /^(?:\/(?:[^~/]|~0|~1)*)*$|^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i;
+var RELATIVE_JSON_POINTER = /^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/;
module.exports = formats;
function formats(mode) {
mode = mode == 'full' ? 'full' : 'fast';
- var formatDefs = util.copy(formats[mode]);
- for (var fName in formats.compare) {
- formatDefs[fName] = {
- validate: formatDefs[fName],
- compare: formats.compare[fName]
- };
- }
- return formatDefs;
+ return util.copy(formats[mode]);
}
@@ -34,11 +35,14 @@ formats.fast = {
time: /^[0-2]\d:[0-5]\d:[0-5]\d(?:\.\d+)?(?:z|[+-]\d\d:\d\d)?$/i,
'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,
// uri: https://github.com/mafintosh/is-my-json-valid/blob/master/formats.js
- uri: /^(?:[a-z][a-z0-9+-.]*)?(?:\:|\/)\/?[^\s]*$/i,
+ uri: /^(?:[a-z][a-z0-9+-.]*)(?::|\/)\/?[^\s]*$/i,
+ 'uri-reference': /^(?:(?:[a-z][a-z0-9+-.]*:)?\/\/)?[^\s]*$/i,
+ 'uri-template': URITEMPLATE,
+ url: URL,
// email (sources from jsen validator):
// http://stackoverflow.com/questions/201323/using-a-regular-expression-to-validate-an-email-address#answer-8829363
// http://www.w3.org/TR/html5/forms.html#valid-e-mail-address (search for 'willful violation')
- 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,
+ 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,
hostname: HOSTNAME,
// optimized https://www.safaribooksonline.com/library/view/regular-expressions-cookbook/9780596802837/ch07s16.html
ipv4: /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,
@@ -60,7 +64,10 @@ formats.full = {
time: time,
'date-time': date_time,
uri: uri,
- 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,
+ 'uri-reference': URIREF,
+ 'uri-template': URITEMPLATE,
+ url: URL,
+ 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,
hostname: hostname,
ipv4: /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,
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,
@@ -71,13 +78,6 @@ formats.full = {
};
-formats.compare = {
- date: compareDate,
- time: compareTime,
- 'date-time': compareDateTime
-};
-
-
function date(str) {
// full-date from http://tools.ietf.org/html/rfc3339#section-5.6
var matches = str.match(DATE);
@@ -116,14 +116,16 @@ function hostname(str) {
}
-var NOT_URI_FRAGMENT = /\/|\:/;
+var NOT_URI_FRAGMENT = /\/|:/;
function uri(str) {
// http://jmrware.com/articles/2009/uri_regexp/URI_regex.html + optional protocol + required "."
return NOT_URI_FRAGMENT.test(str) && URI.test(str);
}
+var Z_ANCHOR = /[^\\]\\Z/;
function regex(str) {
+ if (Z_ANCHOR.test(str)) return false;
try {
new RegExp(str);
return true;
@@ -131,34 +133,3 @@ function regex(str) {
return false;
}
}
-
-
-function compareDate(d1, d2) {
- if (!(d1 && d2)) return;
- if (d1 > d2) return 1;
- if (d1 < d2) return -1;
- if (d1 === d2) return 0;
-}
-
-
-function compareTime(t1, t2) {
- if (!(t1 && t2)) return;
- t1 = t1.match(TIME);
- t2 = t2.match(TIME);
- if (!(t1 && t2)) return;
- t1 = t1[1] + t1[2] + t1[3] + (t1[4]||'');
- t2 = t2[1] + t2[2] + t2[3] + (t2[4]||'');
- if (t1 > t2) return 1;
- if (t1 < t2) return -1;
- if (t1 === t2) return 0;
-}
-
-
-function compareDateTime(dt1, dt2) {
- if (!(dt1 && dt2)) return;
- dt1 = dt1.split(DATE_TIME_SEPARATOR);
- dt2 = dt2.split(DATE_TIME_SEPARATOR);
- var res = compareDate(dt1[0], dt2[0]);
- if (res === undefined) return;
- return res || compareTime(dt1[1], dt2[1]);
-}
diff --git a/node_modules/ajv/lib/compile/index.js b/node_modules/ajv/lib/compile/index.js
index c9c6730f8..45e35d905 100644
--- a/node_modules/ajv/lib/compile/index.js
+++ b/node_modules/ajv/lib/compile/index.js
@@ -2,18 +2,8 @@
var resolve = require('./resolve')
, util = require('./util')
- , stableStringify = require('json-stable-stringify')
- , async = require('../async');
-
-var beautify;
-
-function loadBeautify(){
- if (beautify === undefined) {
- var name = 'js-beautify';
- try { beautify = require(name).js_beautify; }
- catch(e) { beautify = false; }
- }
-}
+ , errorClasses = require('./error_classes')
+ , stableStringify = require('json-stable-stringify');
var validateGenerator = require('../dotjs/validate');
@@ -23,10 +13,10 @@ var validateGenerator = require('../dotjs/validate');
var co = require('co');
var ucs2length = util.ucs2length;
-var equal = require('./equal');
+var equal = require('fast-deep-equal');
// this error is thrown by async schemas to return validation errors via exception
-var ValidationError = require('./validation_error');
+var ValidationError = errorClasses.Validation;
module.exports = compile;
@@ -51,8 +41,7 @@ function compile(schema, root, localRefs, baseId) {
, patternsHash = {}
, defaults = []
, defaultsHash = {}
- , customRules = []
- , keepSourceCode = opts.sourceCode !== false;
+ , customRules = [];
root = root || { schema: schema, refVal: refVal, refs: refs };
@@ -74,7 +63,7 @@ function compile(schema, root, localRefs, baseId) {
cv.refVal = v.refVal;
cv.root = v.root;
cv.$async = v.$async;
- if (keepSourceCode) cv.sourceCode = v.sourceCode;
+ if (opts.sourceCode) cv.source = v.source;
}
return v;
} finally {
@@ -94,7 +83,6 @@ function compile(schema, root, localRefs, baseId) {
return compile.call(self, _schema, _root, localRefs, baseId);
var $async = _schema.$async === true;
- if ($async && !opts.transpile) async.setup(opts);
var sourceCode = validateGenerator({
isTop: true,
@@ -105,6 +93,7 @@ function compile(schema, root, localRefs, baseId) {
schemaPath: '',
errSchemaPath: '#',
errorPath: '""',
+ MissingRefError: errorClasses.MissingRef,
RULES: RULES,
validate: validateGenerator,
util: util,
@@ -122,20 +111,10 @@ function compile(schema, root, localRefs, baseId) {
+ vars(defaults, defaultCode) + vars(customRules, customRuleCode)
+ sourceCode;
- if (opts.beautify) {
- loadBeautify();
- /* istanbul ignore else */
- if (beautify) sourceCode = beautify(sourceCode, opts.beautify);
- else console.error('"npm install js-beautify" to use beautify option');
- }
- // console.log('\n\n\n *** \n', sourceCode);
- var validate, validateCode
- , transpile = opts._transpileFunc;
+ if (opts.processCode) sourceCode = opts.processCode(sourceCode);
+ // console.log('\n\n\n *** \n', JSON.stringify(sourceCode));
+ var validate;
try {
- validateCode = $async && transpile
- ? transpile(sourceCode)
- : sourceCode;
-
var makeValidate = new Function(
'self',
'RULES',
@@ -148,7 +127,7 @@ function compile(schema, root, localRefs, baseId) {
'equal',
'ucs2length',
'ValidationError',
- validateCode
+ sourceCode
);
validate = makeValidate(
@@ -167,7 +146,7 @@ function compile(schema, root, localRefs, baseId) {
refVal[0] = validate;
} catch(e) {
- console.error('Error compiling schema, function code:', validateCode);
+ console.error('Error compiling schema, function code:', sourceCode);
throw e;
}
@@ -177,9 +156,9 @@ function compile(schema, root, localRefs, baseId) {
validate.refVal = refVal;
validate.root = isRoot ? validate : _root;
if ($async) validate.$async = true;
- if (keepSourceCode) validate.sourceCode = sourceCode;
if (opts.sourceCode === true) {
validate.source = {
+ code: sourceCode,
patterns: patterns,
defaults: defaults
};
@@ -208,7 +187,7 @@ function compile(schema, root, localRefs, baseId) {
refCode = addLocalRef(ref);
var v = resolve.call(self, localCompile, root, ref);
- if (!v) {
+ if (v === undefined) {
var localSchema = localRefs && localRefs[ref];
if (localSchema) {
v = resolve.inlineRef(localSchema, opts.inlineRefs)
@@ -217,7 +196,9 @@ function compile(schema, root, localRefs, baseId) {
}
}
- if (v) {
+ if (v === undefined) {
+ removeLocalRef(ref);
+ } else {
replaceLocalRef(ref, v);
return resolvedRef(v, refCode);
}
@@ -230,13 +211,17 @@ function compile(schema, root, localRefs, baseId) {
return 'refVal' + refId;
}
+ function removeLocalRef(ref) {
+ delete refs[ref];
+ }
+
function replaceLocalRef(ref, v) {
var refId = refs[ref];
refVal[refId] = v;
}
function resolvedRef(refVal, code) {
- return typeof refVal == 'object'
+ return typeof refVal == 'object' || typeof refVal == 'boolean'
? { code: code, schema: refVal, inline: true }
: { code: code, $async: refVal && refVal.$async };
}
@@ -294,8 +279,12 @@ function compile(schema, root, localRefs, baseId) {
validate = inline.call(self, it, rule.keyword, schema, parentSchema);
} else {
validate = rule.definition.validate;
+ if (!validate) return;
}
+ if (validate === undefined)
+ throw new Error('custom keyword "' + rule.keyword + '"failed to compile');
+
var index = customRules.length;
customRules[index] = validate;
@@ -372,7 +361,7 @@ function defaultCode(i) {
function refValCode(i, refVal) {
- return refVal[i] ? 'var refVal' + i + ' = refVal[' + i + '];' : '';
+ return refVal[i] === undefined ? '' : 'var refVal' + i + ' = refVal[' + i + '];';
}
diff --git a/node_modules/ajv/lib/compile/resolve.js b/node_modules/ajv/lib/compile/resolve.js
index db2b91fbf..7d06afab8 100644
--- a/node_modules/ajv/lib/compile/resolve.js
+++ b/node_modules/ajv/lib/compile/resolve.js
@@ -1,9 +1,10 @@
'use strict';
var url = require('url')
- , equal = require('./equal')
+ , equal = require('fast-deep-equal')
, util = require('./util')
- , SchemaObject = require('./schema_obj');
+ , SchemaObject = require('./schema_obj')
+ , traverse = require('json-schema-traverse');
module.exports = resolve;
@@ -47,7 +48,7 @@ function resolve(compile, root, ref) {
if (schema instanceof SchemaObject) {
v = schema.validate || compile.call(this, schema.schema, root, undefined, baseId);
- } else if (schema) {
+ } else if (schema !== undefined) {
v = inlineRef(schema, this._opts.inlineRefs)
? schema
: compile.call(this, schema, root, undefined, baseId);
@@ -68,7 +69,7 @@ function resolveSchema(root, ref) {
/* jshint validthis: true */
var p = url.parse(ref, false, true)
, refPath = _getFullPath(p)
- , baseId = getFullPath(root.schema.id);
+ , baseId = getFullPath(this._getId(root.schema));
if (refPath !== baseId) {
var id = normalizeId(refPath);
var refVal = this._refs[id];
@@ -89,7 +90,7 @@ function resolveSchema(root, ref) {
}
}
if (!root.schema) return;
- baseId = getFullPath(root.schema.id);
+ baseId = getFullPath(this._getId(root.schema));
}
return getJsonPointer.call(this, p, baseId, root.schema, root);
}
@@ -103,7 +104,8 @@ function resolveRecursive(root, ref, parsedRef) {
var schema = res.schema;
var baseId = res.baseId;
root = res.root;
- if (schema.id) baseId = resolveUrl(baseId, schema.id);
+ var id = this._getId(schema);
+ if (id) baseId = resolveUrl(baseId, id);
return getJsonPointer.call(this, parsedRef, baseId, schema, root);
}
}
@@ -122,20 +124,24 @@ function getJsonPointer(parsedRef, baseId, schema, root) {
if (part) {
part = util.unescapeFragment(part);
schema = schema[part];
- if (!schema) break;
- if (schema.id && !PREVENT_SCOPE_CHANGE[part]) baseId = resolveUrl(baseId, schema.id);
- if (schema.$ref) {
- var $ref = resolveUrl(baseId, schema.$ref);
- var res = resolveSchema.call(this, root, $ref);
- if (res) {
- schema = res.schema;
- root = res.root;
- baseId = res.baseId;
+ if (schema === undefined) break;
+ var id;
+ if (!PREVENT_SCOPE_CHANGE[part]) {
+ id = this._getId(schema);
+ if (id) baseId = resolveUrl(baseId, id);
+ if (schema.$ref) {
+ var $ref = resolveUrl(baseId, schema.$ref);
+ var res = resolveSchema.call(this, root, $ref);
+ if (res) {
+ schema = res.schema;
+ root = res.root;
+ baseId = res.baseId;
+ }
}
}
}
}
- if (schema && schema != root.schema)
+ if (schema !== undefined && schema !== root.schema)
return { schema: schema, root: root, baseId: baseId };
}
@@ -225,43 +231,41 @@ function resolveUrl(baseId, id) {
/* @this Ajv */
function resolveIds(schema) {
- /* eslint no-shadow: 0 */
- /* jshint validthis: true */
- var id = normalizeId(schema.id);
+ var schemaId = normalizeId(this._getId(schema));
+ var baseIds = {'': schemaId};
+ var fullPaths = {'': getFullPath(schemaId, false)};
var localRefs = {};
- _resolveIds.call(this, schema, getFullPath(id, false), id);
- return localRefs;
-
- /* @this Ajv */
- function _resolveIds(schema, fullPath, baseId) {
- /* jshint validthis: true */
- if (Array.isArray(schema)) {
- for (var i=0; i<schema.length; i++)
- _resolveIds.call(this, schema[i], fullPath+'/'+i, baseId);
- } else if (schema && typeof schema == 'object') {
- if (typeof schema.id == 'string') {
- var id = baseId = baseId
- ? url.resolve(baseId, schema.id)
- : schema.id;
- id = normalizeId(id);
-
- var refVal = this._refs[id];
- if (typeof refVal == 'string') refVal = this._refs[refVal];
- if (refVal && refVal.schema) {
- if (!equal(schema, refVal.schema))
+ var self = this;
+
+ traverse(schema, {allKeys: true}, function(sch, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex) {
+ if (jsonPtr === '') return;
+ var id = self._getId(sch);
+ var baseId = baseIds[parentJsonPtr];
+ var fullPath = fullPaths[parentJsonPtr] + '/' + parentKeyword;
+ if (keyIndex !== undefined)
+ fullPath += '/' + (typeof keyIndex == 'number' ? keyIndex : util.escapeFragment(keyIndex));
+
+ if (typeof id == 'string') {
+ id = baseId = normalizeId(baseId ? url.resolve(baseId, id) : id);
+
+ var refVal = self._refs[id];
+ if (typeof refVal == 'string') refVal = self._refs[refVal];
+ if (refVal && refVal.schema) {
+ if (!equal(sch, refVal.schema))
+ throw new Error('id "' + id + '" resolves to more than one schema');
+ } else if (id != normalizeId(fullPath)) {
+ if (id[0] == '#') {
+ if (localRefs[id] && !equal(sch, localRefs[id]))
throw new Error('id "' + id + '" resolves to more than one schema');
- } else if (id != normalizeId(fullPath)) {
- if (id[0] == '#') {
- if (localRefs[id] && !equal(schema, localRefs[id]))
- throw new Error('id "' + id + '" resolves to more than one schema');
- localRefs[id] = schema;
- } else {
- this._refs[id] = fullPath;
- }
+ localRefs[id] = sch;
+ } else {
+ self._refs[id] = fullPath;
}
}
- for (var key in schema)
- _resolveIds.call(this, schema[key], fullPath+'/'+util.escapeFragment(key), baseId);
}
- }
+ baseIds[jsonPtr] = baseId;
+ fullPaths[jsonPtr] = fullPath;
+ });
+
+ return localRefs;
}
diff --git a/node_modules/ajv/lib/compile/rules.js b/node_modules/ajv/lib/compile/rules.js
index 39b1708d9..eaeab77fa 100644
--- a/node_modules/ajv/lib/compile/rules.js
+++ b/node_modules/ajv/lib/compile/rules.js
@@ -6,34 +6,52 @@ var ruleModules = require('./_rules')
module.exports = function rules() {
var RULES = [
{ type: 'number',
- rules: [ 'maximum', 'minimum', 'multipleOf'] },
+ rules: [ { 'maximum': ['exclusiveMaximum'] },
+ { 'minimum': ['exclusiveMinimum'] }, 'multipleOf', 'format'] },
{ type: 'string',
rules: [ 'maxLength', 'minLength', 'pattern', 'format' ] },
{ type: 'array',
- rules: [ 'maxItems', 'minItems', 'uniqueItems', 'items' ] },
+ rules: [ 'maxItems', 'minItems', 'uniqueItems', 'contains', 'items' ] },
{ type: 'object',
- rules: [ 'maxProperties', 'minProperties', 'required', 'dependencies', 'properties' ] },
- { rules: [ '$ref', 'enum', 'not', 'anyOf', 'oneOf', 'allOf' ] }
+ rules: [ 'maxProperties', 'minProperties', 'required', 'dependencies', 'propertyNames',
+ { 'properties': ['additionalProperties', 'patternProperties'] } ] },
+ { rules: [ '$ref', 'const', 'enum', 'not', 'anyOf', 'oneOf', 'allOf' ] }
];
- var ALL = [ 'type', 'additionalProperties', 'patternProperties' ];
- var KEYWORDS = [ 'additionalItems', '$schema', 'id', 'title', 'description', 'default' ];
+ var ALL = [ 'type' ];
+ var KEYWORDS = [
+ 'additionalItems', '$schema', 'id', 'title',
+ 'description', 'default', 'definitions'
+ ];
var TYPES = [ 'number', 'integer', 'string', 'array', 'object', 'boolean', 'null' ];
RULES.all = toHash(ALL);
+ RULES.types = toHash(TYPES);
RULES.forEach(function (group) {
group.rules = group.rules.map(function (keyword) {
+ var implKeywords;
+ if (typeof keyword == 'object') {
+ var key = Object.keys(keyword)[0];
+ implKeywords = keyword[key];
+ keyword = key;
+ implKeywords.forEach(function (k) {
+ ALL.push(k);
+ RULES.all[k] = true;
+ });
+ }
ALL.push(keyword);
var rule = RULES.all[keyword] = {
keyword: keyword,
- code: ruleModules[keyword]
+ code: ruleModules[keyword],
+ implements: implKeywords
};
return rule;
});
+
+ if (group.type) RULES.types[group.type] = group;
});
RULES.keywords = toHash(ALL.concat(KEYWORDS));
- RULES.types = toHash(TYPES);
RULES.custom = {};
return RULES;
diff --git a/node_modules/ajv/lib/compile/util.js b/node_modules/ajv/lib/compile/util.js
index 8451f83ae..263891c33 100644
--- a/node_modules/ajv/lib/compile/util.js
+++ b/node_modules/ajv/lib/compile/util.js
@@ -9,19 +9,20 @@ module.exports = {
toHash: toHash,
getProperty: getProperty,
escapeQuotes: escapeQuotes,
+ equal: require('fast-deep-equal'),
ucs2length: require('./ucs2length'),
varOccurences: varOccurences,
varReplace: varReplace,
cleanUpCode: cleanUpCode,
- cleanUpVarErrors: cleanUpVarErrors,
+ finalCleanUpCode: finalCleanUpCode,
schemaHasRules: schemaHasRules,
schemaHasRulesExcept: schemaHasRulesExcept,
- stableStringify: require('json-stable-stringify'),
toQuotedString: toQuotedString,
getPathExpr: getPathExpr,
getPath: getPath,
getData: getData,
unescapeFragment: unescapeFragment,
+ unescapeJsonPointer: unescapeJsonPointer,
escapeFragment: escapeFragment,
escapeJsonPointer: escapeJsonPointer
};
@@ -144,31 +145,40 @@ function cleanUpCode(out) {
}
-var ERRORS_REGEXP = /[^v\.]errors/g
+var ERRORS_REGEXP = /[^v.]errors/g
, REMOVE_ERRORS = /var errors = 0;|var vErrors = null;|validate.errors = vErrors;/g
, REMOVE_ERRORS_ASYNC = /var errors = 0;|var vErrors = null;/g
, RETURN_VALID = 'return errors === 0;'
, RETURN_TRUE = 'validate.errors = null; return true;'
- , RETURN_ASYNC = /if \(errors === 0\) return true;\s*else throw new ValidationError\(vErrors\);/
- , RETURN_TRUE_ASYNC = 'return true;';
+ , RETURN_ASYNC = /if \(errors === 0\) return data;\s*else throw new ValidationError\(vErrors\);/
+ , RETURN_DATA_ASYNC = 'return data;'
+ , ROOTDATA_REGEXP = /[^A-Za-z_$]rootData[^A-Za-z0-9_$]/g
+ , REMOVE_ROOTDATA = /if \(rootData === undefined\) rootData = data;/;
-function cleanUpVarErrors(out, async) {
+function finalCleanUpCode(out, async) {
var matches = out.match(ERRORS_REGEXP);
- if (!matches || matches.length !== 2) return out;
- return async
+ if (matches && matches.length == 2) {
+ out = async
? out.replace(REMOVE_ERRORS_ASYNC, '')
- .replace(RETURN_ASYNC, RETURN_TRUE_ASYNC)
+ .replace(RETURN_ASYNC, RETURN_DATA_ASYNC)
: out.replace(REMOVE_ERRORS, '')
.replace(RETURN_VALID, RETURN_TRUE);
+ }
+
+ matches = out.match(ROOTDATA_REGEXP);
+ if (!matches || matches.length !== 3) return out;
+ return out.replace(REMOVE_ROOTDATA, '');
}
function schemaHasRules(schema, rules) {
+ if (typeof schema == 'boolean') return !schema;
for (var key in schema) if (rules[key]) return true;
}
function schemaHasRulesExcept(schema, rules, exceptKeyword) {
+ if (typeof schema == 'boolean') return !schema && exceptKeyword != 'not';
for (var key in schema) if (key != exceptKeyword && rules[key]) return true;
}
diff --git a/node_modules/ajv/lib/compile/validation_error.js b/node_modules/ajv/lib/compile/validation_error.js
deleted file mode 100644
index 3c5c59478..000000000
--- a/node_modules/ajv/lib/compile/validation_error.js
+++ /dev/null
@@ -1,14 +0,0 @@
-'use strict';
-
-module.exports = ValidationError;
-
-
-function ValidationError(errors) {
- this.message = 'validation failed';
- this.errors = errors;
- this.ajv = this.validation = true;
-}
-
-
-ValidationError.prototype = Object.create(Error.prototype);
-ValidationError.prototype.constructor = ValidationError;