Urara-Blog/node_modules/.pnpm-store/v3/files/c4/616c68f23199ec8b142d529cf71dfef9f9307d4b0f9d477c55858dfb05c68ad0061be84dd22ccf45b33fa2752d3a804bb624b60060f47dac653ea9f7ef411d
2022-08-14 01:14:53 +08:00

22 lines
717 B
Text

import type {CodeKeywordDefinition, AnySchema} from "../../types"
import type {KeywordCxt} from "../../compile/validate"
import {alwaysValidSchema} from "../../compile/util"
const def: CodeKeywordDefinition = {
keyword: "allOf",
schemaType: "array",
code(cxt: KeywordCxt) {
const {gen, schema, it} = cxt
/* istanbul ignore if */
if (!Array.isArray(schema)) throw new Error("ajv implementation error")
const valid = gen.name("valid")
schema.forEach((sch: AnySchema, i: number) => {
if (alwaysValidSchema(it, sch)) return
const schCxt = cxt.subschema({keyword: "allOf", schemaProp: i}, valid)
cxt.ok(valid)
cxt.mergeEvaluated(schCxt)
})
},
}
export default def