extendSchemableClass tests
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
22
src/tests.ts
22
src/tests.ts
@@ -1,6 +1,6 @@
|
||||
import { pipeInto } from "ts-functional-pipe"
|
||||
import { z } from "zod"
|
||||
import { makeSchemableClass, newSchemable } from "."
|
||||
import { extendSchemableClass, makeSchemableClass, newSchemable } from "."
|
||||
import { makeJsonifiableSchemableClass } from "./jsonifiable"
|
||||
import { dejsonifyBigIntSchema, jsonifyBigIntSchema } from "./legacy/jsonifiable"
|
||||
|
||||
@@ -49,4 +49,22 @@ class User extends pipeInto(
|
||||
|
||||
|
||||
const user1 = newSchemable(User, { id: 1n, name: "User" })
|
||||
user1.jsonify()
|
||||
console.log(user1.jsonify())
|
||||
|
||||
|
||||
const UserWithPhone = extendSchemableClass(User, {
|
||||
schema: schema => schema.extend({
|
||||
phone: z.string()
|
||||
}),
|
||||
|
||||
defaultValues: defaultValues => ({
|
||||
...defaultValues,
|
||||
phone: "+33600000000",
|
||||
}),
|
||||
})
|
||||
|
||||
UserWithPhone.schema
|
||||
|
||||
|
||||
const user2 = newSchemable(UserWithPhone, { id: 1n, name: "User" })
|
||||
console.log(user2.jsonify())
|
||||
|
||||
Reference in New Issue
Block a user