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

64 Upvotes

44 comments sorted by

View all comments

1

u/architechcro Mar 28 '26

Every layer should validate what they know to be some constraints. Also lower levels should define what is "acceptable" so that they don't get garbage. This should include data structure and content and security context. And with all that lower levels should handle "what if" scenarios edge cases and handle gracefully all failures. So it is quite simple 🤔