【发布时间】:2015-06-17 10:35:32
【问题描述】:
我在 Dropwizard 中有一个表示,其中包含带有注释 @ValidationMethod 的方法。
Dropwizard 示例:
@ValidationMethod(message="may not be Coda")
public boolean isNotCoda() {
return !("Coda".equals(name));
}
请注意,方法必须以“is”开头。这是 Hibernate Validator 的限制。
我的例子:
@NotBlank(message = REQUIRED)
private String password;
@JsonIgnore
@ValidationMethod(message = "the password fields must match")
public boolean isPasswordEqualRepeatedPassword() {
}
@JsonIgnore
@ValidationMethod(message = "the password must not contain or be equal to the username")
public boolean isNotEqualOrContainUsername(){
}
目前的回应:
"field" : "PasswordEqualRepeatedPassword", "message" = "密码字段必须匹配"
"field" : "NotEqualOrContainUsername", "message" = "密码不能包含或等于用户名"
我希望该字段与类属性一样等于密码。问题是我不能命名 isPassword() 的方法得到以下响应:
“字段”:“密码”, "message" = "密码字段必须匹配"
“字段”:“密码”, "message" = "密码不能包含或等于用户名"
有没有办法做到这一点?
【问题讨论】:
标签: java jackson dropwizard hibernate-validator