diff options
Diffstat (limited to 'node_modules/ajv-errors')
-rw-r--r-- | node_modules/ajv-errors/LICENSE | 21 | ||||
-rw-r--r-- | node_modules/ajv-errors/README.md | 318 | ||||
-rw-r--r-- | node_modules/ajv-errors/index.js | 48 | ||||
-rw-r--r-- | node_modules/ajv-errors/lib/dot/errorMessage.jst | 372 | ||||
-rw-r--r-- | node_modules/ajv-errors/lib/dotjs/README.md | 3 | ||||
-rw-r--r-- | node_modules/ajv-errors/lib/dotjs/errorMessage.js | 315 | ||||
-rw-r--r-- | node_modules/ajv-errors/package.json | 85 |
7 files changed, 0 insertions, 1162 deletions
diff --git a/node_modules/ajv-errors/LICENSE b/node_modules/ajv-errors/LICENSE deleted file mode 100644 index 7f15435..0000000 --- a/node_modules/ajv-errors/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2017 Evgeny Poberezkin - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/node_modules/ajv-errors/README.md b/node_modules/ajv-errors/README.md deleted file mode 100644 index 92118a4..0000000 --- a/node_modules/ajv-errors/README.md +++ /dev/null @@ -1,318 +0,0 @@ -# ajv-errors -Custom error messages in JSON-Schema for Ajv validator - -[](https://travis-ci.org/epoberezkin/ajv-errors) -[](http://badge.fury.io/js/ajv-errors) -[](https://coveralls.io/github/epoberezkin/ajv-errors?branch=master) -[](https://gitter.im/ajv-validator/ajv) - - -## Contents - -- [Install](#install) -- [Usage](#usage) - - [Single message](#single-message) - - [Messages for keywords](#messages-for-keywords) - - [Messages for properties and items](#messages-for-properties-and-items) - - [Default message](#default-message) -- [Templates](#templates) -- [Options](#options) -- [License](#license) - - -## Install - -``` -npm install ajv-errors -``` - - -## Usage - -Add the keyword `errorMessages` to Ajv instance: - -```javascript -var Ajv = require('ajv'); -var ajv = new Ajv({allErrors: true, jsonPointers: true}); -// Ajv options allErrors and jsonPointers are required -require('ajv-errors')(ajv /*, {singleError: true} */); -``` - -See [Options](#options) below. - - -### Single message - -Replace all errors in the current schema and subschemas with a single message: - -```javascript -var schema = { - type: 'object', - required: ['foo'], - properties: { - foo: { type: 'integer' } - }, - additionalProperties: false, - errorMessage: 'should be an object with an integer property foo only' -}; - -var validate = ajv.compile(schema); -console.log(validate({foo: 'a', bar: 2})); // false -console.log(validate.errors); // processed errors -``` - -Processed errors: - -```javascript -[ - { - keyword: 'errorMessage', - message: 'should be an object with an integer property foo only', - // ... - params: { - errors: [ - { keyword: 'additionalProperties', dataPath: '' /* , ... */ }, - { keyword: 'type', dataPath: '.foo' /* , ... */ } - ] - } - } -] -``` - - -### Messages for keywords - -Replace errors for certain keywords in the current schema only: - -```javascript -var schema = { - type: 'object', - required: ['foo'], - properties: { - foo: { type: 'integer' } - }, - additionalProperties: false, - errorMessage: { - type: 'should be an object', // will not replace internal "type" error for the property "foo" - required: 'should have property foo', - additionalProperties: 'should not have properties other than foo' - } -}; - -var validate = ajv.compile(schema); -console.log(validate({foo: 'a', bar: 2})); // false -console.log(validate.errors); // processed errors -``` - -Processed errors: - -```javascript -[ - { - // original error - keyword: type, - dataPath: '/foo', - // ... - message: 'should be integer' - }, - { - // generated error - keyword: 'errorMessage', - message: 'should not have properties other than foo', - // ... - params: { - errors: [ - { keyword: 'additionalProperties' /* , ... */ } - ] - }, - } -] -``` - -For keywords "required" and "dependencies" it is possible to specify different messages for different properties: - -```javascript -var schema = { - type: 'object', - required: ['foo', 'bar'], - properties: { - foo: { type: 'integer' }, - bar: { type: 'string' } - }, - errorMessage: { - type: 'should be an object', // will not replace internal "type" error for the property "foo" - required: { - foo: 'should have an integer property "foo"', - bar: 'should have a string property "bar"' - } - } -}; -``` - - -### Messages for properties and items - -Replace errors for properties / items (and deeper), regardless where in schema they were created: - -```javascript -var schema = { - type: 'object', - required: ['foo', 'bar'], - allOf: [{ - properties: { - foo: { type: 'integer', minimum: 2 }, - bar: { type: 'string', minLength: 2 } - }, - additionalProperties: false - }], - errorMessage: { - properties: { - foo: 'data.foo should be integer >= 2', - bar: 'data.bar should be string with length >= 2' - } - } -}; - -var validate = ajv.compile(schema); -console.log(validate({foo: 1, bar: 'a'})); // false -console.log(validate.errors); // processed errors -``` - -Processed errors: - -```javascript -[ - { - keyword: 'errorMessage', - message: 'data.foo should be integer >= 2', - dataPath: '/foo', - // ... - params: { - errors: [ - { keyword: 'minimum' /* , ... */ } - ] - }, - }, - { - keyword: 'errorMessage', - message: 'data.bar should be string with length >= 2', - dataPath: '/bar', - // ... - params: { - errors: [ - { keyword: 'minLength' /* , ... */ } - ] - }, - } -] -``` - - -### Default message - -When the value of keyword `errorMessage` is an object you can specify a message that will be used if any error appears that is not specified by keywords/properties/items: - -```javascript -var schema = { - type: 'object', - required: ['foo', 'bar'], - allOf: [{ - properties: { - foo: { type: 'integer', minimum: 2 }, - bar: { type: 'string', minLength: 2 } - }, - additionalProperties: false - }], - errorMessage: { - type: 'data should be an object', - properties: { - foo: 'data.foo should be integer >= 2', - bar: 'data.bar should be string with length >= 2' - }, - _: 'data should have properties "foo" and "bar" only' - } -}; - -var validate = ajv.compile(schema); -console.log(validate({})); // false -console.log(validate.errors); // processed errors -``` - -Processed errors: - -```javascript -[ - { - keyword: 'errorMessage', - message: 'data should be an object with properties "foo" and "bar" only', - dataPath: '', - // ... - params: { - errors: [ - { keyword: 'required' /* , ... */ }, - { keyword: 'required' /* , ... */ } - ] - }, - } -] -``` - -The message in property `_` of `errorMessage` replaces the same errors that would have been replaced if `errorMessage` were a string. - - -## Templates - -Custom error messages used in `errorMessage` keyword can be templates using [JSON-pointers](https://tools.ietf.org/html/rfc6901) or [relative JSON-pointers](http://tools.ietf.org/html/draft-luff-relative-json-pointer-00) to data being validated, in which case the value will be interpolated. Also see [examples](https://gist.github.com/geraintluff/5911303) of relative JSON-pointers. - -The syntax to interpolate a value is `${<pointer>}`. - -The values used in messages will be JSON-stringified: -- to differentiate between `false` and `"false"`, etc. -- to support structured values. - -Example: - -```json -{ - "type": "object", - "properties": { - "size": { - "type": "number", - "minimum": 4 - } - }, - "errorMessage": { - "properties": { - "size": "size should be a number bigger or equal to 4, current value is ${/size}" - } - } -} -``` - - -## Options - -Defaults: - -```javascript -{ - keepErrors: false, - singleError: false -} -``` - -- _keepErrors_: keep original errors. Default is to remove matched errors (they will still be available in `params.errors` property of generated error). If an error was matched and included in the error generated by `errorMessage` keyword it will have property `emUsed: true`. -- _singleError_: create one error for all keywords used in `errorMessage` keyword (error messages defined for properties and items are not merged because they have different dataPaths). Multiple error messages are concatenated. Option values: - - `false` (default): create multiple errors, one for each message - - `true`: create single error, messages are concatenated using `"; "` - - non-empty string: this string is used as a separator to concatenate messages - - -## Supporters - -[<img src="https://media.licdn.com/mpr/mpr/shrinknp_400_400/AAEAAQAAAAAAAAwEAAAAJDg1YzBlYzFjLTA3YWYtNGEzOS1iMTdjLTQ0MTU1NWZjOGM0ZQ.jpg" width="48" height="48">](https://www.linkedin.com/in/rogerkepler/) [Roger Kepler](https://www.linkedin.com/in/rogerkepler/) - - -## License - -[MIT](https://github.com/epoberezkin/ajv-errors/blob/master/LICENSE) diff --git a/node_modules/ajv-errors/index.js b/node_modules/ajv-errors/index.js deleted file mode 100644 index 423eb23..0000000 --- a/node_modules/ajv-errors/index.js +++ /dev/null @@ -1,48 +0,0 @@ -'use strict'; - -module.exports = function (ajv, options) { - if (!ajv._opts.allErrors) throw new Error('ajv-errors: Ajv option allErrors must be true'); - if (!ajv._opts.jsonPointers) { - console.warn('ajv-errors: Ajv option jsonPointers changed to true'); - ajv._opts.jsonPointers = true; - } - - ajv.addKeyword('errorMessage', { - inline: require('./lib/dotjs/errorMessage'), - statements: true, - valid: true, - errors: 'full', - config: { - KEYWORD_PROPERTY_PARAMS: { - required: 'missingProperty', - dependencies: 'property' - }, - options: options || {} - }, - metaSchema: { - 'type': ['string', 'object'], - properties: { - properties: {$ref: '#/definitions/stringMap'}, - items: {$ref: '#/definitions/stringList'}, - required: {$ref: '#/definitions/stringOrMap'}, - dependencies: {$ref: '#/definitions/stringOrMap'} - }, - additionalProperties: {'type': 'string'}, - definitions: { - stringMap: { - 'type': ['object'], - additionalProperties: {'type': 'string'} - }, - stringOrMap: { - 'type': ['string', 'object'], - additionalProperties: {'type': 'string'} - }, - stringList: { - 'type': ['array'], - items: {'type': 'string'} - } - } - } - }); - return ajv; -}; diff --git a/node_modules/ajv-errors/lib/dot/errorMessage.jst b/node_modules/ajv-errors/lib/dot/errorMessage.jst deleted file mode 100644 index 60cf89d..0000000 --- a/node_modules/ajv-errors/lib/dot/errorMessage.jst +++ /dev/null @@ -1,372 +0,0 @@ -{{# def.definitions }} -{{# def.errors }} -{{# def.setupKeyword }} - -{{## def.em_errorMatch: - {{# def._em_commonErrorMatch }} - && ({{=$err}}.dataPath == {{=$dataPath}} || - ({{=$err}}.dataPath.indexOf({{=$dataPath}}) == 0 && - {{=$err}}.dataPath[{{=$dataPath}}.length] == '/')) - && {{=$err}}.schemaPath.indexOf({{=$errSchemaPathString}}) == 0 - && {{=$err}}.schemaPath[{{=it.errSchemaPath.length}}] == '/' -#}} - -{{## def.em_keywordErrorMatch: - {{# def._em_commonErrorMatch }} - && {{=$err}}.keyword in {{=$errors}} - && {{=$err}}.dataPath == {{=$dataPath}} - && {{=$err}}.schemaPath.indexOf({{=$errSchemaPathString}}) == 0 - && /^\/[^\/]*$/.test({{=$err}}.schemaPath.slice({{=it.errSchemaPath.length}})) -#}} - -{{## def.em_childErrorMatch: - {{# def._em_commonErrorMatch }} - && {{=$err}}.dataPath.indexOf({{=$dataPath}}) == 0 - && ({{=$matches}} = {{=$err}}.dataPath.slice({{=$dataPath}}.length).match(/^\/([^\/]*)(?:\/|$)/), - {{=$child}} = {{=$matches}} && {{=$matches}}[1].replace(/~1/g, '/').replace(/~0/g, '~') - ) !== undefined - && {{=$child}} in {{=$errors}} -#}} - -{{## def._em_commonErrorMatch: - {{=$err}}.keyword != '{{=$keyword}}' - {{? $config.options.keepErrors }} - && !{{=$err}}.emUsed - {{?}} -#}} - -{{## def.em_useError: - {{? $config.options.keepErrors }} - {{=$err}}.emUsed = true; - {{??}} - vErrors.splice({{=$i}}, 1); - errors--; - {{?}} -#}} - -{{## def.em_compileTemplates: _keysArray: - var {{=$templates}} = { - {{ var $comma = false; }} - {{~ _keysArray:$k }} - {{? INTERPOLATION.test($schema[$k]) }} - {{?$comma}},{{?}}{{= it.util.toQuotedString($k) }}: {{= templateFunc($schema[$k]) }} - {{ $comma = true; }} - {{?}} - {{~}} - }; -#}} - -{{## def.em_compilePropsTemplates: _keywordProps: - var {{=$templates}} = { - {{ var $comma = false; }} - {{~ Object.keys(_keywordProps):$k }} - {{ var $keywordMsgs = $schema[$k]; }} - {{?$comma}},{{?}}{{= it.util.toQuotedString($k) }}: { - {{ $comma = true; var $innerComma = false; }} - {{~ Object.keys($keywordMsgs):$prop }} - {{? INTERPOLATION.test($keywordMsgs[$prop]) }} - {{?$innerComma}},{{?}}{{= it.util.toQuotedString($prop) }}: {{= templateFunc($keywordMsgs[$prop]) }} - {{ $innerComma = true; }} - {{?}} - {{~}} - } - {{~}} - }; -#}} - -{{## def.em_compileChildTemplates: _children: - {{ var _keysArray = Object.keys($childErrors._children); }} - var {{=$templates}} = { - {{ var $comma = false; }} - {{~ _keysArray:$k }} - {{? INTERPOLATION.test($schema._children[$k]) }} - {{?$comma}},{{?}}{{= it.util.toQuotedString($k) }}: {{= templateFunc($schema._children[$k]) }} - {{ $comma = true; }} - {{?}} - {{~}} - }; -#}} - -{{## def.em_errorMessage: - {{=$key}} in {{=$templates}} - ? {{=$templates}}[{{=$key}}] () - : validate.schema{{=$schemaPath}}[{{=$key}}] -#}} - -{{## def.em_keywordError: - var err = { - keyword: '{{=$keyword}}' - , dataPath: {{=$dataPath}} - , schemaPath: {{=$errSchemaPathString}} + '/{{=$keyword}}' - , params: { errors: {{=$paramsErrors}} } - , message: {{=$message}} - {{? it.opts.verbose }} - , schema: validate.schema{{=$schemaPath}} - , parentSchema: validate.schema{{=it.schemaPath}} - , data: {{=$data}} - {{?}} - }; - {{# def._addError:'custom' }} -#}} - - -{{? it.createErrors !== false }} - {{ - var INTERPOLATION = /\$\{[^\}]+\}/; - var INTERPOLATION_REPLACE = /\$\{([^\}]+)\}/g; - var EMPTY_STR = /^\'\'\s*\+\s*|\s*\+\s*\'\'$/g; - - var $config = it.self.getKeyword($keyword).config - , $dataPath = '_em_dataPath' + $lvl - , $i = '_em_i' + $lvl - , $key = '_em_key' + $lvl - , $keyProp = '_em_keyProp' + $lvl - , $err = '_em_err' + $lvl - , $child = '_em_child' + $lvl - , $childKeyword = '_em_childKeyword' + $lvl - , $matches = '_em_matches' + $lvl - , $isArray = '_em_isArray' + $lvl - , $errors = '_em_errors' + $lvl - , $message = '_em_message' + $lvl - , $paramsErrors = '_em_paramsErrors' + $lvl - , $propParam = '_em_propParam' + $lvl - , $keywordPropParams = '_em_keywordPropParams' + $lvl - , $templates = '_em_templates' + $lvl - , $errSchemaPathString = it.util.toQuotedString(it.errSchemaPath); - }} - - if (errors > 0) { - var {{=$dataPath}} = (dataPath || '') + {{= it.errorPath }}; - var {{=$i}}, {{=$err}}, {{=$errors}}; - - {{? typeof $schema == 'object' }} - {{ - var $keywordErrors = {} - , $keywordPropErrors = {} - , $childErrors = { properties: {}, items: {} } - , $hasKeywordProps = false - , $hasProperties = false - , $hasItems = false; - - for (var $k in $schema) { - switch ($k) { - case 'properties': - for (var $prop in $schema.properties) { - $hasProperties = true; - $childErrors.properties[$prop] = []; - } - break; - case 'items': - for (var $item=0; $item<$schema.items.length; $item++) { - $hasItems = true; - $childErrors.items[$item] = []; - } - break; - default: - if (typeof $schema[$k] == 'object') { - $hasKeywordProps = true; - $keywordPropErrors[$k] = {}; - for (var $prop in $schema[$k]) { - $keywordPropErrors[$k][$prop] = []; - } - } else { - $keywordErrors[$k] = []; - } - } - } - }} - - {{ var $keywordErrorsArr = Object.keys($keywordErrors); }} - {{? $keywordErrorsArr.length }} - {{=$i}} = 0; - {{=$errors}} = {{= JSON.stringify($keywordErrors) }}; - {{# def.em_compileTemplates:$keywordErrorsArr }} - while ({{=$i}} < errors) { - {{=$err}} = vErrors[{{=$i}}]; - if ({{# def.em_keywordErrorMatch}}) { - {{=$errors}}[{{=$err}}.keyword].push({{=$err}}); - {{# def.em_useError }} - } else { - {{=$i}}++; - } - } - - {{? $config.options.singleError }} - var {{=$message}} = ''; - var {{=$paramsErrors}} = []; - {{?}} - - for (var {{=$key}} in {{=$errors}}) { - if ({{=$errors}}[{{=$key}}].length) { - - {{? $config.options.singleError }} - if ({{=$message}}) { - {{=$message}} += {{? typeof $config.options.singleError == 'string' }} - {{= it.util.toQuotedString($config.options.singleError) }} - {{??}} - '; ' - {{?}}; - } - {{=$message}} += {{# def.em_errorMessage }}; - {{=$paramsErrors}} = {{=$paramsErrors}}.concat({{=$errors}}[{{=$key}}]); - } - } - {{??}} - var {{=$message}} = {{# def.em_errorMessage }}; - var {{=$paramsErrors}} = {{=$errors}}[{{=$key}}]; - {{?}} - - {{# def.em_keywordError}} - - {{? !$config.options.singleError }} - } - } - {{?}} - {{?}} /* $keywordErrorsArr */ - - {{? $hasKeywordProps }} - {{=$i}} = 0; - {{=$errors}} = {{= JSON.stringify($keywordPropErrors) }}; - var {{=$paramsErrors}}, {{=$propParam}}; - var {{=$keywordPropParams}} = {{= JSON.stringify($config.KEYWORD_PROPERTY_PARAMS) }}; - {{# def.em_compilePropsTemplates:$keywordPropErrors }} - - while ({{=$i}} < errors) { - {{=$err}} = vErrors[{{=$i}}]; - if ({{# def.em_keywordErrorMatch}}) { - {{=$propParam}} = {{=$keywordPropParams}}[{{=$err}}.keyword]; - {{=$paramsErrors}} = {{=$errors}}[{{=$err}}.keyword][{{=$err}}.params[{{=$propParam}}]]; - if ({{=$paramsErrors}}) { - {{=$paramsErrors}}.push({{=$err}}); - {{# def.em_useError }} - } else { - {{=$i}}++; - } - } else { - {{=$i}}++; - } - } - - for (var {{=$key}} in {{=$errors}}) { - for (var {{=$keyProp}} in {{=$errors}}[{{=$key}}]) { - {{=$paramsErrors}} = {{=$errors}}[{{=$key}}][{{=$keyProp}}]; - if ({{=$paramsErrors}}.length) { - var {{=$message}} = {{=$key}} in {{=$templates}} && {{=$keyProp}} in {{=$templates}}[{{=$key}}] - ? {{=$templates}}[{{=$key}}][{{=$keyProp}}] () - : validate.schema{{=$schemaPath}}[{{=$key}}][{{=$keyProp}}]; - {{# def.em_keywordError}} - } - } - } - {{?}} /* $hasKeywordProps */ - - {{? $hasProperties || $hasItems }} - var {{=$isArray}} = Array.isArray({{=$data}}); - if - {{? $hasProperties && $hasItems }} - (typeof {{=$data}} == 'object') { - {{ var $childProp = '[' + $childKeyword + ']'; }} - {{=$i}} = 0; - if ({{=$isArray}}) { - var {{=$childKeyword}} = 'items'; - {{=$errors}} = {{= JSON.stringify($childErrors.items) }}; - {{# def.em_compileChildTemplates: items }} - } else { - var {{=$childKeyword}} = 'properties'; - {{=$errors}} = {{= JSON.stringify($childErrors.properties) }}; - {{# def.em_compileChildTemplates: properties }} - } - {{?? $hasProperties }} - (typeof {{=$data}} == 'object' && !{{=$isArray}}) { - {{ var $childProp = '.properties'; }} - {{=$i}} = 0; - {{=$errors}} = {{= JSON.stringify($childErrors.properties) }}; - {{# def.em_compileChildTemplates: properties }} - {{??}} - ({{=$isArray}}) { - {{ var $childProp = '.items'; }} - {{=$i}} = 0; - {{=$errors}} = {{= JSON.stringify($childErrors.items) }}; - {{# def.em_compileChildTemplates: items }} - {{?}} - - var {{=$child}}, {{=$matches}}; - while ({{=$i}} < errors) { - {{=$err}} = vErrors[{{=$i}}]; - if ({{# def.em_childErrorMatch}}) { - {{=$errors}}[{{=$child}}].push({{=$err}}); - {{# def.em_useError }} - } else { - {{=$i}}++; - } - } - for (var {{=$key}} in {{=$errors}}) { - if ({{=$errors}}[{{=$key}}].length) { - var err = { - keyword: '{{=$keyword}}' - , dataPath: {{=$dataPath}} + '/' + {{=$key}}.replace(/~/g, '~0').replace(/\//g, '~1') - , schemaPath: {{=$errSchemaPathString}} + '/{{=$keyword}}' - , params: { errors: {{=$errors}}[{{=$key}}] } - , message: {{=$key}} in {{=$templates}} - ? {{=$templates}}[{{=$key}}] () - : validate.schema{{=$schemaPath}}{{=$childProp}}[{{=$key}}] - {{? it.opts.verbose }} - , schema: validate.schema{{=$schemaPath}} - , parentSchema: validate.schema{{=it.schemaPath}} - , data: {{=$data}} - {{?}} - }; - {{# def._addError:'custom' }} - } - } /* for */ - } /* if */ - {{?}} /* $hasProperties || $hasItems */ - {{?}} /* $schema is object */ - - {{ var $schemaMessage = typeof $schema == 'string' ? $schema : $schema._; }} - {{? $schemaMessage }} - {{=$i}} = 0; - {{=$errors}} = []; - while ({{=$i}} < errors) { - {{=$err}} = vErrors[{{=$i}}]; - if ({{# def.em_errorMatch}}) { - {{=$errors}}.push({{=$err}}); - {{# def.em_useError }} - } else { - {{=$i}}++; - } - } - if ({{=$errors}}.length) { - var err = { - keyword: '{{=$keyword}}' - , dataPath: {{=$dataPath}} - , schemaPath: {{=$errSchemaPathString}} + '/{{=$keyword}}' - , params: { errors: {{=$errors}} } - , message: {{=templateExpr($schemaMessage)}} - {{? it.opts.verbose }} - , schema: {{=it.util.toQuotedString($schemaMessage)}} - , parentSchema: validate.schema{{=it.schemaPath}} - , data: {{=$data}} - {{?}} - }; - {{# def._addError:'custom' }} - } - {{?}} - } -{{?}} - - -{{ - function templateExpr(str) { - str = it.util.escapeQuotes(str); - if (!INTERPOLATION.test(str)) return "'" + str + "'"; - var expr = "'" + str.replace(INTERPOLATION_REPLACE, function ($0, $1) { - return "' + JSON.stringify(" + it.util.getData($1, $dataLvl, it.dataPathArr) + ") + '"; - }) + "'"; - return expr.replace(EMPTY_STR, ''); - } - - function templateFunc(str) { - return 'function() { return ' + templateExpr(str) + '; }'; - } -}} diff --git a/node_modules/ajv-errors/lib/dotjs/README.md b/node_modules/ajv-errors/lib/dotjs/README.md deleted file mode 100644 index e2846c8..0000000 --- a/node_modules/ajv-errors/lib/dotjs/README.md +++ /dev/null @@ -1,3 +0,0 @@ -These files are compiled dot templates from dot folder. - -Do NOT edit them directly, edit the templates and run `npm run build` from main ajv-keywords folder. diff --git a/node_modules/ajv-errors/lib/dotjs/errorMessage.js b/node_modules/ajv-errors/lib/dotjs/errorMessage.js deleted file mode 100644 index 05d66d9..0000000 --- a/node_modules/ajv-errors/lib/dotjs/errorMessage.js +++ /dev/null @@ -1,315 +0,0 @@ -'use strict'; -module.exports = function generate_errorMessage(it, $keyword, $ruleType) { - var out = ' '; - var $lvl = it.level; - var $dataLvl = it.dataLevel; - var $schema = it.schema[$keyword]; - var $schemaPath = it.schemaPath + it.util.getProperty($keyword); - var $errSchemaPath = it.errSchemaPath + '/' + $keyword; - var $breakOnError = !it.opts.allErrors; - var $data = 'data' + ($dataLvl || ''); - if (it.createErrors !== false) { - var INTERPOLATION = /\$\{[^\}]+\}/; - var INTERPOLATION_REPLACE = /\$\{([^\}]+)\}/g; - var EMPTY_STR = /^\'\'\s*\+\s*|\s*\+\s*\'\'$/g; - var $config = it.self.getKeyword($keyword).config, - $dataPath = '_em_dataPath' + $lvl, - $i = '_em_i' + $lvl, - $key = '_em_key' + $lvl, - $keyProp = '_em_keyProp' + $lvl, - $err = '_em_err' + $lvl, - $child = '_em_child' + $lvl, - $childKeyword = '_em_childKeyword' + $lvl, - $matches = '_em_matches' + $lvl, - $isArray = '_em_isArray' + $lvl, - $errors = '_em_errors' + $lvl, - $message = '_em_message' + $lvl, - $paramsErrors = '_em_paramsErrors' + $lvl, - $propParam = '_em_propParam' + $lvl, - $keywordPropParams = '_em_keywordPropParams' + $lvl, - $templates = '_em_templates' + $lvl, - $errSchemaPathString = it.util.toQuotedString(it.errSchemaPath); - out += ' if (errors > 0) { var ' + ($dataPath) + ' = (dataPath || \'\') + ' + (it.errorPath) + '; var ' + ($i) + ', ' + ($err) + ', ' + ($errors) + '; '; - if (typeof $schema == 'object') { - var $keywordErrors = {}, - $keywordPropErrors = {}, - $childErrors = { - properties: {}, - items: {} - }, - $hasKeywordProps = false, - $hasProperties = false, - $hasItems = false; - for (var $k in $schema) { - switch ($k) { - case 'properties': - for (var $prop in $schema.properties) { - $hasProperties = true; - $childErrors.properties[$prop] = []; - } - break; - case 'items': - for (var $item = 0; $item < $schema.items.length; $item++) { - $hasItems = true; - $childErrors.items[$item] = []; - } - break; - default: - if (typeof $schema[$k] == 'object') { - $hasKeywordProps = true; - $keywordPropErrors[$k] = {}; - for (var $prop in $schema[$k]) { - $keywordPropErrors[$k][$prop] = []; - } - } else { - $keywordErrors[$k] = []; - } - } - } - var $keywordErrorsArr = Object.keys($keywordErrors); - if ($keywordErrorsArr.length) { - out += ' ' + ($i) + ' = 0; ' + ($errors) + ' = ' + (JSON.stringify($keywordErrors)) + '; var ' + ($templates) + ' = { '; - var $comma = false; - var arr1 = $keywordErrorsArr; - if (arr1) { - var $k, i1 = -1, - l1 = arr1.length - 1; - while (i1 < l1) { - $k = arr1[i1 += 1]; - if (INTERPOLATION.test($schema[$k])) { - if ($comma) { - out += ','; - } - out += '' + (it.util.toQuotedString($k)) + ': ' + (templateFunc($schema[$k])) + ' '; - $comma = true; - } - } - } - out += ' }; while (' + ($i) + ' < errors) { ' + ($err) + ' = vErrors[' + ($i) + ']; if ( ' + ($err) + '.keyword != \'' + ($keyword) + '\' '; - if ($config.options.keepErrors) { - out += ' && !' + ($err) + '.emUsed '; - } - out += ' && ' + ($err) + '.keyword in ' + ($errors) + ' && ' + ($err) + '.dataPath == ' + ($dataPath) + ' && ' + ($err) + '.schemaPath.indexOf(' + ($errSchemaPathString) + ') == 0 && /^\\/[^\\/]*$/.test(' + ($err) + '.schemaPath.slice(' + (it.errSchemaPath.length) + '))) { ' + ($errors) + '[' + ($err) + '.keyword].push(' + ($err) + '); '; - if ($config.options.keepErrors) { - out += ' ' + ($err) + '.emUsed = true; '; - } else { - out += ' vErrors.splice(' + ($i) + ', 1); errors--; '; - } - out += ' } else { ' + ($i) + '++; } } '; - if ($config.options.singleError) { - out += ' var ' + ($message) + ' = \'\'; var ' + ($paramsErrors) + ' = []; '; - } - out += ' for (var ' + ($key) + ' in ' + ($errors) + ') { if (' + ($errors) + '[' + ($key) + '].length) { '; - if ($config.options.singleError) { - out += ' if (' + ($message) + ') { ' + ($message) + ' += '; - if (typeof $config.options.singleError == 'string') { - out += ' ' + (it.util.toQuotedString($config.options.singleError)) + ' '; - } else { - out += ' \'; \' '; - } - out += '; } ' + ($message) + ' += ' + ($key) + ' in ' + ($templates) + ' ? ' + ($templates) + '[' + ($key) + '] () : validate.schema' + ($schemaPath) + '[' + ($key) + ']; ' + ($paramsErrors) + ' = ' + ($paramsErrors) + '.concat(' + ($errors) + '[' + ($key) + ']); } } '; - } else { - out += ' var ' + ($message) + ' = ' + ($key) + ' in ' + ($templates) + ' ? ' + ($templates) + '[' + ($key) + '] () : validate.schema' + ($schemaPath) + '[' + ($key) + ']; var ' + ($paramsErrors) + ' = ' + ($errors) + '[' + ($key) + ']; '; - } - out += ' var err = { keyword: \'' + ($keyword) + '\' , dataPath: ' + ($dataPath) + ' , schemaPath: ' + ($errSchemaPathString) + ' + \'/' + ($keyword) + '\' , params: { errors: ' + ($paramsErrors) + ' } , message: ' + ($message) + ' '; - if (it.opts.verbose) { - out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; - } - out += ' }; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; '; - if (!$config.options.singleError) { - out += ' } } '; - } - } - if ($hasKeywordProps) { - out += ' ' + ($i) + ' = 0; ' + ($errors) + ' = ' + (JSON.stringify($keywordPropErrors)) + '; var ' + ($paramsErrors) + ', ' + ($propParam) + '; var ' + ($keywordPropParams) + ' = ' + (JSON.stringify($config.KEYWORD_PROPERTY_PARAMS)) + '; var ' + ($templates) + ' = { '; - var $comma = false; - var arr2 = Object.keys($keywordPropErrors); - if (arr2) { - var $k, i2 = -1, - l2 = arr2.length - 1; - while (i2 < l2) { - $k = arr2[i2 += 1]; - var $keywordMsgs = $schema[$k]; - if ($comma) { - out += ','; - } - out += '' + (it.util.toQuotedString($k)) + ': { '; - $comma = true; - var $innerComma = false; - var arr3 = Object.keys($keywordMsgs); - if (arr3) { - var $prop, i3 = -1, - l3 = arr3.length - 1; - while (i3 < l3) { - $prop = arr3[i3 += 1]; - if (INTERPOLATION.test($keywordMsgs[$prop])) { - if ($innerComma) { - out += ','; - } - out += '' + (it.util.toQuotedString($prop)) + ': ' + (templateFunc($keywordMsgs[$prop])) + ' '; - $innerComma = true; - } - } - } - out += ' } '; - } - } - out += ' }; while (' + ($i) + ' < errors) { ' + ($err) + ' = vErrors[' + ($i) + ']; if ( ' + ($err) + '.keyword != \'' + ($keyword) + '\' '; - if ($config.options.keepErrors) { - out += ' && !' + ($err) + '.emUsed '; - } - out += ' && ' + ($err) + '.keyword in ' + ($errors) + ' && ' + ($err) + '.dataPath == ' + ($dataPath) + ' && ' + ($err) + '.schemaPath.indexOf(' + ($errSchemaPathString) + ') == 0 && /^\\/[^\\/]*$/.test(' + ($err) + '.schemaPath.slice(' + (it.errSchemaPath.length) + '))) { ' + ($propParam) + ' = ' + ($keywordPropParams) + '[' + ($err) + '.keyword]; ' + ($paramsErrors) + ' = ' + ($errors) + '[' + ($err) + '.keyword][' + ($err) + '.params[' + ($propParam) + ']]; if (' + ($paramsErrors) + ') { ' + ($paramsErrors) + '.push(' + ($err) + '); '; - if ($config.options.keepErrors) { - out += ' ' + ($err) + '.emUsed = true; '; - } else { - out += ' vErrors.splice(' + ($i) + ', 1); errors--; '; - } - out += ' } else { ' + ($i) + '++; } } else { ' + ($i) + '++; } } for (var ' + ($key) + ' in ' + ($errors) + ') { for (var ' + ($keyProp) + ' in ' + ($errors) + '[' + ($key) + ']) { ' + ($paramsErrors) + ' = ' + ($errors) + '[' + ($key) + '][' + ($keyProp) + ']; if (' + ($paramsErrors) + '.length) { var ' + ($message) + ' = ' + ($key) + ' in ' + ($templates) + ' && ' + ($keyProp) + ' in ' + ($templates) + '[' + ($key) + '] ? ' + ($templates) + '[' + ($key) + '][' + ($keyProp) + '] () : validate.schema' + ($schemaPath) + '[' + ($key) + '][' + ($keyProp) + ']; var err = { keyword: \'' + ($keyword) + '\' , dataPath: ' + ($dataPath) + ' , schemaPath: ' + ($errSchemaPathString) + ' + \'/' + ($keyword) + '\' , params: { errors: ' + ($paramsErrors) + ' } , message: ' + ($message) + ' '; - if (it.opts.verbose) { - out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; - } - out += ' }; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } } } '; - } - if ($hasProperties || $hasItems) { - out += ' var ' + ($isArray) + ' = Array.isArray(' + ($data) + '); if '; - if ($hasProperties && $hasItems) { - out += ' (typeof ' + ($data) + ' == \'object\') { '; - var $childProp = '[' + $childKeyword + ']'; - out += ' ' + ($i) + ' = 0; if (' + ($isArray) + ') { var ' + ($childKeyword) + ' = \'items\'; ' + ($errors) + ' = ' + (JSON.stringify($childErrors.items)) + '; '; - var _keysArray = Object.keys($childErrors.items); - out += ' var ' + ($templates) + ' = { '; - var $comma = false; - var arr4 = _keysArray; - if (arr4) { - var $k, i4 = -1, - l4 = arr4.length - 1; - while (i4 < l4) { - $k = arr4[i4 += 1]; - if (INTERPOLATION.test($schema.items[$k])) { - if ($comma) { - out += ','; - } - out += '' + (it.util.toQuotedString($k)) + ': ' + (templateFunc($schema.items[$k])) + ' '; - $comma = true; - } - } - } - out += ' }; } else { var ' + ($childKeyword) + ' = \'properties\'; ' + ($errors) + ' = ' + (JSON.stringify($childErrors.properties)) + '; '; - var _keysArray = Object.keys($childErrors.properties); - out += ' var ' + ($templates) + ' = { '; - var $comma = false; - var arr5 = _keysArray; - if (arr5) { - var $k, i5 = -1, - l5 = arr5.length - 1; - while (i5 < l5) { - $k = arr5[i5 += 1]; - if (INTERPOLATION.test($schema.properties[$k])) { - if ($comma) { - out += ','; - } - out += '' + (it.util.toQuotedString($k)) + ': ' + (templateFunc($schema.properties[$k])) + ' '; - $comma = true; - } - } - } - out += ' }; } '; - } else if ($hasProperties) { - out += ' (typeof ' + ($data) + ' == \'object\' && !' + ($isArray) + ') { '; - var $childProp = '.properties'; - out += ' ' + ($i) + ' = 0; ' + ($errors) + ' = ' + (JSON.stringify($childErrors.properties)) + '; '; - var _keysArray = Object.keys($childErrors.properties); - out += ' var ' + ($templates) + ' = { '; - var $comma = false; - var arr6 = _keysArray; - if (arr6) { - var $k, i6 = -1, - l6 = arr6.length - 1; - while (i6 < l6) { - $k = arr6[i6 += 1]; - if (INTERPOLATION.test($schema.properties[$k])) { - if ($comma) { - out += ','; - } - out += '' + (it.util.toQuotedString($k)) + ': ' + (templateFunc($schema.properties[$k])) + ' '; - $comma = true; - } - } - } - out += ' }; '; - } else { - out += ' (' + ($isArray) + ') { '; - var $childProp = '.items'; - out += ' ' + ($i) + ' = 0; ' + ($errors) + ' = ' + (JSON.stringify($childErrors.items)) + '; '; - var _keysArray = Object.keys($childErrors.items); - out += ' var ' + ($templates) + ' = { '; - var $comma = false; - var arr7 = _keysArray; - if (arr7) { - var $k, i7 = -1, - l7 = arr7.length - 1; - while (i7 < l7) { - $k = arr7[i7 += 1]; - if (INTERPOLATION.test($schema.items[$k])) { - if ($comma) { - out += ','; - } - out += '' + (it.util.toQuotedString($k)) + ': ' + (templateFunc($schema.items[$k])) + ' '; - $comma = true; - } - } - } - out += ' }; '; - } - out += ' var ' + ($child) + ', ' + ($matches) + '; while (' + ($i) + ' < errors) { ' + ($err) + ' = vErrors[' + ($i) + ']; if ( ' + ($err) + '.keyword != \'' + ($keyword) + '\' '; - if ($config.options.keepErrors) { - out += ' && !' + ($err) + '.emUsed '; - } - out += ' && ' + ($err) + '.dataPath.indexOf(' + ($dataPath) + ') == 0 && (' + ($matches) + ' = ' + ($err) + '.dataPath.slice(' + ($dataPath) + '.length).match(/^\\/([^\\/]*)(?:\\/|$)/), ' + ($child) + ' = ' + ($matches) + ' && ' + ($matches) + '[1].replace(/~1/g, \'/\').replace(/~0/g, \'~\') ) !== undefined && ' + ($child) + ' in ' + ($errors) + ') { ' + ($errors) + '[' + ($child) + '].push(' + ($err) + '); '; - if ($config.options.keepErrors) { - out += ' ' + ($err) + '.emUsed = true; '; - } else { - out += ' vErrors.splice(' + ($i) + ', 1); errors--; '; - } - out += ' } else { ' + ($i) + '++; } } for (var ' + ($key) + ' in ' + ($errors) + ') { if (' + ($errors) + '[' + ($key) + '].length) { var err = { keyword: \'' + ($keyword) + '\' , dataPath: ' + ($dataPath) + ' + \'/\' + ' + ($key) + '.replace(/~/g, \'~0\').replace(/\\//g, \'~1\') , schemaPath: ' + ($errSchemaPathString) + ' + \'/' + ($keyword) + '\' , params: { errors: ' + ($errors) + '[' + ($key) + '] } , message: ' + ($key) + ' in ' + ($templates) + ' ? ' + ($templates) + '[' + ($key) + '] () : validate.schema' + ($schemaPath) + ($childProp) + '[' + ($key) + '] '; - if (it.opts.verbose) { - out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; - } - out += ' }; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } } } '; - } - } - var $schemaMessage = typeof $schema == 'string' ? $schema : $schema._; - if ($schemaMessage) { - out += ' ' + ($i) + ' = 0; ' + ($errors) + ' = []; while (' + ($i) + ' < errors) { ' + ($err) + ' = vErrors[' + ($i) + ']; if ( ' + ($err) + '.keyword != \'' + ($keyword) + '\' '; - if ($config.options.keepErrors) { - out += ' && !' + ($err) + '.emUsed '; - } - out += ' && (' + ($err) + '.dataPath == ' + ($dataPath) + ' || (' + ($err) + '.dataPath.indexOf(' + ($dataPath) + ') == 0 && ' + ($err) + '.dataPath[' + ($dataPath) + '.length] == \'/\')) && ' + ($err) + '.schemaPath.indexOf(' + ($errSchemaPathString) + ') == 0 && ' + ($err) + '.schemaPath[' + (it.errSchemaPath.length) + '] == \'/\') { ' + ($errors) + '.push(' + ($err) + '); '; - if ($config.options.keepErrors) { - out += ' ' + ($err) + '.emUsed = true; '; - } else { - out += ' vErrors.splice(' + ($i) + ', 1); errors--; '; - } - out += ' } else { ' + ($i) + '++; } } if (' + ($errors) + '.length) { var err = { keyword: \'' + ($keyword) + '\' , dataPath: ' + ($dataPath) + ' , schemaPath: ' + ($errSchemaPathString) + ' + \'/' + ($keyword) + '\' , params: { errors: ' + ($errors) + ' } , message: ' + (templateExpr($schemaMessage)) + ' '; - if (it.opts.verbose) { - out += ' , schema: ' + (it.util.toQuotedString($schemaMessage)) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; - } - out += ' }; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } '; - } - out += ' }'; - } - - function templateExpr(str) { - str = it.util.escapeQuotes(str); - if (!INTERPOLATION.test(str)) return "'" + str + "'"; - var expr = "'" + str.replace(INTERPOLATION_REPLACE, function($0, $1) { - return "' + JSON.stringify(" + it.util.getData($1, $dataLvl, it.dataPathArr) + ") + '"; - }) + "'"; - return expr.replace(EMPTY_STR, ''); - } - - function templateFunc(str) { - return 'function() { return ' + templateExpr(str) + '; }'; - } - return out; -} diff --git a/node_modules/ajv-errors/package.json b/node_modules/ajv-errors/package.json deleted file mode 100644 index 04bac58..0000000 --- a/node_modules/ajv-errors/package.json +++ /dev/null @@ -1,85 +0,0 @@ -{ - "_from": "ajv-errors@^1.0.0", - "_id": "ajv-errors@1.0.1", - "_inBundle": false, - "_integrity": "sha512-DCRfO/4nQ+89p/RK43i8Ezd41EqdGIU4ld7nGF8OQ14oc/we5rEntLCUa7+jrn3nn83BosfwZA0wb4pon2o8iQ==", - "_location": "/ajv-errors", - "_phantomChildren": {}, - "_requested": { - "type": "range", - "registry": true, - "raw": "ajv-errors@^1.0.0", - "name": "ajv-errors", - "escapedName": "ajv-errors", - "rawSpec": "^1.0.0", - "saveSpec": null, - "fetchSpec": "^1.0.0" - }, - "_requiredBy": [ - "/file-loader/schema-utils", - "/terser-webpack-plugin/schema-utils", - "/webpack/schema-utils" - ], - "_resolved": "https://registry.npmjs.org/ajv-errors/-/ajv-errors-1.0.1.tgz", - "_shasum": "f35986aceb91afadec4102fbd85014950cefa64d", - "_spec": "ajv-errors@^1.0.0", - "_where": "/home/pruss/Dev/3-minute-website/node_modules/file-loader/node_modules/schema-utils", - "author": "", - "bugs": { - "url": "https://github.com/epoberezkin/ajv-errors/issues" - }, - "bundleDependencies": false, - "deprecated": false, - "description": "Custom error messages in JSON-Schema for Ajv validator", - "devDependencies": { - "ajv": "^5.0.0", - "coveralls": "^2.11.16", - "dot": "^1.1.1", - "eslint": "^3.17.0", - "glob": "^7.1.1", - "js-beautify": "^1.6.12", - "mocha": "^3.2.0", - "nyc": "^10.1.2", - "pre-commit": "^1.2.2" - }, - "files": [ - "lib" - ], - "homepage": "https://github.com/epoberezkin/ajv-errors#readme", - "keywords": [ - "ajv", - "json-schema", - "validator", - "error", - "messages" - ], - "license": "MIT", - "main": "index.js", - "name": "ajv-errors", - "nyc": { - "exclude": [ - "**/spec/**", - "node_modules" - ], - "reporter": [ - "lcov", - "text-summary" - ] - }, - "peerDependencies": { - "ajv": ">=5.0.0" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/epoberezkin/ajv-errors.git" - }, - "scripts": { - "build": "node node_modules/ajv/scripts/compile-dots.js node_modules/ajv/lib lib", - "eslint": "eslint *.js spec", - "prepublish": "npm run build", - "test": "npm run eslint && npm run build && npm run test-cov", - "test-cov": "nyc npm run test-spec", - "test-spec": "mocha spec/*.spec.js -R spec" - }, - "version": "1.0.1" -} |