-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Description
The intersection of two objects
z.toJSONSchema(z.intersection(
z.object({foo: z.boolean()}),
z.object({bar: z.boolean()}),
))compiles to:
{ "allOf": [{
"type": "object",
"properties": { "foo": { "type": "boolean" } },
"required": ["foo"],
"additionalProperties": false
}, {
"type": "object",
"properties": { "bar": { "type": "boolean" } },
"required": [ "bar" ],
"additionalProperties": false
}]}where additionalProperties: false prevents { foo: true, bar: false } from matching at least one of the rules.
.looseObject works around this but isn't strict enough for my taste so for now I'm stuck with extending union cases
Maybe this helps?
Metadata
Metadata
Assignees
Labels
No labels