@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 CHANGED
@@ -324,7 +324,11 @@ var SchemaNullable = class extends SchemaItem {
324
324
  return this.child;
325
325
  }
326
326
  parse(input, options) {
327
- if (this.isNull(input)) {
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 Array.isArray(input);
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
- if (this.isNull(input)) {
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 Array.isArray(input);
297
+ return this.isNull(input) || this.child.isOfType(input);
294
298
  }
295
299
  isNull(value) {
296
300
  return typeof value === "undefined" || value === null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dzeio/schema",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "dependencies": {
5
5
  "@dzeio/object-util": "^1.8.3"
6
6
  },