-
Notifications
You must be signed in to change notification settings - Fork 408
feat: support minItems
and maxItems
#242
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks super good overall. A few comments. Also, what do you think about updating generated output to be more safe? As-is:
type A = [string, string?, string?]
const a: A = ['a', undefined, 'c']
Instead, we could avoid accidentally allowing undefined
through:
type B = [string] | [string, string] | [string, string, string]
const b: B = ['a', undefined, 'c']
I've addressed the other comments. In regards to changing the types, I think it's a good idea. |
It makes the types verbose, but it adds a heap more type safety. I'm a lot happier with the types this way! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost there -- one last (minor) suggestion.
- fix normalizer not applying deeply - normalize minItems - add tests for zero min/maxItems - fix some bugs that were surfaced from that
OOOOKay. Sorry, this PR keeps growing. So in adding in a normalizer for I noticed that most of the normalizers had a check for So I added a traverser which will properly traverse the schema, which allows the normalizers to correctly apply to things which are actually schemas beyond the root schema. This surfaced a few bugs which I fixed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great. Thanks for the enhancement, and thanks for improving underlying infrastructure along the way, Brad!
Published 7.0.0. |
NOTE - this branch was based off of #241.
Github will show a number of unrelated commits until that PR is merged.
For a nicer reviewing experience, please only review commits after
5cb467a
Fixes #218
This PR:
minItems
/maxItems
exists.minItems
/maxItems
greater than the length of the provided items.maxItems
less than the length of the provided items.minItems
ormaxItems
.