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

Optional schema keys? #41

Closed
spacesuitdiver opened this issue Jul 29, 2020 · 3 comments
Closed

Optional schema keys? #41

spacesuitdiver opened this issue Jul 29, 2020 · 3 comments

Comments

@spacesuitdiver
Copy link

Is it possible to have optional values in schema?

@FokkeZB
Copy link
Contributor

FokkeZB commented Sep 25, 2020

You can, but it's hacky. The RegExp check assumes values are strings, but missing values will be undefined. However, RegExp().test() does cast this to the string "undefined" so you can do something like: ^(foo|undefined)$.

I just ran into this as well and I'll open a PR to improve this.

@FokkeZB
Copy link
Contributor

FokkeZB commented Oct 1, 2020

@keithmorris I think this can be closed now #45 has been published.

@keithmorris
Copy link
Owner

This has been fixed as of release v2.9.0

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

3 participants