0.1.1 #2
24
src/tests.ts
24
src/tests.ts
@@ -1,7 +1,6 @@
|
||||
import { extendsAndExpresses } from "@thilawyn/thilatrait"
|
||||
import { z } from "zod"
|
||||
import { makeSchemableClass, newSchemable } from "."
|
||||
import { JsonifiableSchemable } from "./jsonifiable"
|
||||
import { makeJsonifiableSchemableClass } from "./jsonifiable"
|
||||
import { dejsonifyBigIntSchema, jsonifyBigIntSchema } from "./legacy/jsonifiable"
|
||||
|
||||
|
||||
@@ -19,12 +18,21 @@ const UserProto = makeSchemableClass(z.object({
|
||||
UserProto.defaultValues
|
||||
|
||||
|
||||
class User extends extendsAndExpresses(UserProto,
|
||||
JsonifiableSchemable(
|
||||
UserProto.schema.extend({ id: jsonifyBigIntSchema(z.bigint()) }),
|
||||
UserProto.schema.extend({ id: dejsonifyBigIntSchema(z.bigint()) }),
|
||||
)
|
||||
) {}
|
||||
const JsonifiableUserProto = makeJsonifiableSchemableClass({
|
||||
extend: UserProto,
|
||||
|
||||
jsonifySchema: ({ schema, shape }) => schema.extend({
|
||||
id: jsonifyBigIntSchema(shape.id)
|
||||
}),
|
||||
|
||||
dejsonifySchema: ({ schema, shape }) => schema.extend({
|
||||
id: dejsonifyBigIntSchema(shape.id)
|
||||
}),
|
||||
})
|
||||
|
||||
|
||||
class User extends JsonifiableUserProto {}
|
||||
|
||||
|
||||
const user1 = newSchemable(User, { id: 1n, name: "User" })
|
||||
user1.jsonify()
|
||||
|
||||
Reference in New Issue
Block a user