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

Function validateFormat

docs/scripts/ajv-validator.js:379–395  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

377 cxt.fail$data(codegen_1.or(codegen_1._ `typeof ${fmt} != "object"`, codegen_1._ `${fmt} instanceof RegExp`, codegen_1._ `typeof ${fmt}.compare != "function"`, compareCode(fmt)));
378 }
379 function validateFormat() {
380 const format = fCxt.schema;
381 const fmtDef = self.formats[format];
382 if (!fmtDef || fmtDef === true)
383 return;
384 if (typeof fmtDef != "object" ||
385 fmtDef instanceof RegExp ||
386 typeof fmtDef.compare != "function") {
387 throw new Error(`"${keyword}": format "${format}" does not define "compare" function`);
388 }
389 const fmt = gen.scopeValue("formats", {
390 key: format,
391 ref: fmtDef,
392 code: opts.code.formats ? codegen_1._ `${opts.code.formats}${codegen_1.getProperty(format)}` : undefined,
393 });
394 cxt.fail$data(compareCode(fmt));
395 }
396 function compareCode(fmt) {
397 return codegen_1._ `${fmt}.compare(${data}, ${schemaCode}) ${KWDs[keyword].fail} 0`;
398 }

Callers 1

codeFunction · 0.85

Calls 7

compareCodeFunction · 0.85
unknownFormatFunction · 0.85
getFormatFunction · 0.85
validConditionFunction · 0.85
scopeValueMethod · 0.80
fail$dataMethod · 0.80
passMethod · 0.80

Tested by

no test coverage detected