Validating domain objects
For instance, when loading historical data, some genders may be missing. The answer is certainly not to fail the query operation.
The dates in the User Profile class present the opportunity for some more complex business rules.
Why should you have validation in the domain layer when every domain object is by its nature in a valid state after its construction and can never be invalid? I would propose to put it on the surrounding / higher layer, the Service Layer.
In the above picture, from the external request perspective, I need a few questions answered: Think of request validation as "have I filled out the form correctly".There always seem to be some variations here and there.My applications also tend to have explicit objects for external "requests", which are the types bound to the HTTP request variables.This might be a form POST, or it might be a JSON POST, but in either case, there's a request object.The real question is - how does that request object finally affect my domain model?