mirror of
https://github.com/S2-/minifyfromhtml.git
synced 2025-08-03 04:10:04 +02:00
update node modules
This commit is contained in:
108
node_modules/ajv/lib/dotjs/validate.js
generated
vendored
108
node_modules/ajv/lib/dotjs/validate.js
generated
vendored
@@ -4,26 +4,21 @@ module.exports = function generate_validate(it, $keyword, $ruleType) {
|
||||
var $async = it.schema.$async === true,
|
||||
$refKeywords = it.util.schemaHasRulesExcept(it.schema, it.RULES.all, '$ref'),
|
||||
$id = it.self._getId(it.schema);
|
||||
if (it.isTop) {
|
||||
if ($async) {
|
||||
it.async = true;
|
||||
var $es7 = it.opts.async == 'es7';
|
||||
it.yieldAwait = $es7 ? 'await' : 'yield';
|
||||
if (it.opts.strictKeywords) {
|
||||
var $unknownKwd = it.util.schemaUnknownRules(it.schema, it.RULES.keywords);
|
||||
if ($unknownKwd) {
|
||||
var $keywordsMsg = 'unknown keyword: ' + $unknownKwd;
|
||||
if (it.opts.strictKeywords === 'log') it.logger.warn($keywordsMsg);
|
||||
else throw new Error($keywordsMsg);
|
||||
}
|
||||
}
|
||||
if (it.isTop) {
|
||||
out += ' var validate = ';
|
||||
if ($async) {
|
||||
if ($es7) {
|
||||
out += ' (async function ';
|
||||
} else {
|
||||
if (it.opts.async != '*') {
|
||||
out += 'co.wrap';
|
||||
}
|
||||
out += '(function* ';
|
||||
}
|
||||
} else {
|
||||
out += ' (function ';
|
||||
it.async = true;
|
||||
out += 'async ';
|
||||
}
|
||||
out += ' (data, dataPath, parentData, parentDataProperty, rootData) { \'use strict\'; ';
|
||||
out += 'function(data, dataPath, parentData, parentDataProperty, rootData) { \'use strict\'; ';
|
||||
if ($id && (it.opts.sourceCode || it.opts.processCode)) {
|
||||
out += ' ' + ('/\*# sourceURL=' + $id + ' */') + ' ';
|
||||
}
|
||||
@@ -62,7 +57,8 @@ module.exports = function generate_validate(it, $keyword, $ruleType) {
|
||||
}
|
||||
var __err = out;
|
||||
out = $$outStack.pop();
|
||||
if (!it.compositeRule && $breakOnError) { /* istanbul ignore if */
|
||||
if (!it.compositeRule && $breakOnError) {
|
||||
/* istanbul ignore if */
|
||||
if (it.async) {
|
||||
out += ' throw new ValidationError([' + (__err) + ']); ';
|
||||
} else {
|
||||
@@ -83,7 +79,7 @@ module.exports = function generate_validate(it, $keyword, $ruleType) {
|
||||
}
|
||||
}
|
||||
if (it.isTop) {
|
||||
out += ' }); return validate; ';
|
||||
out += ' }; return validate; ';
|
||||
}
|
||||
return out;
|
||||
}
|
||||
@@ -96,6 +92,11 @@ module.exports = function generate_validate(it, $keyword, $ruleType) {
|
||||
it.baseId = it.baseId || it.rootId;
|
||||
delete it.isTop;
|
||||
it.dataPathArr = [undefined];
|
||||
if (it.schema.default !== undefined && it.opts.useDefaults && it.opts.strictDefaults) {
|
||||
var $defaultMsg = 'default is ignored in the schema root';
|
||||
if (it.opts.strictDefaults === 'log') it.logger.warn($defaultMsg);
|
||||
else throw new Error($defaultMsg);
|
||||
}
|
||||
out += ' var vErrors = null; ';
|
||||
out += ' var errors = 0; ';
|
||||
out += ' if (rootData === undefined) rootData = data; ';
|
||||
@@ -114,6 +115,14 @@ module.exports = function generate_validate(it, $keyword, $ruleType) {
|
||||
var $errorKeyword;
|
||||
var $typeSchema = it.schema.type,
|
||||
$typeIsArray = Array.isArray($typeSchema);
|
||||
if ($typeSchema && it.opts.nullable && it.schema.nullable === true) {
|
||||
if ($typeIsArray) {
|
||||
if ($typeSchema.indexOf('null') == -1) $typeSchema = $typeSchema.concat('null');
|
||||
} else if ($typeSchema != 'null') {
|
||||
$typeSchema = [$typeSchema, 'null'];
|
||||
$typeIsArray = true;
|
||||
}
|
||||
}
|
||||
if ($typeIsArray && $typeSchema.length == 1) {
|
||||
$typeSchema = $typeSchema[0];
|
||||
$typeIsArray = false;
|
||||
@@ -126,6 +135,9 @@ module.exports = function generate_validate(it, $keyword, $ruleType) {
|
||||
it.logger.warn('$ref: keywords ignored in schema at path "' + it.errSchemaPath + '"');
|
||||
}
|
||||
}
|
||||
if (it.schema.$comment && it.opts.$comment) {
|
||||
out += ' ' + (it.RULES.all.$comment.code(it, '$comment'));
|
||||
}
|
||||
if ($typeSchema) {
|
||||
if (it.opts.coerceTypes) {
|
||||
var $coerceToTypes = it.util.coerceToTypes(it.opts.coerceTypes, $typeSchema);
|
||||
@@ -207,7 +219,8 @@ module.exports = function generate_validate(it, $keyword, $ruleType) {
|
||||
}
|
||||
var __err = out;
|
||||
out = $$outStack.pop();
|
||||
if (!it.compositeRule && $breakOnError) { /* istanbul ignore if */
|
||||
if (!it.compositeRule && $breakOnError) {
|
||||
/* istanbul ignore if */
|
||||
if (it.async) {
|
||||
out += ' throw new ValidationError([' + (__err) + ']); ';
|
||||
} else {
|
||||
@@ -254,7 +267,8 @@ module.exports = function generate_validate(it, $keyword, $ruleType) {
|
||||
}
|
||||
var __err = out;
|
||||
out = $$outStack.pop();
|
||||
if (!it.compositeRule && $breakOnError) { /* istanbul ignore if */
|
||||
if (!it.compositeRule && $breakOnError) {
|
||||
/* istanbul ignore if */
|
||||
if (it.async) {
|
||||
out += ' throw new ValidationError([' + (__err) + ']); ';
|
||||
} else {
|
||||
@@ -280,9 +294,6 @@ module.exports = function generate_validate(it, $keyword, $ruleType) {
|
||||
$closingBraces2 += '}';
|
||||
}
|
||||
} else {
|
||||
if (it.opts.v5 && it.schema.patternGroups) {
|
||||
it.logger.warn('keyword "patternGroups" is deprecated and disabled. Use option patternGroups: true to enable.');
|
||||
}
|
||||
var arr2 = it.RULES;
|
||||
if (arr2) {
|
||||
var $rulesGroup, i2 = -1,
|
||||
@@ -293,7 +304,7 @@ module.exports = function generate_validate(it, $keyword, $ruleType) {
|
||||
if ($rulesGroup.type) {
|
||||
out += ' if (' + (it.util.checkDataType($rulesGroup.type, $data)) + ') { ';
|
||||
}
|
||||
if (it.opts.useDefaults && !it.compositeRule) {
|
||||
if (it.opts.useDefaults) {
|
||||
if ($rulesGroup.type == 'object' && it.schema.properties) {
|
||||
var $schema = it.schema.properties,
|
||||
$schemaKeys = Object.keys($schema);
|
||||
@@ -306,13 +317,25 @@ module.exports = function generate_validate(it, $keyword, $ruleType) {
|
||||
var $sch = $schema[$propertyKey];
|
||||
if ($sch.default !== undefined) {
|
||||
var $passData = $data + it.util.getProperty($propertyKey);
|
||||
out += ' if (' + ($passData) + ' === undefined) ' + ($passData) + ' = ';
|
||||
if (it.opts.useDefaults == 'shared') {
|
||||
out += ' ' + (it.useDefault($sch.default)) + ' ';
|
||||
if (it.compositeRule) {
|
||||
if (it.opts.strictDefaults) {
|
||||
var $defaultMsg = 'default is ignored for: ' + $passData;
|
||||
if (it.opts.strictDefaults === 'log') it.logger.warn($defaultMsg);
|
||||
else throw new Error($defaultMsg);
|
||||
}
|
||||
} else {
|
||||
out += ' ' + (JSON.stringify($sch.default)) + ' ';
|
||||
out += ' if (' + ($passData) + ' === undefined ';
|
||||
if (it.opts.useDefaults == 'empty') {
|
||||
out += ' || ' + ($passData) + ' === null || ' + ($passData) + ' === \'\' ';
|
||||
}
|
||||
out += ' ) ' + ($passData) + ' = ';
|
||||
if (it.opts.useDefaults == 'shared') {
|
||||
out += ' ' + (it.useDefault($sch.default)) + ' ';
|
||||
} else {
|
||||
out += ' ' + (JSON.stringify($sch.default)) + ' ';
|
||||
}
|
||||
out += '; ';
|
||||
}
|
||||
out += '; ';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -325,13 +348,25 @@ module.exports = function generate_validate(it, $keyword, $ruleType) {
|
||||
$sch = arr4[$i += 1];
|
||||
if ($sch.default !== undefined) {
|
||||
var $passData = $data + '[' + $i + ']';
|
||||
out += ' if (' + ($passData) + ' === undefined) ' + ($passData) + ' = ';
|
||||
if (it.opts.useDefaults == 'shared') {
|
||||
out += ' ' + (it.useDefault($sch.default)) + ' ';
|
||||
if (it.compositeRule) {
|
||||
if (it.opts.strictDefaults) {
|
||||
var $defaultMsg = 'default is ignored for: ' + $passData;
|
||||
if (it.opts.strictDefaults === 'log') it.logger.warn($defaultMsg);
|
||||
else throw new Error($defaultMsg);
|
||||
}
|
||||
} else {
|
||||
out += ' ' + (JSON.stringify($sch.default)) + ' ';
|
||||
out += ' if (' + ($passData) + ' === undefined ';
|
||||
if (it.opts.useDefaults == 'empty') {
|
||||
out += ' || ' + ($passData) + ' === null || ' + ($passData) + ' === \'\' ';
|
||||
}
|
||||
out += ' ) ' + ($passData) + ' = ';
|
||||
if (it.opts.useDefaults == 'shared') {
|
||||
out += ' ' + (it.useDefault($sch.default)) + ' ';
|
||||
} else {
|
||||
out += ' ' + (JSON.stringify($sch.default)) + ' ';
|
||||
}
|
||||
out += '; ';
|
||||
}
|
||||
out += '; ';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -393,7 +428,8 @@ module.exports = function generate_validate(it, $keyword, $ruleType) {
|
||||
}
|
||||
var __err = out;
|
||||
out = $$outStack.pop();
|
||||
if (!it.compositeRule && $breakOnError) { /* istanbul ignore if */
|
||||
if (!it.compositeRule && $breakOnError) {
|
||||
/* istanbul ignore if */
|
||||
if (it.async) {
|
||||
out += ' throw new ValidationError([' + (__err) + ']); ';
|
||||
} else {
|
||||
@@ -430,7 +466,7 @@ module.exports = function generate_validate(it, $keyword, $ruleType) {
|
||||
out += ' validate.errors = vErrors; ';
|
||||
out += ' return errors === 0; ';
|
||||
}
|
||||
out += ' }); return validate;';
|
||||
out += ' }; return validate;';
|
||||
} else {
|
||||
out += ' var ' + ($valid) + ' = errors === errs_' + ($lvl) + ';';
|
||||
}
|
||||
|
Reference in New Issue
Block a user