Compare commits
3 Commits
fb1241c779
...
614b7c0185
Author | SHA1 | Date | |
---|---|---|---|
614b7c0185 | |||
7e176f1fb7 | |||
2f48637e28 |
4
package-lock.json
generated
4
package-lock.json
generated
@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "@dzeio/schema",
|
"name": "@dzeio/schema",
|
||||||
"version": "0.3.2",
|
"version": "0.4.0",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@dzeio/schema",
|
"name": "@dzeio/schema",
|
||||||
"version": "0.3.2",
|
"version": "0.4.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@dzeio/object-util": "^1.8.3",
|
"@dzeio/object-util": "^1.8.3",
|
||||||
"@standard-schema/spec": "^1.0.0",
|
"@standard-schema/spec": "^1.0.0",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@dzeio/schema",
|
"name": "@dzeio/schema",
|
||||||
"version": "0.3.2",
|
"version": "0.4.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@dzeio/object-util": "^1.8.3"
|
"@dzeio/object-util": "^1.8.3"
|
||||||
},
|
},
|
||||||
|
@ -1,9 +1,17 @@
|
|||||||
|
import { parceable } from 'Schema'
|
||||||
import SchemaItem from '../SchemaItem'
|
import SchemaItem from '../SchemaItem'
|
||||||
import { SchemaInfer, ValidationResult } from '../types'
|
import { SchemaInfer, ValidationResult } from '../types'
|
||||||
|
|
||||||
export default class SchemaNullable<Type extends SchemaItem> extends SchemaItem<SchemaInfer<Type> | undefined> {
|
export default class SchemaNullable<Type extends SchemaItem> extends SchemaItem<SchemaInfer<Type> | undefined> {
|
||||||
public constructor(public readonly child: Type) { super([child]) }
|
public constructor(public readonly child: Type) { super([child]) }
|
||||||
|
|
||||||
|
@parceable()
|
||||||
|
public falthyAsNull() {
|
||||||
|
this.addPreProcess((it) => !it ? undefined : it)
|
||||||
|
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
public unwrap(): Type {
|
public unwrap(): Type {
|
||||||
return this.child
|
return this.child
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user