Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to specify validation group for @Valid?

People also ask

How do you use validation groups?

You create a validation group by setting the ValidationGroup property to the same name (a string) for all the controls you want to group. You can assign any name to a validation group, but you must use the same name for all members of the group.

What is the importance of validation group property?

Use the ValidationGroup property to specify the name of the validation group for which the Button control causes validation when it posts back to the server. This property has an effect only when the value of the CausesValidation property is set to true .

What are Group constraints?

Group constraints are optional linear constraints that group assets together and enforce bounds on the group weights (see Group Constraints).

What is @valid annotation in Spring boot?

The @Valid annotation will tell spring to go and validate the data passed into the controller by checking to see that the integer numberBetweenOneAndTen is between 1 and 10 inclusive because of those min and max annotations.


The standard java @Valid annotation doesn't support groups. However, Spring now includes an @Validated annotation which does the same job as @Valid, but allows you to specify which groups to use in the validation:

@ModelAttribute("myCandidate") @Validated(UpdateGroup.class) Candidate myCandidate

Note that this annotation is only available in Spring 3.1 and newer.