An annotation to reference other object annotations...

Description

Hello,
In large code bases, there may be times where developers use a Facade pattern to get a value from a different object. For example in the UserBean object below, getting the email actually comes from the User class. I'd like to add a @ValidateReference annotation (or something like it) to the Spec that references to the object and field for validation. In the current implementation, I have to validate twice using validator.validateValue(User.class, "email", email, EmailGroup.class) to validate the email is formatted correctly and then validator.validate(userBean) to validate that both fields match. I would prefer to validate once on the email property using validator.validate(userBean, EmailGroup.class) – with the @ValidateReference addition.

I could simply copy and paste the email constraints from User to UserBean but then I'd get complaints of not being DRY (Don't Repeat Yourself).

Please correct me if my understanding above is incorrect.

Code:

Code:

Code:

Code:

Environment

None

Status

Assignee

Unassigned

Reporter

James Moliere

Labels

None

Feedback Requested

None

Feedback Requested By

None

backPortable

None

Suitable for new contributors

None

Pull Request

None

backportDecision

None

backportReEvaluate

None

Priority

Major
Configure