Skip to content
Sharp

Spring Core · interview question

How can you ensure that a Spring Boot service only processes valid data from a controller method?

Multiple choiceMediumchapter-9-curatedpremiumspring-corepersistence-and-validation
Choose one answer
Answer and explanation

Correct answer

A. Utilize @Valid and Java Bean Validation

Why

By using @Valid in conjunction with Java Bean Validation annotations like @NotBlank or @NotNull, you can enforce validation rules at the controller level. This ensures that only valid data is passed to the service layer for processing.

Test yourself on Spring Core

A free test with instant, explained results. No account needed.

Start free test
All Spring Core questions →