Last change
on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
844 bytes
|
Line | |
---|
1 | "use strict";
|
---|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
3 | exports.checkNullableObject = exports.checkNullable = void 0;
|
---|
4 | const codegen_1 = require("../../compile/codegen");
|
---|
5 | function checkNullable({ gen, data, parentSchema }, cond = codegen_1.nil) {
|
---|
6 | const valid = gen.name("valid");
|
---|
7 | if (parentSchema.nullable) {
|
---|
8 | gen.let(valid, codegen_1._ `${data} === null`);
|
---|
9 | cond = codegen_1.not(valid);
|
---|
10 | }
|
---|
11 | else {
|
---|
12 | gen.let(valid, false);
|
---|
13 | }
|
---|
14 | return [valid, cond];
|
---|
15 | }
|
---|
16 | exports.checkNullable = checkNullable;
|
---|
17 | function checkNullableObject(cxt, cond) {
|
---|
18 | const [valid, cond_] = checkNullable(cxt, cond);
|
---|
19 | return [valid, codegen_1._ `${cond_} && typeof ${cxt.data} == "object" && !Array.isArray(${cxt.data})`];
|
---|
20 | }
|
---|
21 | exports.checkNullableObject = checkNullableObject;
|
---|
22 | //# sourceMappingURL=nullable.js.map |
---|
Note:
See
TracBrowser
for help on using the repository browser.