Compare commits

...

3 Commits

Author SHA1 Message Date
614b7c0185
0.4.0 2025-04-02 13:52:23 +02:00
7e176f1fb7
feat: add falthyAsNull to nullable 2025-04-02 13:52:18 +02:00
2f48637e28
0.3.3 2025-04-02 13:44:03 +02:00
3 changed files with 11 additions and 3 deletions

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{
"name": "@dzeio/schema",
"version": "0.3.2",
"version": "0.4.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@dzeio/schema",
"version": "0.3.2",
"version": "0.4.0",
"dependencies": {
"@dzeio/object-util": "^1.8.3",
"@standard-schema/spec": "^1.0.0",

View File

@ -1,6 +1,6 @@
{
"name": "@dzeio/schema",
"version": "0.3.2",
"version": "0.4.0",
"dependencies": {
"@dzeio/object-util": "^1.8.3"
},

View File

@ -1,9 +1,17 @@
import { parceable } from 'Schema'
import SchemaItem from '../SchemaItem'
import { SchemaInfer, ValidationResult } from '../types'
export default class SchemaNullable<Type extends SchemaItem> extends SchemaItem<SchemaInfer<Type> | 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
}