How to define a heterogeneous array with a specific number of items using JSONSchema (draft/2019-09)? #2071
Replies: 1 comment
-
|
prefixItems is already supported — use "items": false with minItems/maxItems equal to the prefixItems length to generate tuple[str, str, float, bool] (see PR #2537). Thank you!! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
i'd like to be able to specify an array which can only contain specific types, in exact order, with exact count and have the generated Pydantic models enforce that via validation. for example:
...which is to say, my array / list should only ever have 4 entries. indices 0 and 1 should be strings. index 2 should be a number. index 3 should be a boolean. anything else should be flagged as invalid.
is this possible or does it require the as yet unsupported
prefixItemsfeature (issue#1546)Beta Was this translation helpful? Give feedback.
All reactions