Skip to content
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

[Bug] TS-first schemas allow stricter-than-needed checks #9

Open
thoughtspile opened this issue Mar 3, 2023 · 2 comments
Open

[Bug] TS-first schemas allow stricter-than-needed checks #9

thoughtspile opened this issue Mar 3, 2023 · 2 comments

Comments

@thoughtspile
Copy link
Owner

When using TS-first collection schemas, the field validations can be stricter than the type passed:

array<string>(enums(['s']))
array<{ key: string }>(object({ key: string(), extra: string() }))
object<{ key: string }>({
  key: enums(['s'])
})

This never results in incorrect runtime values, but can make authoring and maintaining schemas a bit more daunting and cause false negatives. In the case of nested objects, I'm pretty sure there's no way to disallow extra keys with current TS.

@jordan-boyer
Copy link
Contributor

I'm not sure how to tackle this one if you have an idea let me know and i'll try to help implement it =)

@thoughtspile
Copy link
Owner Author

I have no ideas either. At this point it's probably best to add a note about nested objects in the docs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants