Complete the code to add a validation annotation that ensures the 'name' field is not empty.
public class UserDTO { @[1] private String name; // getters and setters }
The @NotEmpty annotation ensures the 'name' field is not null or empty.
Complete the code to validate that the 'email' field contains a valid email format.
public class UserDTO { @[1] private String email; // getters and setters }
The @Email annotation checks that the string is a valid email format.
Fix the error in the code by adding the correct annotation to ensure 'age' is at least 18.
public class UserDTO { @[1] private int age; // getters and setters }
The @Min(18) annotation ensures the 'age' field value is at least 18.
Fill both blanks to create a DTO field 'password' that must be at least 8 characters and not blank.
public class UserDTO { @[1] @[2](min = 8) private String password; // getters and setters }
@NotBlank ensures the password is not empty or just spaces.
@Size(min = 8) ensures the password has at least 8 characters.
Fill all three blanks to create a DTO field 'username' that is not null, has length between 5 and 15, and matches only letters and digits.
public class UserDTO { @[1] @[2](min = 5, max = 15) @[3](regexp = "^[a-zA-Z0-9]+$") private String username; // getters and setters }
@NotNull ensures the username is not null.
@Size(min = 5, max = 15) restricts length.
@Pattern restricts characters to letters and digits.