Issue
To reduce a chance of a bug. Or should I annotate only DTO? For example,
public class UserDto {
@NotNull
@NotEmpty
private String firstName;
@NotNull
@NotEmpty
private String lastName;
}
public class User extends AbstractBaseEntity {
@NotNull
@NotEmpty
private String username;
@NotNull
@NotEmpty
@Email
private String email;
}
P.S. Most of the code omitted for brevity
Solution
Yes it is completely ok to validate it on both.
Detailed : Spring Rest API validation should be in DTO or in entity?
Answered By - Alien