-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Open
Description
According to the docs
this should work (and it does)
const schema = z.object({
foo: z.string(),
bar: z.number()
}).and(z.looseRecord(z.string().regex(/gitte/), z.boolean()))
schema.parse({
foo: "hello",
bar: 4,
gitte: true
}) // successHowever if I add a .transform to one of the keys it fails
like here
const schema = z.object({
foo: z.string(),
bar: z.number().transform(v => v+4)
}).and(z.looseRecord(z.string().regex(/gitte/), z.boolean()))
schema.parse({
foo: "hello",
bar: 4,
gitte: true
}) // failsThis is an oversimplification of the issue I'm encountering but I'm unsure if this is a bug or if it's not intended to work?
Basically I'm trying to have a complex schema of known keys and various types, but also extend that type with any key that matches a certain regex. but because my different values use .transform it doesn't appear to work
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels