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

Validate input arguments using Joi #35

Merged
merged 2 commits into from Jun 4, 2015
Merged

Conversation

@kanongil
Copy link
Member

kanongil commented Jun 2, 2015

This enables most function argument errors to be caught at development time.

I have tried to accommodate the existing usage in the schemas, and tested that the lab module, which uses bossy, still pass all tests.

Note that validation failures will result in thrown Errors. I'd say this is a breaking change.

@sericaia

This comment has been minimized.

Copy link
Contributor

sericaia commented Jun 3, 2015

Great job. The only modification that I would like to suggest is if you could add the type to the error message. Thanks

@kanongil

This comment has been minimized.

Copy link
Member Author

kanongil commented Jun 3, 2015

Glad you like it.

I'm unsure which modification you suggest? These new errors messages are only for cli authors, to catch invalid arguments. Users should never actually see them.

@sericaia

This comment has been minimized.

Copy link
Contributor

sericaia commented Jun 3, 2015

Yeah, I know it.. but instead of just saying "[1] "required" is not allowed" when I change required from boolean to something else, could it be possible to see something that mentions that it should be a boolean?
Thanks

@kanongil

This comment has been minimized.

Copy link
Member Author

kanongil commented Jun 4, 2015

You are receiving a useful error message. required is not allowed – it should be require, in which case it complains about the booleaness of the value.

This is exactly the type of developer error this is intended to catch.

@sericaia sericaia added this to the 2.0.0 milestone Jun 4, 2015
sericaia added a commit that referenced this pull request Jun 4, 2015
Validate input arguments using Joi
@sericaia sericaia merged commit 3aba720 into hapijs:master Jun 4, 2015
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@sericaia sericaia mentioned this pull request Jul 1, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.