Close
« Tutorial

Spring MVC - Form Validation with Bean Validation MCQ

0/13
0 ✓
0 ✗

1. What is the main purpose of Jakarta Bean Validation?

2. Where do you normally place Bean Validation constraint annotations such as @NotEmpty and @Size?

3. What does Spring MVC register automatically as the global validator when a Bean Validation implementation (such as Hibernate Validator) is on the classpath?

4. Which annotation on a controller method parameter tells Spring to validate that object automatically?

5. When does Spring run the validation for a method parameter marked with @Valid?

6. What is BindingResult used for?

7. Where must the BindingResult parameter be placed in a controller method signature?

8. What happens if the BindingResult parameter is not placed immediately after the validated object?

9. A controller method has two validated model objects. How many BindingResult instances does Spring create?

10. Which method of BindingResult tells you if any validation errors were found?

11. Which constraint annotation makes sure a text value is not null and not empty?

12. Which constraint annotation checks that a text value has a length between a minimum and a maximum?

13. Which constraint annotation checks a text value against a regular expression?

14. Which constraint annotation checks that a text value looks like a valid email address?

15. Which attribute is used to set a custom error message on a constraint annotation?

@NotEmpty(____ = "Name is required")

16. Copying field errors from BindingResult into the model by hand is not ideal. What is a better alternative?

Join