summaryrefslogtreecommitdiff
path: root/tools/eslint/node_modules/ajv/dist/ajv.bundle.js
diff options
context:
space:
mode:
Diffstat (limited to 'tools/eslint/node_modules/ajv/dist/ajv.bundle.js')
-rw-r--r--tools/eslint/node_modules/ajv/dist/ajv.bundle.js235
1 files changed, 122 insertions, 113 deletions
diff --git a/tools/eslint/node_modules/ajv/dist/ajv.bundle.js b/tools/eslint/node_modules/ajv/dist/ajv.bundle.js
index fc16d815d1..ce77b83b33 100644
--- a/tools/eslint/node_modules/ajv/dist/ajv.bundle.js
+++ b/tools/eslint/node_modules/ajv/dist/ajv.bundle.js
@@ -2223,6 +2223,7 @@ module.exports = function generate_custom(it, $keyword) {
var $breakOnError = !it.opts.allErrors;
var $errorKeyword;
var $data = 'data' + ($dataLvl || '');
+ var $valid = 'valid' + $lvl;
var $errs = 'errs__' + $lvl;
var $isData = it.opts.v5 && $schema && $schema.$data,
$schemaValue;
@@ -2257,9 +2258,16 @@ module.exports = function generate_custom(it, $keyword) {
if (!($inline || $macro)) {
out += '' + ($ruleErrs) + ' = null;';
}
- out += 'var ' + ($errs) + ' = errors;var valid' + ($lvl) + ';';
- if ($inline && $rDef.statements) {
- out += ' ' + ($ruleValidate.validate);
+ out += 'var ' + ($errs) + ' = errors;var ' + ($valid) + ';';
+ if ($validateSchema) {
+ out += ' ' + ($valid) + ' = ' + ($definition) + '.validateSchema(' + ($schemaValue) + '); if (' + ($valid) + ') {';
+ }
+ if ($inline) {
+ if ($rDef.statements) {
+ out += ' ' + ($ruleValidate.validate) + ' ';
+ } else {
+ out += ' ' + ($valid) + ' = ' + ($ruleValidate.validate) + '; ';
+ }
} else if ($macro) {
var $it = it.util.copy(it);
$it.level++;
@@ -2271,7 +2279,7 @@ module.exports = function generate_custom(it, $keyword) {
var $code = it.validate($it).replace(/validate\.schema/g, $validateCode);
it.compositeRule = $it.compositeRule = $wasComposite;
out += ' ' + ($code);
- } else if (!$inline) {
+ } else {
var $$outStack = $$outStack || [];
$$outStack.push(out);
out = '';
@@ -2290,102 +2298,56 @@ module.exports = function generate_custom(it, $keyword) {
if (it.errorPath != '""') {
out += ' + ' + (it.errorPath);
}
- if ($dataLvl) {
- out += ' , data' + (($dataLvl - 1) || '') + ' , ' + (it.dataPathArr[$dataLvl]) + ' ';
- } else {
- out += ' , parentData , parentDataProperty ';
- }
- out += ' , rootData ) ';
+ var $parentData = $dataLvl ? 'data' + (($dataLvl - 1) || '') : 'parentData',
+ $parentDataProperty = $dataLvl ? it.dataPathArr[$dataLvl] : 'parentDataProperty';
+ out += ' , ' + ($parentData) + ' , ' + ($parentDataProperty) + ' , rootData ) ';
var def_callRuleValidate = out;
out = $$outStack.pop();
- if ($rDef.errors !== false) {
+ if ($rDef.errors === false) {
+ out += ' ' + ($valid) + ' = ';
+ if ($asyncKeyword) {
+ out += '' + (it.yieldAwait);
+ }
+ out += '' + (def_callRuleValidate) + '; ';
+ } else {
if ($asyncKeyword) {
$ruleErrs = 'customErrors' + $lvl;
- out += ' var ' + ($ruleErrs) + ' = null; try { valid' + ($lvl) + ' = ' + (it.yieldAwait) + (def_callRuleValidate) + '; } catch (e) { valid' + ($lvl) + ' = false; if (e instanceof ValidationError) ' + ($ruleErrs) + ' = e.errors; else throw e; } ';
+ out += ' var ' + ($ruleErrs) + ' = null; try { ' + ($valid) + ' = ' + (it.yieldAwait) + (def_callRuleValidate) + '; } catch (e) { ' + ($valid) + ' = false; if (e instanceof ValidationError) ' + ($ruleErrs) + ' = e.errors; else throw e; } ';
} else {
- out += ' ' + ($validateCode) + '.errors = null; ';
+ out += ' ' + ($ruleErrs) + ' = null; ' + ($valid) + ' = ' + (def_callRuleValidate) + '; ';
}
}
}
- out += 'if (';
+ if ($rDef.modifying) {
+ out += ' ' + ($data) + ' = ' + ($parentData) + '[' + ($parentDataProperty) + '];';
+ }
if ($validateSchema) {
- out += ' !' + ($definition) + '.validateSchema(' + ($schemaValue) + ') || ';
+ out += ' }';
}
- out += ' ! ';
- if ($inline) {
- if ($rDef.statements) {
- out += ' valid' + ($lvl) + ' ';
- } else {
- out += ' (' + ($ruleValidate.validate) + ') ';
+ if ($rDef.valid) {
+ if ($breakOnError) {
+ out += ' if (true) { ';
}
- } else if ($macro) {
- out += ' ' + ($nextValid) + ' ';
} else {
- if ($asyncKeyword) {
- if ($rDef.errors === false) {
- out += ' (' + (it.yieldAwait) + (def_callRuleValidate) + ') ';
+ out += ' if ( ';
+ if ($rDef.valid === undefined) {
+ out += ' !';
+ if ($macro) {
+ out += '' + ($nextValid);
} else {
- out += ' valid' + ($lvl) + ' ';
+ out += '' + ($valid);
}
} else {
- out += ' ' + (def_callRuleValidate) + ' ';
+ out += ' ' + (!$rDef.valid) + ' ';
}
- }
- out += ') { ';
- $errorKeyword = $rule.keyword;
- var $$outStack = $$outStack || [];
- $$outStack.push(out);
- out = '';
- var $$outStack = $$outStack || [];
- $$outStack.push(out);
- out = ''; /* istanbul ignore else */
- if (it.createErrors !== false) {
- out += ' { keyword: \'' + ($errorKeyword || 'custom') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { keyword: \'' + ($rule.keyword) + '\' } ';
- if (it.opts.messages !== false) {
- out += ' , message: \'should pass "' + ($rule.keyword) + '" keyword validation\' ';
- }
- if (it.opts.verbose) {
- out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
- }
- out += ' } ';
- } else {
- out += ' {} ';
- }
- var __err = out;
- out = $$outStack.pop();
- if (!it.compositeRule && $breakOnError) { /* istanbul ignore if */
- if (it.async) {
- out += ' throw new ValidationError([' + (__err) + ']); ';
- } else {
- out += ' validate.errors = [' + (__err) + ']; return false; ';
- }
- } else {
- out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
- }
- var def_customError = out;
- out = $$outStack.pop();
- if ($inline) {
- if ($rDef.errors) {
- if ($rDef.errors != 'full') {
- 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) + '"; } ';
- if (it.opts.verbose) {
- out += ' ' + ($ruleErr) + '.schema = ' + ($schemaValue) + '; ' + ($ruleErr) + '.data = ' + ($data) + '; ';
- }
- out += ' } ';
- }
- } else {
- if ($rDef.errors === false) {
- out += ' ' + (def_customError) + ' ';
- } else {
- 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) + '"; } ';
- if (it.opts.verbose) {
- out += ' ' + ($ruleErr) + '.schema = ' + ($schemaValue) + '; ' + ($ruleErr) + '.data = ' + ($data) + '; ';
- }
- out += ' } } ';
- }
- }
- } else if ($macro) {
- out += ' var err = '; /* istanbul ignore else */
+ out += ') { ';
+ $errorKeyword = $rule.keyword;
+ var $$outStack = $$outStack || [];
+ $$outStack.push(out);
+ out = '';
+ var $$outStack = $$outStack || [];
+ $$outStack.push(out);
+ out = ''; /* istanbul ignore else */
if (it.createErrors !== false) {
out += ' { keyword: \'' + ($errorKeyword || 'custom') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { keyword: \'' + ($rule.keyword) + '\' } ';
if (it.opts.messages !== false) {
@@ -2398,28 +2360,76 @@ module.exports = function generate_custom(it, $keyword) {
} else {
out += ' {} ';
}
- out += '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
+ var __err = out;
+ out = $$outStack.pop();
if (!it.compositeRule && $breakOnError) { /* istanbul ignore if */
if (it.async) {
- out += ' throw new ValidationError(vErrors); ';
+ out += ' throw new ValidationError([' + (__err) + ']); ';
} else {
- out += ' validate.errors = vErrors; return false; ';
+ out += ' validate.errors = [' + (__err) + ']; return false; ';
}
+ } else {
+ out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
}
- } else {
- if ($rDef.errors === false) {
- out += ' ' + (def_customError) + ' ';
+ var def_customError = out;
+ out = $$outStack.pop();
+ if ($inline) {
+ if ($rDef.errors) {
+ if ($rDef.errors != 'full') {
+ 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) + '"; } ';
+ if (it.opts.verbose) {
+ out += ' ' + ($ruleErr) + '.schema = ' + ($schemaValue) + '; ' + ($ruleErr) + '.data = ' + ($data) + '; ';
+ }
+ out += ' } ';
+ }
+ } else {
+ if ($rDef.errors === false) {
+ out += ' ' + (def_customError) + ' ';
+ } else {
+ 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) + '"; } ';
+ if (it.opts.verbose) {
+ out += ' ' + ($ruleErr) + '.schema = ' + ($schemaValue) + '; ' + ($ruleErr) + '.data = ' + ($data) + '; ';
+ }
+ out += ' } } ';
+ }
+ }
+ } else if ($macro) {
+ out += ' var err = '; /* istanbul ignore else */
+ if (it.createErrors !== false) {
+ out += ' { keyword: \'' + ($errorKeyword || 'custom') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { keyword: \'' + ($rule.keyword) + '\' } ';
+ if (it.opts.messages !== false) {
+ out += ' , message: \'should pass "' + ($rule.keyword) + '" keyword validation\' ';
+ }
+ if (it.opts.verbose) {
+ out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
+ }
+ out += ' } ';
+ } else {
+ out += ' {} ';
+ }
+ out += '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
+ if (!it.compositeRule && $breakOnError) { /* istanbul ignore if */
+ if (it.async) {
+ out += ' throw new ValidationError(vErrors); ';
+ } else {
+ out += ' validate.errors = vErrors; return false; ';
+ }
+ }
} else {
- 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) + ']; ' + ($ruleErr) + '.dataPath = (dataPath || \'\') + ' + (it.errorPath) + '; ' + ($ruleErr) + '.schemaPath = "' + ($errSchemaPath) + '"; ';
- if (it.opts.verbose) {
- out += ' ' + ($ruleErr) + '.schema = ' + ($schemaValue) + '; ' + ($ruleErr) + '.data = ' + ($data) + '; ';
+ if ($rDef.errors === false) {
+ out += ' ' + (def_customError) + ' ';
+ } else {
+ 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) + '"; ';
+ if (it.opts.verbose) {
+ out += ' ' + ($ruleErr) + '.schema = ' + ($schemaValue) + '; ' + ($ruleErr) + '.data = ' + ($data) + '; ';
+ }
+ out += ' } } else { ' + (def_customError) + ' } ';
}
- out += ' } } else { ' + (def_customError) + ' } ';
}
- }
- out += ' } ';
- if ($breakOnError) {
- out += ' else { ';
+ out += ' } ';
+ if ($breakOnError) {
+ out += ' else { ';
+ }
}
return out;
}
@@ -2554,7 +2564,7 @@ module.exports = function generate_dependencies(it, $keyword) {
for (var $property in $schemaDeps) {
var $sch = $schemaDeps[$property];
if (it.util.schemaHasRules($sch, it.RULES.all)) {
- out += ' ' + ($nextValid) + ' = true; if (' + ($data) + '[\'' + ($property) + '\'] !== undefined) { ';
+ out += ' ' + ($nextValid) + ' = true; if (' + ($data) + (it.util.getProperty($property)) + ' !== undefined) { ';
$it.schema = $sch;
$it.schemaPath = $schemaPath + it.util.getProperty($property);
$it.errSchemaPath = $errSchemaPath + '/' + it.util.escapeFragment($property);
@@ -3850,12 +3860,9 @@ module.exports = function generate_ref(it, $keyword) {
if (it.errorPath != '""') {
out += ' + ' + (it.errorPath);
}
- if ($dataLvl) {
- out += ' , data' + (($dataLvl - 1) || '') + ' , ' + (it.dataPathArr[$dataLvl]) + ' ';
- } else {
- out += ' , parentData , parentDataProperty ';
- }
- out += ', rootData) ';
+ var $parentData = $dataLvl ? 'data' + (($dataLvl - 1) || '') : 'parentData',
+ $parentDataProperty = $dataLvl ? it.dataPathArr[$dataLvl] : 'parentDataProperty';
+ out += ' , ' + ($parentData) + ' , ' + ($parentDataProperty) + ', rootData) ';
var __callValidate = out;
out = $$outStack.pop();
if ($async) {
@@ -4469,15 +4476,14 @@ module.exports = function generate_validate(it, $keyword) {
} else {
out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
}
- out += ' } else { ';
- if ($dataLvl) {
- var $parentData = 'data' + (($dataLvl - 1) || ''),
- $dataProperty = it.dataPathArr[$dataLvl];
- out += ' ' + ($data) + ' = ' + ($parentData) + '[' + ($dataProperty) + '] = ' + ($coerced) + '; ';
- } else {
- out += ' data = ' + ($coerced) + '; if (parentData !== undefined) parentData[parentDataProperty] = ' + ($coerced) + '; ';
+ out += ' } else { ';
+ var $parentData = $dataLvl ? 'data' + (($dataLvl - 1) || '') : 'parentData',
+ $parentDataProperty = $dataLvl ? it.dataPathArr[$dataLvl] : 'parentDataProperty';
+ out += ' ' + ($data) + ' = ' + ($coerced) + '; ';
+ if (!$dataLvl) {
+ out += 'if (' + ($parentData) + ' !== undefined)';
}
- out += ' } } ';
+ out += ' ' + ($parentData) + '[' + ($parentDataProperty) + '] = ' + ($coerced) + '; } } ';
}
}
var $refKeywords;
@@ -4744,6 +4750,9 @@ function addKeyword(keyword, definition) {
throw new Error('Keyword ' + keyword + ' is not a valid identifier');
if (definition) {
+ if (definition.macro && definition.valid !== undefined)
+ throw new Error('"valid" option cannot be used with macro keywords');
+
var dataType = definition.type;
if (Array.isArray(dataType)) {
var i, len = dataType.length;