This commit is contained in:
2024-03-22 03:47:51 +05:30
parent 8bcf3d211e
commit 89819f6fe2
28440 changed files with 3211033 additions and 2 deletions

21
node_modules/ajv/lib/vocabularies/jtd/nullable.ts generated vendored Normal file
View File

@@ -0,0 +1,21 @@
import type {KeywordCxt} from "../../compile/validate"
import {_, not, nil, Code, Name} from "../../compile/codegen"
export function checkNullable(
{gen, data, parentSchema}: KeywordCxt,
cond: Code = nil
): [Name, Code] {
const valid = gen.name("valid")
if (parentSchema.nullable) {
gen.let(valid, _`${data} === null`)
cond = not(valid)
} else {
gen.let(valid, false)
}
return [valid, cond]
}
export function checkNullableObject(cxt: KeywordCxt, cond: Code): [Name, Code] {
const [valid, cond_] = checkNullable(cxt, cond)
return [valid, _`${cond_} && typeof ${cxt.data} == "object" && !Array.isArray(${cxt.data})`]
}