plugin-agent-orchestrator 1.1.0 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/externalVersion.js +6 -6
- package/dist/locale/en-US.json +7 -1
- package/dist/locale/vi-VN.json +7 -1
- package/dist/locale/zh-CN.json +7 -1
- package/dist/node_modules/ajv/.tonic_example.js +20 -0
- package/dist/node_modules/ajv/LICENSE +22 -0
- package/dist/node_modules/ajv/dist/ajv.bundle.js +7189 -0
- package/dist/node_modules/ajv/dist/ajv.min.js +3 -0
- package/dist/node_modules/ajv/lib/ajv.d.ts +397 -0
- package/dist/node_modules/ajv/lib/ajv.js +3 -0
- package/dist/node_modules/ajv/lib/cache.js +26 -0
- package/dist/node_modules/ajv/lib/compile/async.js +90 -0
- package/dist/node_modules/ajv/lib/compile/equal.js +5 -0
- package/dist/node_modules/ajv/lib/compile/error_classes.js +34 -0
- package/dist/node_modules/ajv/lib/compile/formats.js +142 -0
- package/dist/node_modules/ajv/lib/compile/index.js +387 -0
- package/dist/node_modules/ajv/lib/compile/resolve.js +270 -0
- package/dist/node_modules/ajv/lib/compile/rules.js +66 -0
- package/dist/node_modules/ajv/lib/compile/schema_obj.js +9 -0
- package/dist/node_modules/ajv/lib/compile/ucs2length.js +20 -0
- package/dist/node_modules/ajv/lib/compile/util.js +239 -0
- package/dist/node_modules/ajv/lib/data.js +49 -0
- package/dist/node_modules/ajv/lib/definition_schema.js +37 -0
- package/dist/node_modules/ajv/lib/dot/_limit.jst +113 -0
- package/dist/node_modules/ajv/lib/dot/_limitItems.jst +12 -0
- package/dist/node_modules/ajv/lib/dot/_limitLength.jst +12 -0
- package/dist/node_modules/ajv/lib/dot/_limitProperties.jst +12 -0
- package/dist/node_modules/ajv/lib/dot/allOf.jst +32 -0
- package/dist/node_modules/ajv/lib/dot/anyOf.jst +46 -0
- package/dist/node_modules/ajv/lib/dot/coerce.def +51 -0
- package/dist/node_modules/ajv/lib/dot/comment.jst +9 -0
- package/dist/node_modules/ajv/lib/dot/const.jst +11 -0
- package/dist/node_modules/ajv/lib/dot/contains.jst +55 -0
- package/dist/node_modules/ajv/lib/dot/custom.jst +191 -0
- package/dist/node_modules/ajv/lib/dot/defaults.def +47 -0
- package/dist/node_modules/ajv/lib/dot/definitions.def +203 -0
- package/dist/node_modules/ajv/lib/dot/dependencies.jst +79 -0
- package/dist/node_modules/ajv/lib/dot/enum.jst +30 -0
- package/dist/node_modules/ajv/lib/dot/errors.def +194 -0
- package/dist/node_modules/ajv/lib/dot/format.jst +106 -0
- package/dist/node_modules/ajv/lib/dot/if.jst +73 -0
- package/dist/node_modules/ajv/lib/dot/items.jst +98 -0
- package/dist/node_modules/ajv/lib/dot/missing.def +39 -0
- package/dist/node_modules/ajv/lib/dot/multipleOf.jst +22 -0
- package/dist/node_modules/ajv/lib/dot/not.jst +43 -0
- package/dist/node_modules/ajv/lib/dot/oneOf.jst +54 -0
- package/dist/node_modules/ajv/lib/dot/pattern.jst +14 -0
- package/dist/node_modules/ajv/lib/dot/properties.jst +245 -0
- package/dist/node_modules/ajv/lib/dot/propertyNames.jst +52 -0
- package/dist/node_modules/ajv/lib/dot/ref.jst +85 -0
- package/dist/node_modules/ajv/lib/dot/required.jst +108 -0
- package/dist/node_modules/ajv/lib/dot/uniqueItems.jst +62 -0
- package/dist/node_modules/ajv/lib/dot/validate.jst +276 -0
- package/dist/node_modules/ajv/lib/dotjs/_limit.js +163 -0
- package/dist/node_modules/ajv/lib/dotjs/_limitItems.js +80 -0
- package/dist/node_modules/ajv/lib/dotjs/_limitLength.js +85 -0
- package/dist/node_modules/ajv/lib/dotjs/_limitProperties.js +80 -0
- package/dist/node_modules/ajv/lib/dotjs/allOf.js +42 -0
- package/dist/node_modules/ajv/lib/dotjs/anyOf.js +73 -0
- package/dist/node_modules/ajv/lib/dotjs/comment.js +14 -0
- package/dist/node_modules/ajv/lib/dotjs/const.js +56 -0
- package/dist/node_modules/ajv/lib/dotjs/contains.js +81 -0
- package/dist/node_modules/ajv/lib/dotjs/custom.js +228 -0
- package/dist/node_modules/ajv/lib/dotjs/dependencies.js +168 -0
- package/dist/node_modules/ajv/lib/dotjs/enum.js +66 -0
- package/dist/node_modules/ajv/lib/dotjs/format.js +150 -0
- package/dist/node_modules/ajv/lib/dotjs/if.js +103 -0
- package/dist/node_modules/ajv/lib/dotjs/index.js +33 -0
- package/dist/node_modules/ajv/lib/dotjs/items.js +140 -0
- package/dist/node_modules/ajv/lib/dotjs/multipleOf.js +80 -0
- package/dist/node_modules/ajv/lib/dotjs/not.js +84 -0
- package/dist/node_modules/ajv/lib/dotjs/oneOf.js +73 -0
- package/dist/node_modules/ajv/lib/dotjs/pattern.js +75 -0
- package/dist/node_modules/ajv/lib/dotjs/properties.js +335 -0
- package/dist/node_modules/ajv/lib/dotjs/propertyNames.js +81 -0
- package/dist/node_modules/ajv/lib/dotjs/ref.js +124 -0
- package/dist/node_modules/ajv/lib/dotjs/required.js +270 -0
- package/dist/node_modules/ajv/lib/dotjs/uniqueItems.js +86 -0
- package/dist/node_modules/ajv/lib/dotjs/validate.js +482 -0
- package/dist/node_modules/ajv/lib/keyword.js +146 -0
- package/dist/node_modules/ajv/lib/refs/data.json +17 -0
- package/dist/node_modules/ajv/lib/refs/json-schema-draft-04.json +149 -0
- package/dist/node_modules/ajv/lib/refs/json-schema-draft-06.json +154 -0
- package/dist/node_modules/ajv/lib/refs/json-schema-draft-07.json +168 -0
- package/dist/node_modules/ajv/lib/refs/json-schema-secure.json +94 -0
- package/dist/node_modules/ajv/node_modules/json-schema-traverse/.eslintrc.yml +27 -0
- package/dist/node_modules/ajv/node_modules/json-schema-traverse/.travis.yml +8 -0
- package/dist/node_modules/ajv/node_modules/json-schema-traverse/index.js +89 -0
- package/dist/node_modules/ajv/node_modules/json-schema-traverse/package.json +43 -0
- package/dist/node_modules/ajv/node_modules/json-schema-traverse/spec/.eslintrc.yml +6 -0
- package/dist/node_modules/ajv/node_modules/json-schema-traverse/spec/fixtures/schema.js +125 -0
- package/dist/node_modules/ajv/node_modules/json-schema-traverse/spec/index.spec.js +171 -0
- package/dist/node_modules/ajv/package.json +1 -0
- package/dist/node_modules/ajv/scripts/.eslintrc.yml +3 -0
- package/dist/node_modules/ajv/scripts/bundle.js +61 -0
- package/dist/node_modules/ajv/scripts/compile-dots.js +73 -0
- package/dist/node_modules/ajv/scripts/info +10 -0
- package/dist/node_modules/ajv/scripts/prepare-tests +12 -0
- package/dist/node_modules/ajv/scripts/publish-built-version +32 -0
- package/dist/node_modules/ajv/scripts/travis-gh-pages +23 -0
- package/dist/server/collections/skill-definitions.js +31 -0
- package/dist/server/collections/skill-executions.js +19 -0
- package/dist/server/collections/skill-registry-installations.js +70 -0
- package/dist/server/migrations/20260727010000-backfill-skill-tool-names.js +66 -0
- package/dist/server/plugin.js +96 -1
- package/dist/server/services/AgentExecutionContext.js +45 -0
- package/dist/server/services/CodeValidator.js +1 -0
- package/dist/server/services/ExecutionSpanService.js +10 -2
- package/dist/server/services/InputSchemaValidator.js +83 -0
- package/dist/server/services/NativeSubAgentObserver.js +55 -8
- package/dist/server/services/SandboxRunner.js +6 -2
- package/dist/server/services/SkillAccessService.js +109 -0
- package/dist/server/services/SkillManager.js +2 -0
- package/dist/server/services/SkillRepositoryService.js +70 -0
- package/dist/server/skill-hub/actions/git-import.js +479 -216
- package/dist/server/skill-hub/mcp/McpController.js +8 -5
- package/dist/server/skill-hub/middlewares/git-import-request-method-policy.js +69 -0
- package/dist/server/skill-hub/plugin.js +68 -14
- package/dist/server/skill-hub/services/RegistrySkillInstallationService.js +249 -0
- package/dist/server/skill-hub/services/RegistrySkillSnapshotService.js +228 -0
- package/dist/server/skill-hub/tasks/SkillExecutionTask.js +15 -3
- package/dist/server/tools/skill-execute.js +23 -2
- package/dist/server/utils/ctx-utils.js +2 -2
- package/dist/server/utils/skill-tool-name.js +73 -0
- package/package.json +9 -3
- package/src/locale/en-US.json +7 -1
- package/src/locale/vi-VN.json +7 -1
- package/src/locale/zh-CN.json +7 -1
- package/src/server/__tests__/agent-execution-context.test.ts +18 -0
- package/src/server/__tests__/input-schema-validator.test.ts +26 -0
- package/src/server/__tests__/native-sub-agent-observer.test.ts +52 -2
- package/src/server/__tests__/skill-access-service.test.ts +64 -0
- package/src/server/__tests__/skill-execute.test.ts +37 -0
- package/src/server/__tests__/skill-tool-name.test.ts +23 -0
- package/src/server/collections/skill-definitions.ts +31 -0
- package/src/server/collections/skill-executions.ts +19 -0
- package/src/server/collections/skill-registry-installations.ts +41 -0
- package/src/server/migrations/20260727010000-backfill-skill-tool-names.ts +45 -0
- package/src/server/plugin.ts +104 -1
- package/src/server/services/AgentExecutionContext.ts +23 -0
- package/src/server/services/CodeValidator.ts +1 -0
- package/src/server/services/ExecutionSpanService.ts +119 -110
- package/src/server/services/InputSchemaValidator.ts +44 -0
- package/src/server/services/NativeSubAgentObserver.ts +64 -10
- package/src/server/services/SandboxRunner.ts +6 -0
- package/src/server/services/SkillAccessService.ts +100 -0
- package/src/server/services/SkillManager.ts +2 -0
- package/src/server/services/SkillRepositoryService.ts +98 -2
- package/src/server/services/__tests__/SkillRepositoryService.test.ts +33 -0
- package/src/server/skill-hub/actions/__tests__/git-import.test.ts +501 -0
- package/src/server/skill-hub/actions/git-import.ts +682 -236
- package/src/server/skill-hub/mcp/McpController.ts +8 -14
- package/src/server/skill-hub/middlewares/git-import-request-method-policy.ts +51 -0
- package/src/server/skill-hub/plugin.ts +79 -13
- package/src/server/skill-hub/services/RegistrySkillInstallationService.ts +281 -0
- package/src/server/skill-hub/services/RegistrySkillSnapshotService.ts +239 -0
- package/src/server/skill-hub/services/__tests__/RegistrySkillInstallationService.test.ts +295 -0
- package/src/server/skill-hub/services/__tests__/RegistrySkillSnapshotService.test.ts +63 -0
- package/src/server/skill-hub/tasks/SkillExecutionTask.ts +14 -2
- package/src/server/tools/skill-execute.ts +24 -2
- package/src/server/utils/ctx-utils.ts +1 -1
- package/src/server/utils/skill-tool-name.ts +58 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
module.exports = function generate_multipleOf(it, $keyword, $ruleType) {
|
|
3
|
+
var out = ' ';
|
|
4
|
+
var $lvl = it.level;
|
|
5
|
+
var $dataLvl = it.dataLevel;
|
|
6
|
+
var $schema = it.schema[$keyword];
|
|
7
|
+
var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
|
|
8
|
+
var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
|
|
9
|
+
var $breakOnError = !it.opts.allErrors;
|
|
10
|
+
var $data = 'data' + ($dataLvl || '');
|
|
11
|
+
var $isData = it.opts.$data && $schema && $schema.$data,
|
|
12
|
+
$schemaValue;
|
|
13
|
+
if ($isData) {
|
|
14
|
+
out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; ';
|
|
15
|
+
$schemaValue = 'schema' + $lvl;
|
|
16
|
+
} else {
|
|
17
|
+
$schemaValue = $schema;
|
|
18
|
+
}
|
|
19
|
+
if (!($isData || typeof $schema == 'number')) {
|
|
20
|
+
throw new Error($keyword + ' must be number');
|
|
21
|
+
}
|
|
22
|
+
out += 'var division' + ($lvl) + ';if (';
|
|
23
|
+
if ($isData) {
|
|
24
|
+
out += ' ' + ($schemaValue) + ' !== undefined && ( typeof ' + ($schemaValue) + ' != \'number\' || ';
|
|
25
|
+
}
|
|
26
|
+
out += ' (division' + ($lvl) + ' = ' + ($data) + ' / ' + ($schemaValue) + ', ';
|
|
27
|
+
if (it.opts.multipleOfPrecision) {
|
|
28
|
+
out += ' Math.abs(Math.round(division' + ($lvl) + ') - division' + ($lvl) + ') > 1e-' + (it.opts.multipleOfPrecision) + ' ';
|
|
29
|
+
} else {
|
|
30
|
+
out += ' division' + ($lvl) + ' !== parseInt(division' + ($lvl) + ') ';
|
|
31
|
+
}
|
|
32
|
+
out += ' ) ';
|
|
33
|
+
if ($isData) {
|
|
34
|
+
out += ' ) ';
|
|
35
|
+
}
|
|
36
|
+
out += ' ) { ';
|
|
37
|
+
var $$outStack = $$outStack || [];
|
|
38
|
+
$$outStack.push(out);
|
|
39
|
+
out = ''; /* istanbul ignore else */
|
|
40
|
+
if (it.createErrors !== false) {
|
|
41
|
+
out += ' { keyword: \'' + ('multipleOf') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { multipleOf: ' + ($schemaValue) + ' } ';
|
|
42
|
+
if (it.opts.messages !== false) {
|
|
43
|
+
out += ' , message: \'should be multiple of ';
|
|
44
|
+
if ($isData) {
|
|
45
|
+
out += '\' + ' + ($schemaValue);
|
|
46
|
+
} else {
|
|
47
|
+
out += '' + ($schemaValue) + '\'';
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (it.opts.verbose) {
|
|
51
|
+
out += ' , schema: ';
|
|
52
|
+
if ($isData) {
|
|
53
|
+
out += 'validate.schema' + ($schemaPath);
|
|
54
|
+
} else {
|
|
55
|
+
out += '' + ($schema);
|
|
56
|
+
}
|
|
57
|
+
out += ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
|
|
58
|
+
}
|
|
59
|
+
out += ' } ';
|
|
60
|
+
} else {
|
|
61
|
+
out += ' {} ';
|
|
62
|
+
}
|
|
63
|
+
var __err = out;
|
|
64
|
+
out = $$outStack.pop();
|
|
65
|
+
if (!it.compositeRule && $breakOnError) {
|
|
66
|
+
/* istanbul ignore if */
|
|
67
|
+
if (it.async) {
|
|
68
|
+
out += ' throw new ValidationError([' + (__err) + ']); ';
|
|
69
|
+
} else {
|
|
70
|
+
out += ' validate.errors = [' + (__err) + ']; return false; ';
|
|
71
|
+
}
|
|
72
|
+
} else {
|
|
73
|
+
out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
|
|
74
|
+
}
|
|
75
|
+
out += '} ';
|
|
76
|
+
if ($breakOnError) {
|
|
77
|
+
out += ' else { ';
|
|
78
|
+
}
|
|
79
|
+
return out;
|
|
80
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
module.exports = function generate_not(it, $keyword, $ruleType) {
|
|
3
|
+
var out = ' ';
|
|
4
|
+
var $lvl = it.level;
|
|
5
|
+
var $dataLvl = it.dataLevel;
|
|
6
|
+
var $schema = it.schema[$keyword];
|
|
7
|
+
var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
|
|
8
|
+
var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
|
|
9
|
+
var $breakOnError = !it.opts.allErrors;
|
|
10
|
+
var $data = 'data' + ($dataLvl || '');
|
|
11
|
+
var $errs = 'errs__' + $lvl;
|
|
12
|
+
var $it = it.util.copy(it);
|
|
13
|
+
$it.level++;
|
|
14
|
+
var $nextValid = 'valid' + $it.level;
|
|
15
|
+
if ((it.opts.strictKeywords ? (typeof $schema == 'object' && Object.keys($schema).length > 0) || $schema === false : it.util.schemaHasRules($schema, it.RULES.all))) {
|
|
16
|
+
$it.schema = $schema;
|
|
17
|
+
$it.schemaPath = $schemaPath;
|
|
18
|
+
$it.errSchemaPath = $errSchemaPath;
|
|
19
|
+
out += ' var ' + ($errs) + ' = errors; ';
|
|
20
|
+
var $wasComposite = it.compositeRule;
|
|
21
|
+
it.compositeRule = $it.compositeRule = true;
|
|
22
|
+
$it.createErrors = false;
|
|
23
|
+
var $allErrorsOption;
|
|
24
|
+
if ($it.opts.allErrors) {
|
|
25
|
+
$allErrorsOption = $it.opts.allErrors;
|
|
26
|
+
$it.opts.allErrors = false;
|
|
27
|
+
}
|
|
28
|
+
out += ' ' + (it.validate($it)) + ' ';
|
|
29
|
+
$it.createErrors = true;
|
|
30
|
+
if ($allErrorsOption) $it.opts.allErrors = $allErrorsOption;
|
|
31
|
+
it.compositeRule = $it.compositeRule = $wasComposite;
|
|
32
|
+
out += ' if (' + ($nextValid) + ') { ';
|
|
33
|
+
var $$outStack = $$outStack || [];
|
|
34
|
+
$$outStack.push(out);
|
|
35
|
+
out = ''; /* istanbul ignore else */
|
|
36
|
+
if (it.createErrors !== false) {
|
|
37
|
+
out += ' { keyword: \'' + ('not') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: {} ';
|
|
38
|
+
if (it.opts.messages !== false) {
|
|
39
|
+
out += ' , message: \'should NOT be valid\' ';
|
|
40
|
+
}
|
|
41
|
+
if (it.opts.verbose) {
|
|
42
|
+
out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
|
|
43
|
+
}
|
|
44
|
+
out += ' } ';
|
|
45
|
+
} else {
|
|
46
|
+
out += ' {} ';
|
|
47
|
+
}
|
|
48
|
+
var __err = out;
|
|
49
|
+
out = $$outStack.pop();
|
|
50
|
+
if (!it.compositeRule && $breakOnError) {
|
|
51
|
+
/* istanbul ignore if */
|
|
52
|
+
if (it.async) {
|
|
53
|
+
out += ' throw new ValidationError([' + (__err) + ']); ';
|
|
54
|
+
} else {
|
|
55
|
+
out += ' validate.errors = [' + (__err) + ']; return false; ';
|
|
56
|
+
}
|
|
57
|
+
} else {
|
|
58
|
+
out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
|
|
59
|
+
}
|
|
60
|
+
out += ' } else { errors = ' + ($errs) + '; if (vErrors !== null) { if (' + ($errs) + ') vErrors.length = ' + ($errs) + '; else vErrors = null; } ';
|
|
61
|
+
if (it.opts.allErrors) {
|
|
62
|
+
out += ' } ';
|
|
63
|
+
}
|
|
64
|
+
} else {
|
|
65
|
+
out += ' var err = '; /* istanbul ignore else */
|
|
66
|
+
if (it.createErrors !== false) {
|
|
67
|
+
out += ' { keyword: \'' + ('not') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: {} ';
|
|
68
|
+
if (it.opts.messages !== false) {
|
|
69
|
+
out += ' , message: \'should NOT be valid\' ';
|
|
70
|
+
}
|
|
71
|
+
if (it.opts.verbose) {
|
|
72
|
+
out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
|
|
73
|
+
}
|
|
74
|
+
out += ' } ';
|
|
75
|
+
} else {
|
|
76
|
+
out += ' {} ';
|
|
77
|
+
}
|
|
78
|
+
out += '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
|
|
79
|
+
if ($breakOnError) {
|
|
80
|
+
out += ' if (false) { ';
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return out;
|
|
84
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
module.exports = function generate_oneOf(it, $keyword, $ruleType) {
|
|
3
|
+
var out = ' ';
|
|
4
|
+
var $lvl = it.level;
|
|
5
|
+
var $dataLvl = it.dataLevel;
|
|
6
|
+
var $schema = it.schema[$keyword];
|
|
7
|
+
var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
|
|
8
|
+
var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
|
|
9
|
+
var $breakOnError = !it.opts.allErrors;
|
|
10
|
+
var $data = 'data' + ($dataLvl || '');
|
|
11
|
+
var $valid = 'valid' + $lvl;
|
|
12
|
+
var $errs = 'errs__' + $lvl;
|
|
13
|
+
var $it = it.util.copy(it);
|
|
14
|
+
var $closingBraces = '';
|
|
15
|
+
$it.level++;
|
|
16
|
+
var $nextValid = 'valid' + $it.level;
|
|
17
|
+
var $currentBaseId = $it.baseId,
|
|
18
|
+
$prevValid = 'prevValid' + $lvl,
|
|
19
|
+
$passingSchemas = 'passingSchemas' + $lvl;
|
|
20
|
+
out += 'var ' + ($errs) + ' = errors , ' + ($prevValid) + ' = false , ' + ($valid) + ' = false , ' + ($passingSchemas) + ' = null; ';
|
|
21
|
+
var $wasComposite = it.compositeRule;
|
|
22
|
+
it.compositeRule = $it.compositeRule = true;
|
|
23
|
+
var arr1 = $schema;
|
|
24
|
+
if (arr1) {
|
|
25
|
+
var $sch, $i = -1,
|
|
26
|
+
l1 = arr1.length - 1;
|
|
27
|
+
while ($i < l1) {
|
|
28
|
+
$sch = arr1[$i += 1];
|
|
29
|
+
if ((it.opts.strictKeywords ? (typeof $sch == 'object' && Object.keys($sch).length > 0) || $sch === false : it.util.schemaHasRules($sch, it.RULES.all))) {
|
|
30
|
+
$it.schema = $sch;
|
|
31
|
+
$it.schemaPath = $schemaPath + '[' + $i + ']';
|
|
32
|
+
$it.errSchemaPath = $errSchemaPath + '/' + $i;
|
|
33
|
+
out += ' ' + (it.validate($it)) + ' ';
|
|
34
|
+
$it.baseId = $currentBaseId;
|
|
35
|
+
} else {
|
|
36
|
+
out += ' var ' + ($nextValid) + ' = true; ';
|
|
37
|
+
}
|
|
38
|
+
if ($i) {
|
|
39
|
+
out += ' if (' + ($nextValid) + ' && ' + ($prevValid) + ') { ' + ($valid) + ' = false; ' + ($passingSchemas) + ' = [' + ($passingSchemas) + ', ' + ($i) + ']; } else { ';
|
|
40
|
+
$closingBraces += '}';
|
|
41
|
+
}
|
|
42
|
+
out += ' if (' + ($nextValid) + ') { ' + ($valid) + ' = ' + ($prevValid) + ' = true; ' + ($passingSchemas) + ' = ' + ($i) + '; }';
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
it.compositeRule = $it.compositeRule = $wasComposite;
|
|
46
|
+
out += '' + ($closingBraces) + 'if (!' + ($valid) + ') { var err = '; /* istanbul ignore else */
|
|
47
|
+
if (it.createErrors !== false) {
|
|
48
|
+
out += ' { keyword: \'' + ('oneOf') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { passingSchemas: ' + ($passingSchemas) + ' } ';
|
|
49
|
+
if (it.opts.messages !== false) {
|
|
50
|
+
out += ' , message: \'should match exactly one schema in oneOf\' ';
|
|
51
|
+
}
|
|
52
|
+
if (it.opts.verbose) {
|
|
53
|
+
out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
|
|
54
|
+
}
|
|
55
|
+
out += ' } ';
|
|
56
|
+
} else {
|
|
57
|
+
out += ' {} ';
|
|
58
|
+
}
|
|
59
|
+
out += '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
|
|
60
|
+
if (!it.compositeRule && $breakOnError) {
|
|
61
|
+
/* istanbul ignore if */
|
|
62
|
+
if (it.async) {
|
|
63
|
+
out += ' throw new ValidationError(vErrors); ';
|
|
64
|
+
} else {
|
|
65
|
+
out += ' validate.errors = vErrors; return false; ';
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
out += '} else { errors = ' + ($errs) + '; if (vErrors !== null) { if (' + ($errs) + ') vErrors.length = ' + ($errs) + '; else vErrors = null; }';
|
|
69
|
+
if (it.opts.allErrors) {
|
|
70
|
+
out += ' } ';
|
|
71
|
+
}
|
|
72
|
+
return out;
|
|
73
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
module.exports = function generate_pattern(it, $keyword, $ruleType) {
|
|
3
|
+
var out = ' ';
|
|
4
|
+
var $lvl = it.level;
|
|
5
|
+
var $dataLvl = it.dataLevel;
|
|
6
|
+
var $schema = it.schema[$keyword];
|
|
7
|
+
var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
|
|
8
|
+
var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
|
|
9
|
+
var $breakOnError = !it.opts.allErrors;
|
|
10
|
+
var $data = 'data' + ($dataLvl || '');
|
|
11
|
+
var $isData = it.opts.$data && $schema && $schema.$data,
|
|
12
|
+
$schemaValue;
|
|
13
|
+
if ($isData) {
|
|
14
|
+
out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; ';
|
|
15
|
+
$schemaValue = 'schema' + $lvl;
|
|
16
|
+
} else {
|
|
17
|
+
$schemaValue = $schema;
|
|
18
|
+
}
|
|
19
|
+
var $regexp = $isData ? '(new RegExp(' + $schemaValue + '))' : it.usePattern($schema);
|
|
20
|
+
out += 'if ( ';
|
|
21
|
+
if ($isData) {
|
|
22
|
+
out += ' (' + ($schemaValue) + ' !== undefined && typeof ' + ($schemaValue) + ' != \'string\') || ';
|
|
23
|
+
}
|
|
24
|
+
out += ' !' + ($regexp) + '.test(' + ($data) + ') ) { ';
|
|
25
|
+
var $$outStack = $$outStack || [];
|
|
26
|
+
$$outStack.push(out);
|
|
27
|
+
out = ''; /* istanbul ignore else */
|
|
28
|
+
if (it.createErrors !== false) {
|
|
29
|
+
out += ' { keyword: \'' + ('pattern') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { pattern: ';
|
|
30
|
+
if ($isData) {
|
|
31
|
+
out += '' + ($schemaValue);
|
|
32
|
+
} else {
|
|
33
|
+
out += '' + (it.util.toQuotedString($schema));
|
|
34
|
+
}
|
|
35
|
+
out += ' } ';
|
|
36
|
+
if (it.opts.messages !== false) {
|
|
37
|
+
out += ' , message: \'should match pattern "';
|
|
38
|
+
if ($isData) {
|
|
39
|
+
out += '\' + ' + ($schemaValue) + ' + \'';
|
|
40
|
+
} else {
|
|
41
|
+
out += '' + (it.util.escapeQuotes($schema));
|
|
42
|
+
}
|
|
43
|
+
out += '"\' ';
|
|
44
|
+
}
|
|
45
|
+
if (it.opts.verbose) {
|
|
46
|
+
out += ' , schema: ';
|
|
47
|
+
if ($isData) {
|
|
48
|
+
out += 'validate.schema' + ($schemaPath);
|
|
49
|
+
} else {
|
|
50
|
+
out += '' + (it.util.toQuotedString($schema));
|
|
51
|
+
}
|
|
52
|
+
out += ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
|
|
53
|
+
}
|
|
54
|
+
out += ' } ';
|
|
55
|
+
} else {
|
|
56
|
+
out += ' {} ';
|
|
57
|
+
}
|
|
58
|
+
var __err = out;
|
|
59
|
+
out = $$outStack.pop();
|
|
60
|
+
if (!it.compositeRule && $breakOnError) {
|
|
61
|
+
/* istanbul ignore if */
|
|
62
|
+
if (it.async) {
|
|
63
|
+
out += ' throw new ValidationError([' + (__err) + ']); ';
|
|
64
|
+
} else {
|
|
65
|
+
out += ' validate.errors = [' + (__err) + ']; return false; ';
|
|
66
|
+
}
|
|
67
|
+
} else {
|
|
68
|
+
out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
|
|
69
|
+
}
|
|
70
|
+
out += '} ';
|
|
71
|
+
if ($breakOnError) {
|
|
72
|
+
out += ' else { ';
|
|
73
|
+
}
|
|
74
|
+
return out;
|
|
75
|
+
}
|
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
module.exports = function generate_properties(it, $keyword, $ruleType) {
|
|
3
|
+
var out = ' ';
|
|
4
|
+
var $lvl = it.level;
|
|
5
|
+
var $dataLvl = it.dataLevel;
|
|
6
|
+
var $schema = it.schema[$keyword];
|
|
7
|
+
var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
|
|
8
|
+
var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
|
|
9
|
+
var $breakOnError = !it.opts.allErrors;
|
|
10
|
+
var $data = 'data' + ($dataLvl || '');
|
|
11
|
+
var $errs = 'errs__' + $lvl;
|
|
12
|
+
var $it = it.util.copy(it);
|
|
13
|
+
var $closingBraces = '';
|
|
14
|
+
$it.level++;
|
|
15
|
+
var $nextValid = 'valid' + $it.level;
|
|
16
|
+
var $key = 'key' + $lvl,
|
|
17
|
+
$idx = 'idx' + $lvl,
|
|
18
|
+
$dataNxt = $it.dataLevel = it.dataLevel + 1,
|
|
19
|
+
$nextData = 'data' + $dataNxt,
|
|
20
|
+
$dataProperties = 'dataProperties' + $lvl;
|
|
21
|
+
var $schemaKeys = Object.keys($schema || {}).filter(notProto),
|
|
22
|
+
$pProperties = it.schema.patternProperties || {},
|
|
23
|
+
$pPropertyKeys = Object.keys($pProperties).filter(notProto),
|
|
24
|
+
$aProperties = it.schema.additionalProperties,
|
|
25
|
+
$someProperties = $schemaKeys.length || $pPropertyKeys.length,
|
|
26
|
+
$noAdditional = $aProperties === false,
|
|
27
|
+
$additionalIsSchema = typeof $aProperties == 'object' && Object.keys($aProperties).length,
|
|
28
|
+
$removeAdditional = it.opts.removeAdditional,
|
|
29
|
+
$checkAdditional = $noAdditional || $additionalIsSchema || $removeAdditional,
|
|
30
|
+
$ownProperties = it.opts.ownProperties,
|
|
31
|
+
$currentBaseId = it.baseId;
|
|
32
|
+
var $required = it.schema.required;
|
|
33
|
+
if ($required && !(it.opts.$data && $required.$data) && $required.length < it.opts.loopRequired) {
|
|
34
|
+
var $requiredHash = it.util.toHash($required);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function notProto(p) {
|
|
38
|
+
return p !== '__proto__';
|
|
39
|
+
}
|
|
40
|
+
out += 'var ' + ($errs) + ' = errors;var ' + ($nextValid) + ' = true;';
|
|
41
|
+
if ($ownProperties) {
|
|
42
|
+
out += ' var ' + ($dataProperties) + ' = undefined;';
|
|
43
|
+
}
|
|
44
|
+
if ($checkAdditional) {
|
|
45
|
+
if ($ownProperties) {
|
|
46
|
+
out += ' ' + ($dataProperties) + ' = ' + ($dataProperties) + ' || Object.keys(' + ($data) + '); for (var ' + ($idx) + '=0; ' + ($idx) + '<' + ($dataProperties) + '.length; ' + ($idx) + '++) { var ' + ($key) + ' = ' + ($dataProperties) + '[' + ($idx) + ']; ';
|
|
47
|
+
} else {
|
|
48
|
+
out += ' for (var ' + ($key) + ' in ' + ($data) + ') { ';
|
|
49
|
+
}
|
|
50
|
+
if ($someProperties) {
|
|
51
|
+
out += ' var isAdditional' + ($lvl) + ' = !(false ';
|
|
52
|
+
if ($schemaKeys.length) {
|
|
53
|
+
if ($schemaKeys.length > 8) {
|
|
54
|
+
out += ' || validate.schema' + ($schemaPath) + '.hasOwnProperty(' + ($key) + ') ';
|
|
55
|
+
} else {
|
|
56
|
+
var arr1 = $schemaKeys;
|
|
57
|
+
if (arr1) {
|
|
58
|
+
var $propertyKey, i1 = -1,
|
|
59
|
+
l1 = arr1.length - 1;
|
|
60
|
+
while (i1 < l1) {
|
|
61
|
+
$propertyKey = arr1[i1 += 1];
|
|
62
|
+
out += ' || ' + ($key) + ' == ' + (it.util.toQuotedString($propertyKey)) + ' ';
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if ($pPropertyKeys.length) {
|
|
68
|
+
var arr2 = $pPropertyKeys;
|
|
69
|
+
if (arr2) {
|
|
70
|
+
var $pProperty, $i = -1,
|
|
71
|
+
l2 = arr2.length - 1;
|
|
72
|
+
while ($i < l2) {
|
|
73
|
+
$pProperty = arr2[$i += 1];
|
|
74
|
+
out += ' || ' + (it.usePattern($pProperty)) + '.test(' + ($key) + ') ';
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
out += ' ); if (isAdditional' + ($lvl) + ') { ';
|
|
79
|
+
}
|
|
80
|
+
if ($removeAdditional == 'all') {
|
|
81
|
+
out += ' delete ' + ($data) + '[' + ($key) + ']; ';
|
|
82
|
+
} else {
|
|
83
|
+
var $currentErrorPath = it.errorPath;
|
|
84
|
+
var $additionalProperty = '\' + ' + $key + ' + \'';
|
|
85
|
+
if (it.opts._errorDataPathProperty) {
|
|
86
|
+
it.errorPath = it.util.getPathExpr(it.errorPath, $key, it.opts.jsonPointers);
|
|
87
|
+
}
|
|
88
|
+
if ($noAdditional) {
|
|
89
|
+
if ($removeAdditional) {
|
|
90
|
+
out += ' delete ' + ($data) + '[' + ($key) + ']; ';
|
|
91
|
+
} else {
|
|
92
|
+
out += ' ' + ($nextValid) + ' = false; ';
|
|
93
|
+
var $currErrSchemaPath = $errSchemaPath;
|
|
94
|
+
$errSchemaPath = it.errSchemaPath + '/additionalProperties';
|
|
95
|
+
var $$outStack = $$outStack || [];
|
|
96
|
+
$$outStack.push(out);
|
|
97
|
+
out = ''; /* istanbul ignore else */
|
|
98
|
+
if (it.createErrors !== false) {
|
|
99
|
+
out += ' { keyword: \'' + ('additionalProperties') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { additionalProperty: \'' + ($additionalProperty) + '\' } ';
|
|
100
|
+
if (it.opts.messages !== false) {
|
|
101
|
+
out += ' , message: \'';
|
|
102
|
+
if (it.opts._errorDataPathProperty) {
|
|
103
|
+
out += 'is an invalid additional property';
|
|
104
|
+
} else {
|
|
105
|
+
out += 'should NOT have additional properties';
|
|
106
|
+
}
|
|
107
|
+
out += '\' ';
|
|
108
|
+
}
|
|
109
|
+
if (it.opts.verbose) {
|
|
110
|
+
out += ' , schema: false , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
|
|
111
|
+
}
|
|
112
|
+
out += ' } ';
|
|
113
|
+
} else {
|
|
114
|
+
out += ' {} ';
|
|
115
|
+
}
|
|
116
|
+
var __err = out;
|
|
117
|
+
out = $$outStack.pop();
|
|
118
|
+
if (!it.compositeRule && $breakOnError) {
|
|
119
|
+
/* istanbul ignore if */
|
|
120
|
+
if (it.async) {
|
|
121
|
+
out += ' throw new ValidationError([' + (__err) + ']); ';
|
|
122
|
+
} else {
|
|
123
|
+
out += ' validate.errors = [' + (__err) + ']; return false; ';
|
|
124
|
+
}
|
|
125
|
+
} else {
|
|
126
|
+
out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
|
|
127
|
+
}
|
|
128
|
+
$errSchemaPath = $currErrSchemaPath;
|
|
129
|
+
if ($breakOnError) {
|
|
130
|
+
out += ' break; ';
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
} else if ($additionalIsSchema) {
|
|
134
|
+
if ($removeAdditional == 'failing') {
|
|
135
|
+
out += ' var ' + ($errs) + ' = errors; ';
|
|
136
|
+
var $wasComposite = it.compositeRule;
|
|
137
|
+
it.compositeRule = $it.compositeRule = true;
|
|
138
|
+
$it.schema = $aProperties;
|
|
139
|
+
$it.schemaPath = it.schemaPath + '.additionalProperties';
|
|
140
|
+
$it.errSchemaPath = it.errSchemaPath + '/additionalProperties';
|
|
141
|
+
$it.errorPath = it.opts._errorDataPathProperty ? it.errorPath : it.util.getPathExpr(it.errorPath, $key, it.opts.jsonPointers);
|
|
142
|
+
var $passData = $data + '[' + $key + ']';
|
|
143
|
+
$it.dataPathArr[$dataNxt] = $key;
|
|
144
|
+
var $code = it.validate($it);
|
|
145
|
+
$it.baseId = $currentBaseId;
|
|
146
|
+
if (it.util.varOccurences($code, $nextData) < 2) {
|
|
147
|
+
out += ' ' + (it.util.varReplace($code, $nextData, $passData)) + ' ';
|
|
148
|
+
} else {
|
|
149
|
+
out += ' var ' + ($nextData) + ' = ' + ($passData) + '; ' + ($code) + ' ';
|
|
150
|
+
}
|
|
151
|
+
out += ' if (!' + ($nextValid) + ') { errors = ' + ($errs) + '; if (validate.errors !== null) { if (errors) validate.errors.length = errors; else validate.errors = null; } delete ' + ($data) + '[' + ($key) + ']; } ';
|
|
152
|
+
it.compositeRule = $it.compositeRule = $wasComposite;
|
|
153
|
+
} else {
|
|
154
|
+
$it.schema = $aProperties;
|
|
155
|
+
$it.schemaPath = it.schemaPath + '.additionalProperties';
|
|
156
|
+
$it.errSchemaPath = it.errSchemaPath + '/additionalProperties';
|
|
157
|
+
$it.errorPath = it.opts._errorDataPathProperty ? it.errorPath : it.util.getPathExpr(it.errorPath, $key, it.opts.jsonPointers);
|
|
158
|
+
var $passData = $data + '[' + $key + ']';
|
|
159
|
+
$it.dataPathArr[$dataNxt] = $key;
|
|
160
|
+
var $code = it.validate($it);
|
|
161
|
+
$it.baseId = $currentBaseId;
|
|
162
|
+
if (it.util.varOccurences($code, $nextData) < 2) {
|
|
163
|
+
out += ' ' + (it.util.varReplace($code, $nextData, $passData)) + ' ';
|
|
164
|
+
} else {
|
|
165
|
+
out += ' var ' + ($nextData) + ' = ' + ($passData) + '; ' + ($code) + ' ';
|
|
166
|
+
}
|
|
167
|
+
if ($breakOnError) {
|
|
168
|
+
out += ' if (!' + ($nextValid) + ') break; ';
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
it.errorPath = $currentErrorPath;
|
|
173
|
+
}
|
|
174
|
+
if ($someProperties) {
|
|
175
|
+
out += ' } ';
|
|
176
|
+
}
|
|
177
|
+
out += ' } ';
|
|
178
|
+
if ($breakOnError) {
|
|
179
|
+
out += ' if (' + ($nextValid) + ') { ';
|
|
180
|
+
$closingBraces += '}';
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
var $useDefaults = it.opts.useDefaults && !it.compositeRule;
|
|
184
|
+
if ($schemaKeys.length) {
|
|
185
|
+
var arr3 = $schemaKeys;
|
|
186
|
+
if (arr3) {
|
|
187
|
+
var $propertyKey, i3 = -1,
|
|
188
|
+
l3 = arr3.length - 1;
|
|
189
|
+
while (i3 < l3) {
|
|
190
|
+
$propertyKey = arr3[i3 += 1];
|
|
191
|
+
var $sch = $schema[$propertyKey];
|
|
192
|
+
if ((it.opts.strictKeywords ? (typeof $sch == 'object' && Object.keys($sch).length > 0) || $sch === false : it.util.schemaHasRules($sch, it.RULES.all))) {
|
|
193
|
+
var $prop = it.util.getProperty($propertyKey),
|
|
194
|
+
$passData = $data + $prop,
|
|
195
|
+
$hasDefault = $useDefaults && $sch.default !== undefined;
|
|
196
|
+
$it.schema = $sch;
|
|
197
|
+
$it.schemaPath = $schemaPath + $prop;
|
|
198
|
+
$it.errSchemaPath = $errSchemaPath + '/' + it.util.escapeFragment($propertyKey);
|
|
199
|
+
$it.errorPath = it.util.getPath(it.errorPath, $propertyKey, it.opts.jsonPointers);
|
|
200
|
+
$it.dataPathArr[$dataNxt] = it.util.toQuotedString($propertyKey);
|
|
201
|
+
var $code = it.validate($it);
|
|
202
|
+
$it.baseId = $currentBaseId;
|
|
203
|
+
if (it.util.varOccurences($code, $nextData) < 2) {
|
|
204
|
+
$code = it.util.varReplace($code, $nextData, $passData);
|
|
205
|
+
var $useData = $passData;
|
|
206
|
+
} else {
|
|
207
|
+
var $useData = $nextData;
|
|
208
|
+
out += ' var ' + ($nextData) + ' = ' + ($passData) + '; ';
|
|
209
|
+
}
|
|
210
|
+
if ($hasDefault) {
|
|
211
|
+
out += ' ' + ($code) + ' ';
|
|
212
|
+
} else {
|
|
213
|
+
if ($requiredHash && $requiredHash[$propertyKey]) {
|
|
214
|
+
out += ' if ( ' + ($useData) + ' === undefined ';
|
|
215
|
+
if ($ownProperties) {
|
|
216
|
+
out += ' || ! Object.prototype.hasOwnProperty.call(' + ($data) + ', \'' + (it.util.escapeQuotes($propertyKey)) + '\') ';
|
|
217
|
+
}
|
|
218
|
+
out += ') { ' + ($nextValid) + ' = false; ';
|
|
219
|
+
var $currentErrorPath = it.errorPath,
|
|
220
|
+
$currErrSchemaPath = $errSchemaPath,
|
|
221
|
+
$missingProperty = it.util.escapeQuotes($propertyKey);
|
|
222
|
+
if (it.opts._errorDataPathProperty) {
|
|
223
|
+
it.errorPath = it.util.getPath($currentErrorPath, $propertyKey, it.opts.jsonPointers);
|
|
224
|
+
}
|
|
225
|
+
$errSchemaPath = it.errSchemaPath + '/required';
|
|
226
|
+
var $$outStack = $$outStack || [];
|
|
227
|
+
$$outStack.push(out);
|
|
228
|
+
out = ''; /* istanbul ignore else */
|
|
229
|
+
if (it.createErrors !== false) {
|
|
230
|
+
out += ' { keyword: \'' + ('required') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { missingProperty: \'' + ($missingProperty) + '\' } ';
|
|
231
|
+
if (it.opts.messages !== false) {
|
|
232
|
+
out += ' , message: \'';
|
|
233
|
+
if (it.opts._errorDataPathProperty) {
|
|
234
|
+
out += 'is a required property';
|
|
235
|
+
} else {
|
|
236
|
+
out += 'should have required property \\\'' + ($missingProperty) + '\\\'';
|
|
237
|
+
}
|
|
238
|
+
out += '\' ';
|
|
239
|
+
}
|
|
240
|
+
if (it.opts.verbose) {
|
|
241
|
+
out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
|
|
242
|
+
}
|
|
243
|
+
out += ' } ';
|
|
244
|
+
} else {
|
|
245
|
+
out += ' {} ';
|
|
246
|
+
}
|
|
247
|
+
var __err = out;
|
|
248
|
+
out = $$outStack.pop();
|
|
249
|
+
if (!it.compositeRule && $breakOnError) {
|
|
250
|
+
/* istanbul ignore if */
|
|
251
|
+
if (it.async) {
|
|
252
|
+
out += ' throw new ValidationError([' + (__err) + ']); ';
|
|
253
|
+
} else {
|
|
254
|
+
out += ' validate.errors = [' + (__err) + ']; return false; ';
|
|
255
|
+
}
|
|
256
|
+
} else {
|
|
257
|
+
out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
|
|
258
|
+
}
|
|
259
|
+
$errSchemaPath = $currErrSchemaPath;
|
|
260
|
+
it.errorPath = $currentErrorPath;
|
|
261
|
+
out += ' } else { ';
|
|
262
|
+
} else {
|
|
263
|
+
if ($breakOnError) {
|
|
264
|
+
out += ' if ( ' + ($useData) + ' === undefined ';
|
|
265
|
+
if ($ownProperties) {
|
|
266
|
+
out += ' || ! Object.prototype.hasOwnProperty.call(' + ($data) + ', \'' + (it.util.escapeQuotes($propertyKey)) + '\') ';
|
|
267
|
+
}
|
|
268
|
+
out += ') { ' + ($nextValid) + ' = true; } else { ';
|
|
269
|
+
} else {
|
|
270
|
+
out += ' if (' + ($useData) + ' !== undefined ';
|
|
271
|
+
if ($ownProperties) {
|
|
272
|
+
out += ' && Object.prototype.hasOwnProperty.call(' + ($data) + ', \'' + (it.util.escapeQuotes($propertyKey)) + '\') ';
|
|
273
|
+
}
|
|
274
|
+
out += ' ) { ';
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
out += ' ' + ($code) + ' } ';
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
if ($breakOnError) {
|
|
281
|
+
out += ' if (' + ($nextValid) + ') { ';
|
|
282
|
+
$closingBraces += '}';
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
if ($pPropertyKeys.length) {
|
|
288
|
+
var arr4 = $pPropertyKeys;
|
|
289
|
+
if (arr4) {
|
|
290
|
+
var $pProperty, i4 = -1,
|
|
291
|
+
l4 = arr4.length - 1;
|
|
292
|
+
while (i4 < l4) {
|
|
293
|
+
$pProperty = arr4[i4 += 1];
|
|
294
|
+
var $sch = $pProperties[$pProperty];
|
|
295
|
+
if ((it.opts.strictKeywords ? (typeof $sch == 'object' && Object.keys($sch).length > 0) || $sch === false : it.util.schemaHasRules($sch, it.RULES.all))) {
|
|
296
|
+
$it.schema = $sch;
|
|
297
|
+
$it.schemaPath = it.schemaPath + '.patternProperties' + it.util.getProperty($pProperty);
|
|
298
|
+
$it.errSchemaPath = it.errSchemaPath + '/patternProperties/' + it.util.escapeFragment($pProperty);
|
|
299
|
+
if ($ownProperties) {
|
|
300
|
+
out += ' ' + ($dataProperties) + ' = ' + ($dataProperties) + ' || Object.keys(' + ($data) + '); for (var ' + ($idx) + '=0; ' + ($idx) + '<' + ($dataProperties) + '.length; ' + ($idx) + '++) { var ' + ($key) + ' = ' + ($dataProperties) + '[' + ($idx) + ']; ';
|
|
301
|
+
} else {
|
|
302
|
+
out += ' for (var ' + ($key) + ' in ' + ($data) + ') { ';
|
|
303
|
+
}
|
|
304
|
+
out += ' if (' + (it.usePattern($pProperty)) + '.test(' + ($key) + ')) { ';
|
|
305
|
+
$it.errorPath = it.util.getPathExpr(it.errorPath, $key, it.opts.jsonPointers);
|
|
306
|
+
var $passData = $data + '[' + $key + ']';
|
|
307
|
+
$it.dataPathArr[$dataNxt] = $key;
|
|
308
|
+
var $code = it.validate($it);
|
|
309
|
+
$it.baseId = $currentBaseId;
|
|
310
|
+
if (it.util.varOccurences($code, $nextData) < 2) {
|
|
311
|
+
out += ' ' + (it.util.varReplace($code, $nextData, $passData)) + ' ';
|
|
312
|
+
} else {
|
|
313
|
+
out += ' var ' + ($nextData) + ' = ' + ($passData) + '; ' + ($code) + ' ';
|
|
314
|
+
}
|
|
315
|
+
if ($breakOnError) {
|
|
316
|
+
out += ' if (!' + ($nextValid) + ') break; ';
|
|
317
|
+
}
|
|
318
|
+
out += ' } ';
|
|
319
|
+
if ($breakOnError) {
|
|
320
|
+
out += ' else ' + ($nextValid) + ' = true; ';
|
|
321
|
+
}
|
|
322
|
+
out += ' } ';
|
|
323
|
+
if ($breakOnError) {
|
|
324
|
+
out += ' if (' + ($nextValid) + ') { ';
|
|
325
|
+
$closingBraces += '}';
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
if ($breakOnError) {
|
|
332
|
+
out += ' ' + ($closingBraces) + ' if (' + ($errs) + ' == errors) {';
|
|
333
|
+
}
|
|
334
|
+
return out;
|
|
335
|
+
}
|