This commit is contained in:
10
src/tests.ts
10
src/tests.ts
@@ -1,15 +1,17 @@
|
||||
import { Implements } from "@thilawyn/traitify-ts"
|
||||
import { Option } from "effect"
|
||||
import { z } from "zod"
|
||||
import { JsonifiedZodSchemaClass } from "./JsonifiedZodSchemaClass"
|
||||
import { ZodSchemaClass } from "./ZodSchemaClass"
|
||||
import { dejsonify, jsonify } from "./schema/jsonifiable"
|
||||
import { effect } from "./schema/lib"
|
||||
import { MobXObservableZodSchemaObject } from "./traits/MobXObservableZodSchemaObject"
|
||||
|
||||
|
||||
const userExp = ZodSchemaClass(
|
||||
z.object({
|
||||
/** User ID */
|
||||
id: z.bigint().default(-1n),
|
||||
id: effect.option.option(z.bigint()).default(Option.none()),
|
||||
|
||||
/** Username */
|
||||
name: z.string(),
|
||||
@@ -24,8 +26,8 @@ const userExp = ZodSchemaClass(
|
||||
@userExp.staticImplements
|
||||
class User extends userExp.extends implements Implements<typeof userExp> {}
|
||||
|
||||
const userInst = User.create({ id: 1n, name: "User" })
|
||||
const userInstEffect = User.createEffect({ id: 1n, name: "User" })
|
||||
const userInst = User.create({ id: Option.some(1n), name: "User" })
|
||||
const userInstEffect = User.createEffect({ id: Option.some(1n), name: "User" })
|
||||
|
||||
|
||||
const jsonifiedUserExp = JsonifiedZodSchemaClass(User, {
|
||||
@@ -52,4 +54,4 @@ const adminUserExp = User.extend(s => s.extend({
|
||||
@adminUserExp.staticImplements
|
||||
class AdminUser extends adminUserExp.extends implements Implements<typeof adminUserExp> {}
|
||||
|
||||
const admin = AdminUser.create({ id: 2n, name: "Admin" })
|
||||
const admin = AdminUser.create({ id: Option.some(2n), name: "Admin" })
|
||||
|
||||
Reference in New Issue
Block a user