UNPKG

859 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.checkNullableObject = exports.checkNullable = void 0;
4const codegen_1 = require("../../compile/codegen");
5function checkNullable({ gen, data, parentSchema }, cond = codegen_1.nil) {
6 const valid = gen.name("valid");
7 if (parentSchema.nullable) {
8 gen.let(valid, (0, codegen_1._) `${data} === null`);
9 cond = (0, codegen_1.not)(valid);
10 }
11 else {
12 gen.let(valid, false);
13 }
14 return [valid, cond];
15}
16exports.checkNullable = checkNullable;
17function checkNullableObject(cxt, cond) {
18 const [valid, cond_] = checkNullable(cxt, cond);
19 return [valid, (0, codegen_1._) `${cond_} && typeof ${cxt.data} == "object" && !Array.isArray(${cxt.data})`];
20}
21exports.checkNullableObject = checkNullableObject;
22//# sourceMappingURL=nullable.js.map
\No newline at end of file