0.1.0 #1
@@ -1,6 +1,7 @@
|
|||||||
import { JsonifiableObject } from "type-fest/source/jsonifiable"
|
import { JsonifiableObject } from "type-fest/source/jsonifiable"
|
||||||
import { z } from "zod"
|
import { z } from "zod"
|
||||||
import { SchemableClass, SchemableConfig } from "."
|
import { SchemableClass, SchemableConfig } from "."
|
||||||
|
import { parseZodTypeEffect } from "./util"
|
||||||
|
|
||||||
|
|
||||||
export function makeJsonifiableSchemableClass<
|
export function makeJsonifiableSchemableClass<
|
||||||
@@ -55,8 +56,24 @@ export function makeJsonifiableSchemableClass<
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
return class JsonifiableSchemableObject {
|
return class JsonifiableSchemableObject extends class_ {
|
||||||
|
static readonly jsonifySchema = jsonifySchema
|
||||||
|
static readonly dejsonifySchema = dejsonifySchema
|
||||||
|
|
||||||
|
readonly jsonifySchema = jsonifySchema
|
||||||
|
readonly dejsonifySchema = dejsonifySchema
|
||||||
|
|
||||||
|
jsonify() {
|
||||||
|
return this.jsonifySchema.parse(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
jsonifyPromise() {
|
||||||
|
return this.jsonifySchema.parseAsync(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
jsonifyEffect() {
|
||||||
|
return parseZodTypeEffect(this.jsonifySchema, this)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user