commit node_modules and generated files
This commit is contained in:
parent
6d7a135fea
commit
34b372292b
3379 changed files with 449603 additions and 2029 deletions
30
node_modules/schema-utils/src/ValidationError.js
generated
vendored
Normal file
30
node_modules/schema-utils/src/ValidationError.js
generated
vendored
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
/* eslint-disable
|
||||
strict,
|
||||
no-param-reassign
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
class ValidationError extends Error {
|
||||
constructor(errors, name) {
|
||||
super();
|
||||
|
||||
this.name = 'ValidationError';
|
||||
|
||||
this.message = `${name || ''} Invalid Options\n\n`;
|
||||
|
||||
this.errors = errors.map((err) => {
|
||||
err.dataPath = err.dataPath.replace(/\//g, '.');
|
||||
|
||||
return err;
|
||||
});
|
||||
|
||||
this.errors.forEach((err) => {
|
||||
this.message += `options${err.dataPath} ${err.message}\n`;
|
||||
});
|
||||
|
||||
Error.captureStackTrace(this, this.constructor);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = ValidationError;
|
||||
9
node_modules/schema-utils/src/index.js
generated
vendored
Normal file
9
node_modules/schema-utils/src/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
/* eslint-disable
|
||||
strict
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const validateOptions = require('./validateOptions');
|
||||
|
||||
module.exports = validateOptions;
|
||||
38
node_modules/schema-utils/src/validateOptions.js
generated
vendored
Normal file
38
node_modules/schema-utils/src/validateOptions.js
generated
vendored
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
/* eslint-disable
|
||||
strict,
|
||||
no-param-reassign
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const Ajv = require('ajv');
|
||||
const errors = require('ajv-errors');
|
||||
const keywords = require('ajv-keywords');
|
||||
|
||||
const ValidationError = require('./ValidationError');
|
||||
|
||||
const ajv = new Ajv({
|
||||
allErrors: true,
|
||||
jsonPointers: true,
|
||||
});
|
||||
|
||||
errors(ajv);
|
||||
keywords(ajv, ['instanceof', 'typeof']);
|
||||
|
||||
const validateOptions = (schema, options, name) => {
|
||||
if (typeof schema === 'string') {
|
||||
schema = fs.readFileSync(path.resolve(schema), 'utf8');
|
||||
schema = JSON.parse(schema);
|
||||
}
|
||||
|
||||
if (!ajv.validate(schema, options)) {
|
||||
throw new ValidationError(ajv.errors, name);
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
module.exports = validateOptions;
|
||||
Loading…
Add table
Add a link
Reference in a new issue