| That’s really unfortunate that for 7 years such a simple fix hasn’t been added to hibernate validator, and that’s because “in some situations this bean would be null”. So what? Note that without this feature you cannot do any contextual validation with hibernate validator, like for example this:
@Entity class User {
protected Country country;
@GovId
protected String govId;
}
If you want to use this entity to represent users from different countries, and you want to implement @GovId validator so that it uses different validation for users from different countries, you currently cannot do it with hibernate validator because there’s no way to access country field of the User entity from the validation context. Fortunately there’s a way to do it using beans validation implementation from Micronaut framework which apparently doesn’t have a problem with injecting root bean into the validation context. |