-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
In favor of custom validations or custom types. #240
Comments
That's the equivalent of eating the cake and having it too. Joi is a validation module used by hapi. It is designed to encourage configuration over code and to provide a clear path to automatic documentation. Providing external functions voids all that. Now, I do understand that people would like to be able to perform more complex validation in hapi and you are free to create a solution that combines joi with custom function (since hapi will just take any validation function instead of joi schema). You can also use an extension function or perform extra logic in a pre or handler. Many options. Nothing is free and between a consistent API that can be automatically documented to extensibility, I picked the first. You are free to pick the second by taking joi and wrapping it with a module that adds what you want into the any() prototype. |
@ericchaves I understand you won't add custom validation to Joi and ok. But allowing for an |
The problem is that while we can expose the internal mechanism for adding new tests, there is so much that can go wrong with that. At the end its the same outcome. If you have a specific proposal, open a new issue with code of how it will work and we can discuss. |
Hi Eran,
I saw a previous closed issue where is said that Joi won't accept custom validations since this could be done with functions applied on data after/prior Joi's validation.
However because in Hapi validations are done with Join internally (we just assign an schema to it) don't you think this restriction can lead to a messy code, where some validations are set during route configuration and others would be left somewhere inside the handlers?
What would be your opinion on this matter?
Cheers,
The text was updated successfully, but these errors were encountered: