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

Use enjoi for input validation. #11

Closed
tlivings opened this issue Sep 21, 2014 · 3 comments
Closed

Use enjoi for input validation. #11

tlivings opened this issue Sep 21, 2014 · 3 comments

Comments

@tlivings
Copy link
Member

Rather than tv4, use enjoi for input validation.

Likely API schema validation will need to remain the same due to the broken Swagger 2.0 schema.

@jorgemsrs
Copy link

Hello @tlivings.

I'm considering swagger spec and this implementation for my company data aggregation layer. While reading the code I wondered (read master branch) about the decision to use enjoi instead of tv4. I prefer tv4 mainly because it's seems more performant (http://cosmicrealms.com/blog/2014/02/07/benchmark-of-node-dot-js-json-validation-modules-part-2/).

Could you share the rationale behind this issue?

@tlivings
Copy link
Member Author

Hi, sure.

The link you reference has questionable benchmarks. When I ran my own benchmarks, which you can run by calling npm run bench in swagaerize-builder, joi validation is actually much faster. I suspect the benchmark run in that link was done without pre-building the joi schema, which I do.

In addition, I found I had better validation results with enjoi, since I resolved $ref up front.

Finally, since I also wrote a swaggerize-hapi module, hapi handles the input validation automatically if you provide it a joi schema, which was a really nice fit.

Hope this helps answer your question.

@tlivings
Copy link
Member Author

Closing this since it's already done in 2.0.0.

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

No branches or pull requests

2 participants