user (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=5edaad5...
) *created* an issue
Bean Validation (
https://hibernate.atlassian.net/browse/BVAL?atlOrigin=eyJpIjoiYzAyOGIwMTB...
) / Bug (
https://hibernate.atlassian.net/browse/BVAL-750?atlOrigin=eyJpIjoiYzAyOGI...
) BVAL-750 (
https://hibernate.atlassian.net/browse/BVAL-750?atlOrigin=eyJpIjoiYzAyOGI...
) Is @Valid supported in composite constraints (
https://hibernate.atlassian.net/browse/BVAL-750?atlOrigin=eyJpIjoiYzAyOGI...
)
Issue Type: Bug Affects Versions: 2.0.2 Assignee: Unassigned Components: api, spec-general
Created: 05/Jun/2020 14:14 PM Environment: OpenJDK 14
Hibernate Validator 6.1.4.Final
SE environment Labels: validation Priority: Minor Reporter: user (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=5edaad5...
)
I have been trying to get @Valid to work in a composite constraint but no luck so far. I
went through HV documentation and searched online to find out if @Valid is not supported
in composite constraints but I can't find any mention of that.
Here is a simple example that shows the issue:
public class Foo {
@NotNull // without composite constraint. both work as expected
@Valid
Bar bar
@NotNullAndValid // composite constraint consisting of @NotNull and @Valid
Baz baz; // @NotNull gets applied but cascade validation
(@Valid) does not
}
@NotNull
@Valid
@Constraint(validatedBy={})
// RUNTIME retention, FIELD target for simplicity
public @ interface NotNullAndValid {
// message, groups, payload
}
So my question is this: Is @Valid supported in composite constraint? If not, can you
please point me to some online resource that explains why.
My guess is that it's not supported for the following reason: @Valid does not support
groups (i.e., if you have @Valid declared somewhere then cascade validation will always
take place regardless of the validation group that was specified in/passed to the
validator API call). On the other hand, composite constraints support groups/can be turned
on/off by validating a bean for a specific group. If @Valid were to be placed in a
composite constraint then you effectively make @Valid support groups (i.e., cascade
validation will become group based rather than the mere presence/absence of @Valid
constraint).
Any thoughts?
(
https://hibernate.atlassian.net/browse/BVAL-750#add-comment?atlOrigin=eyJ...
) Add Comment (
https://hibernate.atlassian.net/browse/BVAL-750#add-comment?atlOrigin=eyJ...
)
Get Jira notifications on your phone! Download the Jira Cloud app for Android (
https://play.google.com/store/apps/details?id=com.atlassian.android.jira....
) or iOS (
https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100128- sha1:078e4e4 )