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

Function validateOneOf

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

Source from the content-addressed store, hash-verified

5147 gen.block(validateOneOf);
5148 cxt.result(valid, () => cxt.reset(), () => cxt.error(true));
5149 function validateOneOf() {
5150 schArr.forEach((sch, i) => {
5151 let schCxt;
5152 if ((0, util_1.alwaysValidSchema)(it, sch)) {
5153 gen.var(schValid, true);
5154 }
5155 else {
5156 schCxt = cxt.subschema({
5157 keyword: "oneOf",
5158 schemaProp: i,
5159 compositeRule: true,
5160 }, schValid);
5161 }
5162 if (i > 0) {
5163 gen
5164 .if((0, codegen_1._) `${schValid} && ${valid}`)
5165 .assign(valid, false)
5166 .assign(passing, (0, codegen_1._) `[${passing}, ${i}]`)
5167 .else();
5168 }
5169 gen.if(schValid, () => {
5170 gen.assign(valid, true);
5171 gen.assign(passing, i);
5172 if (schCxt)
5173 cxt.mergeEvaluated(schCxt, codegen_1.Name);
5174 });
5175 });
5176 }
5177 },
5178 };
5179 exports.default = def;

Callers

nothing calls this directly

Calls 6

varMethod · 0.80
subschemaMethod · 0.80
elseMethod · 0.80
assignMethod · 0.80
mergeEvaluatedMethod · 0.80
ifMethod · 0.45

Tested by

no test coverage detected