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

Function macroKeywordCode

docs/scripts/ajv-validator.js:3299–3314  ·  view source on GitHub ↗
(cxt, def)

Source from the content-addressed store, hash-verified

3297 const code_1 = __webpack_require__(/*! ../../vocabularies/code */ "./node_modules/ajv/dist/vocabularies/code.js");
3298 const errors_1 = __webpack_require__(/*! ../errors */ "./node_modules/ajv/dist/compile/errors.js");
3299 function macroKeywordCode(cxt, def) {
3300 const { gen, keyword, schema, parentSchema, it } = cxt;
3301 const macroSchema = def.macro.call(it.self, schema, parentSchema, it);
3302 const schemaRef = useKeyword(gen, keyword, macroSchema);
3303 if (it.opts.validateSchema !== false)
3304 it.self.validateSchema(macroSchema, true);
3305 const valid = gen.name("valid");
3306 cxt.subschema({
3307 schema: macroSchema,
3308 schemaPath: codegen_1.nil,
3309 errSchemaPath: `${it.errSchemaPath}/${keyword}`,
3310 topSchemaRef: schemaRef,
3311 compositeRule: true,
3312 }, valid);
3313 cxt.pass(valid, () => cxt.error(true));
3314 }
3315 exports.macroKeywordCode = macroKeywordCode;
3316 function funcKeywordCode(cxt, def) {
3317 var _a;

Callers

nothing calls this directly

Calls 6

useKeywordFunction · 0.85
validateSchemaMethod · 0.80
subschemaMethod · 0.80
passMethod · 0.80
errorMethod · 0.80
nameMethod · 0.45

Tested by

no test coverage detected