# Form Validation

**URL:** <https://discourse.slimframework.com/t/form-validation/5208>\
**Category:** Questions\
**Created:** [March 9, 2022, 4:28am UTC](https://discourse.slimframework.com/t/form-validation/5208 "2022-03-09T04:28:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![darkalchemy](https://avatars.discourse-cdn.com/v4/letter/d/ad7895/32.png) [@darkalchemy](https://discourse.slimframework.com/u/darkalchemy)\
**Post date:** [March 9, 2022, 4:28am UTC](https://discourse.slimframework.com/t/form-validation/5208/1 "2022-03-09T04:28:24Z")

</div>

I’m curious to know where form validation should be done? In the controller is what i have seen in many cases. But, would it be better to move it into the middleware and run per route as needed? Or is it better in another location altogether?

Thanks

---

<div class="post-metadata">

**Author:** ![goldrak](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/goldrak/32/823_2.png) [@goldrak](https://discourse.slimframework.com/u/goldrak)\
**Post date:** [March 9, 2022, 11:43am UTC](https://discourse.slimframework.com/t/form-validation/5208/2 "2022-03-09T11:43:20Z")

</div>

Hello,  
I have them at the service level before processing the data, all in a folder called Validation, which has functions depending on the service and I use Respect\Validation for them.

---

<div class="post-metadata">

**Author:** ![tj\_gumis](https://avatars.discourse-cdn.com/v4/letter/t/c89c15/32.png) [@tj\_gumis](https://discourse.slimframework.com/u/tj_gumis)\
**Post date:** [March 9, 2022, 11:59am UTC](https://discourse.slimframework.com/t/form-validation/5208/3 "2022-03-09T11:59:47Z")

</div>

**Middleware** - categorically and indisputably 😃

---

<div class="post-metadata">

**Author:** ![darkalchemy](https://avatars.discourse-cdn.com/v4/letter/d/ad7895/32.png) [@darkalchemy](https://discourse.slimframework.com/u/darkalchemy)\
**Post date:** [March 9, 2022, 1:09pm UTC](https://discourse.slimframework.com/t/form-validation/5208/4 "2022-03-09T13:09:17Z")

</div>

@tj_gumis I thought that might be the case.

@goldrak I’m trying to learn OOP and move away from procedural. In a previous life thats all i knew.

I’m getting better, but I don’t spend enough time at it. I work entirely too much, so keeping up and wrapping my head around new things is slow going.

Thanks for your responses.
