Coerce drops required option on output
Closed this issue · 3 comments
Bram-dc commented
Bram-dc commented
This is probably due to .isNullable() being true on the zod object and is maybe the correct way for this library to also define the required option.
AGalabov commented
Yes @Bram-dc you are totally correct - the capabilities of null/undefined is what is causing this change and it is expected
Sozialarchiv commented
I have the same issue.
const t = z.number({description: 'Database ID', coerce: true})
t.isNullable() // true
t.isOptional() // false
Would it be an option to test isOptional in case of request params?
Because coerce is an important option for request params.