@dzeio/schema 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Schema.js +6 -2
- package/dist/Schema.mjs +6 -2
- package/package.json +1 -1
package/dist/Schema.js
CHANGED
|
@@ -324,7 +324,11 @@ var SchemaNullable = class extends SchemaItem {
|
|
|
324
324
|
return this.child;
|
|
325
325
|
}
|
|
326
326
|
parse(input, options) {
|
|
327
|
-
|
|
327
|
+
const res = super.parse(input, options);
|
|
328
|
+
if (!res.valid) {
|
|
329
|
+
return res;
|
|
330
|
+
}
|
|
331
|
+
if (this.isNull(res.object)) {
|
|
328
332
|
return {
|
|
329
333
|
valid: true,
|
|
330
334
|
object: void 0
|
|
@@ -333,7 +337,7 @@ var SchemaNullable = class extends SchemaItem {
|
|
|
333
337
|
return this.child.parse(input, options);
|
|
334
338
|
}
|
|
335
339
|
isOfType(input) {
|
|
336
|
-
return
|
|
340
|
+
return this.isNull(input) || this.child.isOfType(input);
|
|
337
341
|
}
|
|
338
342
|
isNull(value) {
|
|
339
343
|
return typeof value === "undefined" || value === null;
|
package/dist/Schema.mjs
CHANGED
|
@@ -281,7 +281,11 @@ var SchemaNullable = class extends SchemaItem {
|
|
|
281
281
|
return this.child;
|
|
282
282
|
}
|
|
283
283
|
parse(input, options) {
|
|
284
|
-
|
|
284
|
+
const res = super.parse(input, options);
|
|
285
|
+
if (!res.valid) {
|
|
286
|
+
return res;
|
|
287
|
+
}
|
|
288
|
+
if (this.isNull(res.object)) {
|
|
285
289
|
return {
|
|
286
290
|
valid: true,
|
|
287
291
|
object: void 0
|
|
@@ -290,7 +294,7 @@ var SchemaNullable = class extends SchemaItem {
|
|
|
290
294
|
return this.child.parse(input, options);
|
|
291
295
|
}
|
|
292
296
|
isOfType(input) {
|
|
293
|
-
return
|
|
297
|
+
return this.isNull(input) || this.child.isOfType(input);
|
|
294
298
|
}
|
|
295
299
|
isNull(value) {
|
|
296
300
|
return typeof value === "undefined" || value === null;
|