@dzeio/schema 0.3.3 → 0.4.0

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.d.mts CHANGED
@@ -194,6 +194,7 @@ declare class SchemaLiteral<Type> extends SchemaItem<Type> {
194
194
  declare class SchemaNullable<Type extends SchemaItem> extends SchemaItem<SchemaInfer<Type> | undefined> {
195
195
  readonly child: Type;
196
196
  constructor(child: Type);
197
+ falthyAsNull(): this;
197
198
  unwrap(): Type;
198
199
  parse(input: unknown, options?: {
199
200
  fast?: boolean;
package/dist/Schema.d.ts CHANGED
@@ -194,6 +194,7 @@ declare class SchemaLiteral<Type> extends SchemaItem<Type> {
194
194
  declare class SchemaNullable<Type extends SchemaItem> extends SchemaItem<SchemaInfer<Type> | undefined> {
195
195
  readonly child: Type;
196
196
  constructor(child: Type);
197
+ falthyAsNull(): this;
197
198
  unwrap(): Type;
198
199
  parse(input: unknown, options?: {
199
200
  fast?: boolean;
package/dist/Schema.js CHANGED
@@ -316,6 +316,10 @@ var SchemaNullable = class extends SchemaItem {
316
316
  super([child]);
317
317
  this.child = child;
318
318
  }
319
+ falthyAsNull() {
320
+ this.addPreProcess((it) => !it ? void 0 : it);
321
+ return this;
322
+ }
319
323
  unwrap() {
320
324
  return this.child;
321
325
  }
@@ -335,6 +339,9 @@ var SchemaNullable = class extends SchemaItem {
335
339
  return typeof value === "undefined" || value === null;
336
340
  }
337
341
  };
342
+ __decorateClass([
343
+ parceable()
344
+ ], SchemaNullable.prototype, "falthyAsNull", 1);
338
345
 
339
346
  // src/items/object.ts
340
347
  var import_object_util2 = require("@dzeio/object-util");
package/dist/Schema.mjs CHANGED
@@ -273,6 +273,10 @@ var SchemaNullable = class extends SchemaItem {
273
273
  super([child]);
274
274
  this.child = child;
275
275
  }
276
+ falthyAsNull() {
277
+ this.addPreProcess((it) => !it ? void 0 : it);
278
+ return this;
279
+ }
276
280
  unwrap() {
277
281
  return this.child;
278
282
  }
@@ -292,6 +296,9 @@ var SchemaNullable = class extends SchemaItem {
292
296
  return typeof value === "undefined" || value === null;
293
297
  }
294
298
  };
299
+ __decorateClass([
300
+ parceable()
301
+ ], SchemaNullable.prototype, "falthyAsNull", 1);
295
302
 
296
303
  // src/items/object.ts
297
304
  import { isObject, objectClone, objectLoop } from "@dzeio/object-util";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dzeio/schema",
3
- "version": "0.3.3",
3
+ "version": "0.4.0",
4
4
  "dependencies": {
5
5
  "@dzeio/object-util": "^1.8.3"
6
6
  },