0.1.0 #1

Merged
Thilawyn merged 24 commits from next into master 2024-01-05 00:39:33 +01:00
Showing only changes of commit 92271583ce - Show all commits

View File

@@ -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)
}
} }
} }