that behaves the same way, primarily so that JSON schema generation tools can read min and max here to fill in the maxProperties and minProperties fields in their generated schemas.
It may be more useful for this to be extended more generally into a minProperties() and maxProperties() that is usable for anything that resembles a z.object, so that it can deal with more complex intersections and constructions of objects than just records. It also may be useful to include a .length() equivalent (though at this moment I don't have use for it).
Apologies if this is a duplicate - I wasn't able to find any existing discussion on this topic.
I have a use case where I'm trying to replicate the behaviour of the minProperties / maxProperties (see https://json-schema.org/draft/2020-12/json-schema-validation#name-validation-keywords-for-obj).
I can currently achieve this like so:
Which results in:
I'm proposing that there's an API like so:
that behaves the same way, primarily so that JSON schema generation tools can read
min
andmax
here to fill in themaxProperties
andminProperties
fields in their generated schemas.It may be more useful for this to be extended more generally into a
minProperties()
andmaxProperties()
that is usable for anything that resembles az.object
, so that it can deal with more complex intersections and constructions of objects than just records. It also may be useful to include a.length()
equivalent (though at this moment I don't have use for it).