Open dmckeone opened 1 year ago
Describe the bug
When using anyOf for an optional field, validation criteria are not generated.
anyOf
Minimal reproduction
"first_name": { "type": "string", "minLength": 1 "maxLength": 30 }
The above works, and produces:
.object({ first_name: z.string().min(1).max(30), })
The below does not work:
"first_name": { "anyOf": [ { "type": "string", "maxLength": 30, "minLength": 1 }, { "type": "null" } ], "default": null }
and produces:
.object({ first_name: z.union([z.string(), z.null()]), })
Expected behavior
should produce:
.object({ first_name: z.union([z.string().min(1).max(30), z.null()]), })
.object({ first_name: z.string().min(1).max(30).nullable(), })
Describe the bug
When using
anyOf
for an optional field, validation criteria are not generated.Minimal reproduction
The above works, and produces:
The below does not work:
and produces:
Expected behavior
should produce: