Update checked-in dependencies
This commit is contained in:
parent
5f6ba88b4b
commit
67954db0cf
9 changed files with 526 additions and 164 deletions
99
node_modules/jsonschema/lib/helpers.js
generated
vendored
99
node_modules/jsonschema/lib/helpers.js
generated
vendored
|
|
@ -2,21 +2,23 @@
|
|||
|
||||
var uri = require('url');
|
||||
|
||||
var ValidationError = exports.ValidationError = function ValidationError (message, instance, schema, propertyPath, name, argument) {
|
||||
if (propertyPath) {
|
||||
this.property = propertyPath;
|
||||
var ValidationError = exports.ValidationError = function ValidationError (message, instance, schema, path, name, argument) {
|
||||
if(Array.isArray(path)){
|
||||
this.path = path;
|
||||
this.property = path.reduce(function(sum, item){
|
||||
return sum + makeSuffix(item);
|
||||
}, 'instance');
|
||||
}else if(path !== undefined){
|
||||
this.property = path;
|
||||
}
|
||||
if (message) {
|
||||
this.message = message;
|
||||
}
|
||||
if (schema) {
|
||||
if (schema.id) {
|
||||
this.schema = schema.id;
|
||||
} else {
|
||||
this.schema = schema;
|
||||
}
|
||||
var id = schema.$id || schema.id;
|
||||
this.schema = id || schema;
|
||||
}
|
||||
if (instance) {
|
||||
if (instance !== undefined) {
|
||||
this.instance = instance;
|
||||
}
|
||||
this.name = name;
|
||||
|
|
@ -31,27 +33,33 @@ ValidationError.prototype.toString = function toString() {
|
|||
var ValidatorResult = exports.ValidatorResult = function ValidatorResult(instance, schema, options, ctx) {
|
||||
this.instance = instance;
|
||||
this.schema = schema;
|
||||
this.options = options;
|
||||
this.path = ctx.path;
|
||||
this.propertyPath = ctx.propertyPath;
|
||||
this.errors = [];
|
||||
this.throwError = options && options.throwError;
|
||||
this.throwFirst = options && options.throwFirst;
|
||||
this.throwAll = options && options.throwAll;
|
||||
this.disableFormat = options && options.disableFormat === true;
|
||||
};
|
||||
|
||||
ValidatorResult.prototype.addError = function addError(detail) {
|
||||
var err;
|
||||
if (typeof detail == 'string') {
|
||||
err = new ValidationError(detail, this.instance, this.schema, this.propertyPath);
|
||||
err = new ValidationError(detail, this.instance, this.schema, this.path);
|
||||
} else {
|
||||
if (!detail) throw new Error('Missing error detail');
|
||||
if (!detail.message) throw new Error('Missing error message');
|
||||
if (!detail.name) throw new Error('Missing validator type');
|
||||
err = new ValidationError(detail.message, this.instance, this.schema, this.propertyPath, detail.name, detail.argument);
|
||||
err = new ValidationError(detail.message, this.instance, this.schema, this.path, detail.name, detail.argument);
|
||||
}
|
||||
|
||||
if (this.throwError) {
|
||||
this.errors.push(err);
|
||||
if (this.throwFirst) {
|
||||
throw new ValidatorResultError(this);
|
||||
}else if(this.throwError){
|
||||
throw err;
|
||||
}
|
||||
this.errors.push(err);
|
||||
return err;
|
||||
};
|
||||
|
||||
|
|
@ -74,6 +82,20 @@ Object.defineProperty(ValidatorResult.prototype, "valid", { get: function() {
|
|||
return !this.errors.length;
|
||||
} });
|
||||
|
||||
module.exports.ValidatorResultError = ValidatorResultError;
|
||||
function ValidatorResultError(result) {
|
||||
if(Error.captureStackTrace){
|
||||
Error.captureStackTrace(this, ValidatorResultError);
|
||||
}
|
||||
this.instance = result.instance;
|
||||
this.schema = result.schema;
|
||||
this.options = result.options;
|
||||
this.errors = result.errors;
|
||||
}
|
||||
ValidatorResultError.prototype = new Error();
|
||||
ValidatorResultError.prototype.constructor = ValidatorResultError;
|
||||
ValidatorResultError.prototype.name = "Validation Error";
|
||||
|
||||
/**
|
||||
* Describes a problem with a Schema which prevents validation of an instance
|
||||
* @name SchemaError
|
||||
|
|
@ -86,14 +108,22 @@ var SchemaError = exports.SchemaError = function SchemaError (msg, schema) {
|
|||
Error.captureStackTrace(this, SchemaError);
|
||||
};
|
||||
SchemaError.prototype = Object.create(Error.prototype,
|
||||
{ constructor: {value: SchemaError, enumerable: false}
|
||||
, name: {value: 'SchemaError', enumerable: false}
|
||||
{
|
||||
constructor: {value: SchemaError, enumerable: false},
|
||||
name: {value: 'SchemaError', enumerable: false},
|
||||
});
|
||||
|
||||
var SchemaContext = exports.SchemaContext = function SchemaContext (schema, options, propertyPath, base, schemas) {
|
||||
var SchemaContext = exports.SchemaContext = function SchemaContext (schema, options, path, base, schemas) {
|
||||
this.schema = schema;
|
||||
this.options = options;
|
||||
this.propertyPath = propertyPath;
|
||||
if(Array.isArray(path)){
|
||||
this.path = path;
|
||||
this.propertyPath = path.reduce(function(sum, item){
|
||||
return sum + makeSuffix(item);
|
||||
}, 'instance');
|
||||
}else{
|
||||
this.propertyPath = path;
|
||||
}
|
||||
this.base = base;
|
||||
this.schemas = schemas;
|
||||
};
|
||||
|
|
@ -103,14 +133,15 @@ SchemaContext.prototype.resolve = function resolve (target) {
|
|||
};
|
||||
|
||||
SchemaContext.prototype.makeChild = function makeChild(schema, propertyName){
|
||||
var propertyPath = (propertyName===undefined) ? this.propertyPath : this.propertyPath+makeSuffix(propertyName);
|
||||
var base = uri.resolve(this.base, schema.id||'');
|
||||
var ctx = new SchemaContext(schema, this.options, propertyPath, base, Object.create(this.schemas));
|
||||
if(schema.id && !ctx.schemas[base]){
|
||||
var path = (propertyName===undefined) ? this.path : this.path.concat([propertyName]);
|
||||
var id = schema.$id || schema.id;
|
||||
var base = uri.resolve(this.base, id||'');
|
||||
var ctx = new SchemaContext(schema, this.options, path, base, Object.create(this.schemas));
|
||||
if(id && !ctx.schemas[base]){
|
||||
ctx.schemas[base] = schema;
|
||||
}
|
||||
return ctx;
|
||||
}
|
||||
};
|
||||
|
||||
var FORMAT_REGEXPS = exports.FORMAT_REGEXPS = {
|
||||
'date-time': /^\d{4}-(?:0[0-9]{1}|1[0-2]{1})-(3[01]|0[1-9]|[12][0-9])[tT ](2[0-4]|[01][0-9]):([0-5][0-9]):(60|[0-5][0-9])(\.\d+)?([zZ]|[+-]([0-5][0-9]):(60|[0-5][0-9]))$/,
|
||||
|
|
@ -120,7 +151,11 @@ var FORMAT_REGEXPS = exports.FORMAT_REGEXPS = {
|
|||
'email': /^(?:[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+\.)*[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|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*)?[/?]|[!$&-.0-;=?-Z_a-z~])(%[0-9A-Fa-f]{2}|[!$&-;=?-Z_a-z~])*|\/((%[0-9A-Fa-f]{2}|[!$&-.0-9;=A-Z_a-z~])+(:\d*)?|(\[(([Vv][0-9A-Fa-f]+\.[!$&-.0-;=A-Z_a-z~]+)?|[.0-:A-Fa-f]+)\])?:\d*|\[(([Vv][0-9A-Fa-f]+\.[!$&-.0-;=A-Z_a-z~]+)?|[.0-:A-Fa-f]+)\])?)?|[A-Za-z][+\-.0-9A-Za-z]*:?)?$/,
|
||||
|
||||
'color': /^(#?([0-9A-Fa-f]{3}){1,2}\b|aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|purple|red|silver|teal|white|yellow|(rgb\(\s*\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\b\s*,\s*\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\b\s*,\s*\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\b\s*\))|(rgb\(\s*(\d?\d%|100%)+\s*,\s*(\d?\d%|100%)+\s*,\s*(\d?\d%|100%)+\s*\)))$/,
|
||||
|
||||
|
|
@ -143,7 +178,7 @@ var FORMAT_REGEXPS = exports.FORMAT_REGEXPS = {
|
|||
return result;
|
||||
},
|
||||
'style': /\s*(.+?):\s*([^;]+);?/,
|
||||
'phone': /^\+(?:[0-9] ?){6,14}[0-9]$/
|
||||
'phone': /^\+(?:[0-9] ?){6,14}[0-9]$/,
|
||||
};
|
||||
|
||||
FORMAT_REGEXPS.regexp = FORMAT_REGEXPS.regex;
|
||||
|
|
@ -212,10 +247,10 @@ exports.deepCompareStrict = function deepCompareStrict (a, b) {
|
|||
|
||||
function deepMerger (target, dst, e, i) {
|
||||
if (typeof e === 'object') {
|
||||
dst[i] = deepMerge(target[i], e)
|
||||
dst[i] = deepMerge(target[i], e);
|
||||
} else {
|
||||
if (target.indexOf(e) === -1) {
|
||||
dst.push(e)
|
||||
dst.push(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -232,7 +267,7 @@ function copyistWithDeepMerge (target, src, dst, key) {
|
|||
if (!target[key]) {
|
||||
dst[key] = src[key];
|
||||
} else {
|
||||
dst[key] = deepMerge(target[key], src[key])
|
||||
dst[key] = deepMerge(target[key], src[key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -253,7 +288,7 @@ function deepMerge (target, src) {
|
|||
}
|
||||
|
||||
return dst;
|
||||
};
|
||||
}
|
||||
|
||||
module.exports.deepMerge = deepMerge;
|
||||
|
||||
|
|
@ -284,9 +319,9 @@ function pathEncoder (v) {
|
|||
* @return {String}
|
||||
*/
|
||||
exports.encodePath = function encodePointer(a){
|
||||
// ~ must be encoded explicitly because hacks
|
||||
// the slash is encoded by encodeURIComponent
|
||||
return a.map(pathEncoder).join('');
|
||||
// ~ must be encoded explicitly because hacks
|
||||
// the slash is encoded by encodeURIComponent
|
||||
return a.map(pathEncoder).join('');
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -323,3 +358,7 @@ exports.getDecimalPlaces = function getDecimalPlaces(number) {
|
|||
return decimalPlaces;
|
||||
};
|
||||
|
||||
exports.isSchema = function isSchema(val){
|
||||
return (typeof val === 'object' && val) || (typeof val === 'boolean');
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue