Scrivio Interview library
ConceptFoundations5 min read · updated 12 November 2026

What is the difference between @Valid and @Validated?

@Valid comes from Jakarta Validation: it asks for an object to be validated and makes validation cascade into nested objects, which is why it also goes on fields. @Validated comes from Spring: it does the same job on controller parameters but also accepts validation groups, and placed on a class it enables method validation through a proxy, so constraints on method parameters and return values are checked. For nested objects inside a validated object, we still put @Valid on the field.

Background to this question

Both annotations show up in every Spring project, often side by side, and many developers use them interchangeably until something does not get validated. The difference matters in three situations: when we need groups, when we want to validate parameters of a service method, and when an object contains other objects. In this answer, we will recap where each annotation comes from, compare them on a controller, see how @Validated on a class turns on method validation, and look at why nested objects still need @Valid.

1A Quick Recap of Where They Come From

@Valid is part of the Jakarta Validation specification, in the package jakarta.validation. Its official meaning is cascade: validate this object, and when placed on a field, validate the object the field points to as well. Any validation provider, such as Hibernate Validator, understands it.

@Validated is Spring's own annotation, in org.springframework.validation.annotation. Spring created it because @Valid has no attribute for validation groups, a feature of the specification that lets us apply only a subset of constraints. Spring also gave it a second job: on a class, it marks the bean for method validation.

@Valid compared with @Validated
Aspect@Valid@Validated
Defined byJakarta ValidationSpring Framework
On a controller parametervalidates the argumentvalidates the argument
Validation groupsno, always Defaultyes, @Validated(OnCreate.class)
On a fieldcascades into the nested objectnot allowed
On a classno effectenables method validation via a proxy

2On a Controller Parameter

For a @RequestBody or @ModelAttribute parameter, both annotations trigger validation in the same way. Spring MVC checks the argument after binding and throws MethodArgumentNotValidException when there are violations.

Java
@PostMapping("/customers")
Customer create(@Valid @RequestBody CustomerDto dto) { ... } // all Default constraints
@PutMapping("/customers/{id}")
Customer update(@PathVariable long id,
@Validated(OnUpdate.class) @RequestBody CustomerDto dto) { ... } // only the OnUpdate group
// POST with blank name -> 400 (MethodArgumentNotValidException)

The only difference here is the group. @Valid always validates the Default group, which contains every constraint that declares no groups. @Validated(OnUpdate.class) validates only constraints that list OnUpdate in their groups attribute. If we need groups on a controller, @Validated is the tool; otherwise @Valid is the standard choice.

3On a Class: Method Validation Through a Proxy

The bigger difference appears outside controllers. Suppose a service method should reject a blank customer id. Putting @NotBlank on the parameter does nothing by itself, because nothing calls the validator. When we put @Validated on the class, Spring Boot's MethodValidationPostProcessor wraps the bean in a proxy, a generated wrapper object that intercepts calls, and checks parameter and return value constraints before and after each call.

Java
@Service
@Validated
public class CustomerService {
public Customer find(@NotBlank String id) { ... }
public @NotNull Customer create(@Valid CustomerDto dto) { ... }
}
customerService.find(" ");
// jakarta.validation.ConstraintViolationException: find.id: must not be blank
Step throughMethod validation with @Validated on the class
CallerProxyValidatorCustomerService
find(" ")
validate parameters
id: must not be blank
throw ConstraintViolationException

4 messages in order. Play them, or step through them one at a time.

The real service method is never called when a parameter is invalid.

Notice two things. The failure is a ConstraintViolationException, not MethodArgumentNotValidException, because it comes from the proxy rather than from Spring MVC. And because it is a proxy, the usual proxy rule applies: a call from one method of the same class to another skips it, so self-invocations are not validated. Inside the validated method, @Valid on the dto parameter still asks for the object's own constraints to be checked.

4Nested Objects Still Need @Valid

When an object contains another object, validation stops at the boundary unless we ask it to continue. That request is @Valid on the field. @Validated cannot go on a field at all, so even in a class validated with groups, cascading always uses @Valid.

Java
public record CustomerDto(
@NotBlank String name,
@Valid @NotNull AddressDto address, // cascade into the address
List<@Valid ContactDto> contacts) {} // cascade into each element
public record AddressDto(@NotBlank String street, @NotBlank String city) {}
// {"name": "Ana", "address": {"street": ""}} -> 400: address.street must not be blank

When we validate with a group, the group travels down the cascade: @Validated(OnUpdate.class) on the parameter applies the OnUpdate group to the nested address too. So the rule of thumb is simple: @Valid for cascading and for plain validation, @Validated when we need groups or method validation.

5Follow-up questions

Do we need @Validated on a controller to validate @RequestBody?

No. @Valid on the parameter is enough, because Spring MVC's argument resolver validates it. Putting @Validated on the controller class turns on the AOP method validation as well, which can lead to double validation and different exception types, so Spring's documentation recommends against combining it with the built-in controller method validation in 6.1 and later.

Can @Validated be used on a single method?

Yes. @Validated on a method of a validated class can choose groups for that method's validation. But method validation is only switched on by @Validated at class level; on a method alone of an unannotated class, it has no effect.

Which exception should a global handler map for each?

MethodArgumentNotValidException, from validated @RequestBody and @ModelAttribute parameters, and HandlerMethodValidationException, from Spring 6.1 built-in controller method validation, both map to 400. ConstraintViolationException from class-level @Validated proxies is a 500 by default, so if it can happen for client input, the handler should map it to 400 as well.

6Conclusion

In this answer, we saw that @Valid is the Jakarta Validation annotation that triggers validation and cascades into nested objects, while @Validated is Spring's annotation that adds validation groups and, on a class, enables method validation through a proxy that throws ConstraintViolationException. On controller parameters both work, with @Validated needed only for groups, and cascading into nested fields always uses @Valid.

What to say in the interviewAbout 70 seconds aloud

Open with

@Valid is from the Jakarta Validation specification. It means validate this object, and its official meaning is cascading: on a field or a type argument, it tells the validator to go into the nested object and check its constraints too. @Validated is Spring's annotation, and it exists mainly because @Valid cannot specify validation groups.

Then, if they want more

On a controller parameter, both trigger validation the same way, and Spring throws MethodArgumentNotValidException if it fails; @Validated(OnUpdate.class) lets me check only the constraints of a group. The second job of @Validated is on a class.

When I put it on a service, Spring's MethodValidationPostProcessor wraps the bean in a proxy, and constraints on method parameters and return values, like @NotBlank String id, are checked on each call, throwing ConstraintViolationException. Because it is a proxy, internal calls within the same class skip it.

And for nested objects, @Validated cannot be put on fields, so cascading always uses @Valid, for example @Valid AddressDto address or List<@Valid ContactDto>. So my rule is: @Valid for normal validation and cascading, @Validated for groups and for method validation of Spring beans.

About this answer

Last updated
12 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "What is the difference between @Valid and @Validated?": https://scrivio-interview-library.netlify.app/spring-boot/request-validation/bc9c7bc5a3/