Do I need to use @hapi/joi
with mongoose
?
As I understand @hapi/joi
is used for validating HTTP request (headers, parameters, body etc.). @hapi/joi
provides it's own schema validation. The mongoose
also provides it's own schema validation but on another level. If hapi/joi
tries to validate HTTP request, than mongoose
schema validation ensures that data is valid to be inserted into the database.
As you can see both libraries provide it's own schemas validation (on different levels). It requires additional resource to keep both schema equal to each other (which is a place for bugs).
The question is: Do I need to keep this both libraries and support two schema? Or I can use mongoose
and their validation and @hapi/joi
is redundancy?
Thanks in advance!
Update:
I found related question, but it is not answering my question anyway :(