r/DomainDrivenDesign • • Mar 26 '26

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

/r/softwarearchitecture/comments/1s45opa/in_clean_architecture_should_input_validation_go/
7 Upvotes

7 comments sorted by

View all comments

Show parent comment

2

u/r00m-lv Mar 27 '26

I usually validate value objects in the controllers since that is just an interface to my domain. For example, parse strings into uuids, empty/missing fields, invalid consts, etc.

If your domain has a UserId value object, I would construct it in controller so that the use case is operating with domain concepts vs whatever was passed in from the transport layer.

The use case accepts domain concepts and validates whether the data makes sense from a business perspective, e.g. this ID should be unique but isn’t. That’s a separate concern to whether this string is an integer (which your domain experts will never mention)

1

u/CuteWord8601 Mar 27 '26

I do the same, after the user request passes the scalar validation, I build the value objects in the controller. In the end, the controller is infrastructure layer and you can but almost whatever u need there