thenElse.ts 441 B

12345678910111213
  1. import type {CodeKeywordDefinition} from "../../types"
  2. import type {KeywordCxt} from "../../compile/validate"
  3. import {checkStrictMode} from "../../compile/util"
  4. const def: CodeKeywordDefinition = {
  5. keyword: ["then", "else"],
  6. schemaType: ["object", "boolean"],
  7. code({keyword, parentSchema, it}: KeywordCxt) {
  8. if (parentSchema.if === undefined) checkStrictMode(it, `"${keyword}" without "if" is ignored`)
  9. },
  10. }
  11. export default def