Colt / YelpCamp

583 stars 560 forks source link

Error using Joi Validation Middleware #38

Closed TalibIbrahim closed 1 year ago

TalibIbrahim commented 1 year ago

I used Joi validation and it worked perfectly the last time I worked on the project. The next video had a middleware made from it and nothing works after that. I even reverted back to my previous code and it still doesnt work.

First while using the middleware i got an error saying 'cannot read properties of undefined reading('validate')' at my validateCampground function.

Then I made some changes to the code and it said that " 'campground' is required" .

image

Now, even when all of the inputs pass the validation, it still shows the above error.

I remove the validateCampground middleware, everything works fine. I even checked the documentation and couldnt find the problem anywhere.

TalibIbrahim commented 1 year ago

Also note that app.js: 130:13 refers to new in throw new ExpressError(msg,400)

Code-Singh commented 1 year ago

I had the same error and the cause was enctype="multipart/form-data" attribute on my forms.