Jsonifiable schemas
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Julien Valverdé
2024-02-22 23:59:28 +01:00
parent 68b39f4997
commit 6c6e2cce7c
5 changed files with 112 additions and 2 deletions

View File

@@ -1,6 +1,7 @@
import { Implements, TraitExpression } from "@thilawyn/traitify-ts"
import { z } from "zod"
import { ZodSchemaClassBuilder } from "./ZodSchemaClass"
import { dejsonify, jsonify } from "./schema/jsonify"
import { ObservableZodSchemaObject } from "./traits/ObservableZodSchemaObject"
@@ -15,8 +16,12 @@ const newTestExp = new ZodSchemaClassBuilder(TraitExpression.NullSuperclass, [])
defaultValues: { id: -1n },
})
.jsonifiable({
jsonifySchema: ({ schema }) => schema.extend({}),
dejsonifySchema: ({ schema }) => schema.extend({}),
jsonifySchema: ({ schema, shape }) => schema.extend({
id: jsonify.bigint(shape.id)
}),
dejsonifySchema: ({ schema, shape }) => schema.extend({
id: dejsonify.bigint(shape.id)
}),
})
.expresses(ObservableZodSchemaObject)
.build()