I have create and update operation for user and the following UserDto
public class UserDto {
@NotBlank
private String username;
@NotBlank
private String password;
@NotBlank
private String mobileNo;
... other variables, etc.
}
For update operation, I don't want to update the password, I only want to update other variables. Then the password would be received as null (hence not passing @NotBlank).
But the @NotBlank is required for create operation. What is the best approach to solve this?
Should I create 2 Dtos e.g. UserCreateDto, UserUpdateDto (without password field).
I'm not sure if this is a good practice.