MCPcopy Create free account
hub / github.com/json-editor/json-editor / validateKeywordUsage

Function validateKeywordUsage

docs/scripts/ajv-validator.js:3393–3413  ·  view source on GitHub ↗
({ schema, opts, self, errSchemaPath }, def, keyword)

Source from the content-addressed store, hash-verified

3391 }
3392 exports.validSchemaType = validSchemaType;
3393 function validateKeywordUsage({ schema, opts, self, errSchemaPath }, def, keyword) {
3394 /* istanbul ignore if */
3395 if (Array.isArray(def.keyword) ? !def.keyword.includes(keyword) : def.keyword !== keyword) {
3396 throw new Error("ajv implementation error");
3397 }
3398 const deps = def.dependencies;
3399 if (deps === null || deps === void 0 ? void 0 : deps.some((kwd) => !Object.prototype.hasOwnProperty.call(schema, kwd))) {
3400 throw new Error(`parent schema must have dependencies of ${keyword}: ${deps.join(",")}`);
3401 }
3402 if (def.validateSchema) {
3403 const valid = def.validateSchema(schema[keyword]);
3404 if (!valid) {
3405 const msg = `keyword "${keyword}" value is invalid at path "${errSchemaPath}": ` +
3406 self.errorsText(def.validateSchema.errors);
3407 if (opts.validateSchema === "log")
3408 self.logger.error(msg);
3409 else
3410 throw new Error(msg);
3411 }
3412 }
3413 }
3414 exports.validateKeywordUsage = validateKeywordUsage;
3415//# sourceMappingURL=keyword.js.map
3416

Callers

nothing calls this directly

Calls 3

validateSchemaMethod · 0.80
errorsTextMethod · 0.80
errorMethod · 0.80

Tested by

no test coverage detected