diff --git a/src/items/nullable.ts b/src/items/nullable.ts index 4a7b732..2cb6cd8 100644 --- a/src/items/nullable.ts +++ b/src/items/nullable.ts @@ -1,9 +1,17 @@ +import { parceable } from 'Schema' import SchemaItem from '../SchemaItem' import { SchemaInfer, ValidationResult } from '../types' export default class SchemaNullable extends SchemaItem | undefined> { public constructor(public readonly child: Type) { super([child]) } + @parceable() + public falthyAsNull() { + this.addPreProcess((it) => !it ? undefined : it) + + return this + } + public unwrap(): Type { return this.child }