Schema work
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Julien Valverdé
2024-03-19 18:25:56 +01:00
parent 5e7588510d
commit 9ddda594ef
5 changed files with 12 additions and 10 deletions

View File

@@ -7,15 +7,11 @@ import { z } from "zod"
export type JsonifiedDecimal = Opaque<string, "@thilawyn/zod-schema-class/JsonifiedDecimal">
export function jsonifyDecimalSchema<
S extends z.ZodType<Decimal, z.ZodTypeDef, Decimal>
>(schema: S) {
export function jsonifyDecimalSchema<S extends z.ZodType<Decimal>>(schema: S) {
return schema.transform(v => v.toJSON() as JsonifiedDecimal)
}
export function dejsonifyDecimalSchema<
S extends z.ZodType<Decimal, z.ZodTypeDef, Decimal>
>(schema: S) {
export function dejsonifyDecimalSchema<S extends z.ZodType<Decimal>>(schema: S) {
return z
.custom<JsonifiedDecimal>(identity)
.pipe(