Tim Marcus Moore - I found that z.record evalua...
I found that
z.record
evaluates non-enumerable property keys. I'm not sure whether this is a bug or expected behaviour. It was unexpected to me. I ran into this validating a MobX observable object using a z.record
with z.string()
keys. MobX adds non-enumerable symbol properties, which caused parsing to fail.
If it's a bug, I can open an issue on GitHub, but if it's intentional, I'll just adjust my expectations 🙂
This test demonstrates the problem.
It throws this error on schema.parse(data)
:
1 Reply
It passes with
import { z } from 'zod/v3'
so I suspect this is a bug in v4