我希望在我的 validate() 方法上有特定的行为(比如我可以使用 groups 注释的那个),如果它被调用的话
Form<User> loginForm = form(User.class, User.Login.class).bindFromRequest();`
或开
Form<User> registerForm = form(User.class, User.Register.class).bindFromRequest();
用户模型:
@Entity
public class User extends Model {
public interface Register {}
public interface Login{}
@Required(groups = {Register.class, Login.class})
public String username;
@Required(groups = {Register.class, Login.class})
public String password;
public List<ValidationError> validate() {
... // Here I would like to distinguish User.Login.class from User.Register.class
}
}
应用控制器
public static Result loginSubmit(){
Form<User> loginForm = form(User.class, User.Login.class).bindFromRequest();
}
public static Result registerSubmit(){
Form<User> registerForm = form(User.class, User.Register.class).bindFromRequest();
}