Add @Equals(property="name")

Description

It would be nice to have something like:

public class Customer implements Serializable {
private String password;

@Equals(property="password") // the name of the property above
private String password2;
...
}

Such entity classes would be helpful for user interfaces e.g. inside registration pages where you want to avoid typos or ensure that a human being is registering.

Environment

None

Activity

Show:
Emmanuel Bernard
September 16, 2008, 10:01 PM

As a class-level constraint yes but I am more in favor of letting users write their own.

@SamePassword(old, new) is more meaningful than @Equals(property1, property2)

Hardy Ferentschik
February 12, 2009, 4:03 PM

Move issues into the legacy component since they are pre 3.x which is based on a different codebase

David Parks
November 8, 2010, 12:24 PM

Here is an excellent implementation. I would recommend contacting this guy and using his implementation.

And to vote for this: as a new user I ran into this missing-feature day one and it really made me wonder how complete the package is. This seems like pretty simple functionality that the average user shouldn't be writing custom annotations to implement. Who doesn't need to validate that two passwords are the same? That's common to virtually every app right?

http://stackoverflow.com/questions/1972933/cross-field-validation-with-hibernate-validator-jsr-303

Hardy Ferentschik
November 8, 2010, 1:12 PM

This is an issue created against the obsolete 3.x code base of Validator. As a matter of fact Hibernate Validator 4.1.x has a @ScriptAssert annotation where the usecase can be solved via:

Robin Sander
March 27, 2014, 12:13 PM

@Hardy: using ScriptAssert you always get a class level error but sometimes the error belongs to or the message should be displayed along with a certain field. It would be nice if ScriptAssert could be placed on a field and create a field error in this case instead of a class level error!

Assignee

Unassigned

Reporter

Juergen Zimmermann

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