1 import type {KeywordCxt} from "../../compile/validate"
2 import {_, not, nil, Code, Name} from "../../compile/codegen"
4 export function checkNullable(
5 {gen, data, parentSchema}: KeywordCxt,
8 const valid = gen.name("valid")
9 if (parentSchema.nullable) {
10 gen.let(valid, _`${data} === null`)
18 export function checkNullableObject(cxt: KeywordCxt, cond: Code): [Name, Code] {
19 const [valid, cond_] = checkNullable(cxt, cond)
20 return [valid, _`${cond_} && typeof ${cxt.data} == "object" && !Array.isArray(${cxt.data})`]