Answer the question
In order to leave comments, you need to log in
If there is a DTO for each entity, then which application layer is responsible for validation?
Let's say there is an entity User, it has 2 fields, email and password. It's 2 ValueObjects. VOs must always be valid, before we create them we use DTOs. And the question arose, Which of the 2 levels, DTO or VO, are responsible for validation?
$dto = new UserDTO($data) // тут валидируем
$user = new User($dto);
....
public function __construct(UserDTO $dto)
{
$this->email = new UserVOEmail($dto->email); // или тут валидируем
...
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question