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

This commit is contained in:
Julien Valverdé
2024-01-16 14:44:54 +01:00
parent adc24574ec
commit bfa359449e
4 changed files with 229 additions and 8 deletions

View File

@@ -1,7 +1,7 @@
import { pipeInto } from "ts-functional-pipe"
import { z } from "zod"
import { extendSchemableClass, makeSchemableClass, newSchemable } from "."
import { makeJsonifiableSchemableClass } from "./jsonifiable"
import { dejsonifySchemable, makeJsonifiableSchemableClass } from "./jsonifiable"
import { dejsonifyBigIntSchema, jsonifyBigIntSchema } from "./legacy/jsonifiable"
@@ -49,11 +49,13 @@ class User extends pipeInto(
const user1 = newSchemable(User, { id: 1n, name: "User" })
console.log(user1.jsonify())
const jsonifiedUser1 = user1.jsonify()
console.log(jsonifiedUser1)
console.log(dejsonifySchemable(User, jsonifiedUser1))
const UserWithPhone = extendSchemableClass(User, {
schema: schema => schema.extend({
schema: ({ schema }) => schema.extend({
phone: z.string()
}),
@@ -66,5 +68,5 @@ const UserWithPhone = extendSchemableClass(User, {
UserWithPhone.schema
const user2 = newSchemable(UserWithPhone, { id: 1n, name: "User" })
console.log(user2.jsonify())
// const user2 = newSchemable(UserWithPhone, { id: 1n, name: "User" })
// console.log(user2.jsonify())