howardmann / clean-node

Clean Node Architecture
339 stars 64 forks source link

Validation does not use express middleware to perform validations #4

Open iJKTen opened 3 years ago

iJKTen commented 3 years ago

Please can you explain why did you did not use a middleware to perform data validations? I am trying to understand a better way to write express applications and would appreciate your response.

Thank you

howardmann commented 1 year ago

Yes if using express as the framework then using a validation library as middleware is a good use case. Here is an example of how to use a validation library like JOI and developing your own custom middleware: https://mannhowie.com/express-validation

In this particular example we are attempting to design a clean node app which would allow us to switch out frameworks and technologies. As middleware is commonly tied to Express the framework it would tie our tech stack to Express. By making it a simple function allows us to switch out tech stacks in future