0.1.1 #2

Merged
Thilawyn merged 47 commits from next into master 2024-01-17 20:47:13 +01:00
3 changed files with 22 additions and 12 deletions
Showing only changes of commit c980148c0a - Show all commits

View File

@@ -1,11 +1,12 @@
import { z } from "zod"
export const jsonifyBigIntSchema = <S extends z.ZodBigInt>(schema: S) =>
schema.transform(v => v.toString())
export function jsonifyBigIntSchema<S extends z.ZodBigInt>(schema: S) {
return schema.transform(v => v.toString())
}
export const dejsonifyBigIntSchema = <S extends z.ZodBigInt>(schema: S) =>
z
export function dejsonifyBigIntSchema<S extends z.ZodBigInt>(schema: S) {
return z
.string()
.transform(v => {
try {
@@ -16,3 +17,4 @@ export const dejsonifyBigIntSchema = <S extends z.ZodBigInt>(schema: S) =>
}
})
.pipe(schema)
}

View File

@@ -1,11 +1,12 @@
import { z } from "zod"
export const jsonifyDateSchema = <S extends z.ZodDate>(schema: S) =>
schema.transform(v => v.toString())
export function jsonifyDateSchema<S extends z.ZodDate>(schema: S) {
return schema.transform(v => v.toString())
}
export const dejsonifyDateSchema = <S extends z.ZodDate>(schema: S) =>
z
export function dejsonifyDateSchema<S extends z.ZodDate>(schema: S) {
return z
.string()
.transform(v => {
try {
@@ -16,3 +17,4 @@ export const dejsonifyDateSchema = <S extends z.ZodDate>(schema: S) =>
}
})
.pipe(schema)
}

View File

@@ -2,11 +2,16 @@ import { Decimal } from "decimal.js"
import { z } from "zod"
export const jsonifyDecimalSchema = <S extends z.ZodType<Decimal, z.ZodTypeDef, Decimal>>(schema: S) =>
schema.transform(v => v.toJSON())
export function jsonifyDecimalSchema<
S extends z.ZodType<Decimal, z.ZodTypeDef, Decimal>
>(schema: S) {
return schema.transform(v => v.toJSON())
}
export const dejsonifyDecimalSchema = <S extends z.ZodType<Decimal, z.ZodTypeDef, Decimal>>(schema: S) =>
z
export function dejsonifyDecimalSchema<
S extends z.ZodType<Decimal, z.ZodTypeDef, Decimal>
>(schema: S) {
return z
.string()
.transform(v => {
try {
@@ -17,3 +22,4 @@ export const dejsonifyDecimalSchema = <S extends z.ZodType<Decimal, z.ZodTypeDef
}
})
.pipe(schema)
}