This commit is contained in:
23
src/tests.ts
23
src/tests.ts
@@ -0,0 +1,23 @@
|
||||
import { z } from "zod"
|
||||
import { extendSchemable } from "."
|
||||
|
||||
|
||||
const Test1Schema = z.object({ prout: z.string() })
|
||||
class Test1 {
|
||||
static readonly schema = Test1Schema
|
||||
readonly schema = Test1Schema
|
||||
|
||||
static readonly defaultValues = { prout: "heugneu" }
|
||||
readonly defaultValues = { prout: "heugneu" }
|
||||
|
||||
prout: string = "heugneu"
|
||||
}
|
||||
|
||||
const Test2 = extendSchemable(
|
||||
Test1,
|
||||
schema => schema.extend({ prout: z.literal("ruquier"), ruquier: z.number() }),
|
||||
defaultValues => ({ prout: "ruquier" as const }),
|
||||
)
|
||||
|
||||
Test2.defaultValues
|
||||
new Test2().prout
|
||||
|
||||
Reference in New Issue
Block a user