Recall & Review
beginner
What is the purpose of the
@Email annotation in Spring Boot?The
@Email annotation checks if a string is a valid email address format. It helps ensure users enter proper emails in forms.Click to reveal answer
beginner
How does the
@Pattern annotation work in Spring Boot?@Pattern validates a string against a regular expression (regex). It ensures the string matches a specific pattern you define.Click to reveal answer
beginner
Example usage of
@Email annotation in a Spring Boot model?You add
@Email(message = "Invalid email") above a String field to check email format. Example:<br>@Email(message = "Invalid email")<br>private String userEmail;Click to reveal answer
intermediate
What happens if a string does not match the regex in
@Pattern validation?Spring Boot validation fails and returns an error message. You can customize the message with
message = "Your message" in the annotation.Click to reveal answer
intermediate
Can
@Email and @Pattern be used together on the same field?Yes, you can combine them to enforce email format and additional pattern rules. Both validations run and must pass for the input to be valid.
Click to reveal answer
What does the
@Email annotation validate?✗ Incorrect
@Email checks if the string looks like a proper email address.Which annotation uses a regular expression to validate a string?
✗ Incorrect
@Pattern validates strings against regex patterns you provide.How do you customize the error message shown when
@Pattern validation fails?✗ Incorrect
You add
message = "Your message" inside @Pattern to customize errors.Can
@Email annotation alone guarantee the email domain is real?✗ Incorrect
@Email only checks if the email looks correct, not if the domain exists.If you want to ensure a string contains only digits, which annotation is best?
✗ Incorrect
@Pattern with regex \d+ ensures only digits are allowed.Explain how you would use
@Email and @Pattern annotations to validate a user input field in Spring Boot.Think about combining format checks and pattern rules on the same field.
You got /4 concepts.
What are the limitations of
@Email validation and how can @Pattern help overcome them?Consider what @Email does not check and how regex can add control.
You got /4 concepts.