Skip to content

New option: requiredAsDefault#426

Closed
poldridge wants to merge 2 commits intohapijs:masterfrom
poldridge:master
Closed

New option: requiredAsDefault#426
poldridge wants to merge 2 commits intohapijs:masterfrom
poldridge:master

Conversation

@poldridge
Copy link

requiredAsDefault sets all keys to be required by default. Individual keys can use .optional() to override this setting. This makes it easier to use Joi when you have a large object to validate and the majority of keys are required, such as when validating a JSON config file.

@poldridge
Copy link
Author

I don't particularly like the name requiredAsDefault, but the other names I thought of all made it seem like it was making a default value ( set with any.default() ) required.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to check error message. Applies to all tests added.

@hueniverse hueniverse added the feature New functionality or improvement label Sep 19, 2014
@hueniverse
Copy link
Contributor

Going to implement it slightly different.

@hueniverse hueniverse closed this Sep 19, 2014
@lock
Copy link

lock bot commented Jan 9, 2020

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

feature New functionality or improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants