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