[HV-1831] filters @Valid annotations from jvm and native types#1334
[HV-1831] filters @Valid annotations from jvm and native types#1334thst71 wants to merge 3 commits intohibernate:mainfrom
Conversation
| return constrainable.getType().getTypeName().startsWith( "java." ) | ||
| || constrainable.getType().getTypeName().startsWith( "javax." ) | ||
| || constrainable.getType().getTypeName().matches( BUILTIN_TYPE_NAMES ); |
There was a problem hiding this comment.
yeah ... I can see how it can be tempting to ignore these types 😃.
this probably will work for the primitives, but we cannot safely discard any classes. The user may define a model as:
class SomeClass {
@Valid
Object object;
}which is a valid use case and the type of object field is checked at the runtime when SomeClass instance is passed for validation. So even if the class from these packages will not have any constraints, someone might extend the class and apply the constraints in that extended class...
Another problem is that even though these classes won't have any constraints declared as annotations, a user can always define a constraint through a programmatic DSL, or via XML...
That's why I'm leaning more towards this being a problem of the code generators that are adding redundant @Valid annotations ...
There was a problem hiding this comment.
Ok, good point. I thought about making this configurable, but I need to look at other config properties and how these are wired. I will remove the java check.
https://hibernate.atlassian.net/browse/HV-1831