1 import type {CodeKeywordDefinition, AnySchema} from "../../types"
2 import type {KeywordCxt} from "../../compile/validate"
3 import {alwaysValidSchema} from "../../compile/util"
5 const def: CodeKeywordDefinition = {
8 code(cxt: KeywordCxt) {
9 const {gen, schema, it} = cxt
10 /* istanbul ignore if */
11 if (!Array.isArray(schema)) throw new Error("ajv implementation error")
12 const valid = gen.name("valid")
13 schema.forEach((sch: AnySchema, i: number) => {
14 if (alwaysValidSchema(it, sch)) return
15 const schCxt = cxt.subschema({keyword: "allOf", schemaProp: i}, valid)
17 cxt.mergeEvaluated(schCxt)