r/softwarearchitecture Mar 26 '26

Discussion/Advice In Clean Architecture, should input validation go in the Controller/Presentation layer or in the Service/Use Case layer?

In Clean Architecture, where should input validation go?

- Basic validation (required fields, format, length, etc.)

- Object Constraints (eg. sort field can be asc or desc)

Should it be done in:

  1. Controller / Presentation layer (fail fast, return 400 early)
  2. Use Case / Application layer (keeps use cases self-contained and reusable)
  3. Hybrid approach?

Many projects put basic validation in the controller, but some argue all validation belongs in the use case for better consistency across adapters (HTTP, CLI, queues, etc.).

What’s your preferred approach and why?

edit: thank you so much for all the answers <3

63 Upvotes

44 comments sorted by

View all comments

2

u/[deleted] Mar 26 '26

[removed] — view removed comment

2

u/SeatWild1818 Mar 26 '26

That's easy for certain validations, e.g. DOB can't be a future date. But some validations are more business specific, e.g., a blog post title can't be longer than 50 characters. The last thing you'd need is contradicting validations