Using the validation from PlayFramework and the data binding, is it possible, via (maybe) a decorator, to avoid binding some fields?
For example, I have this model :
class User extends Model {
@Required
@Email
public String email;
// I'd like to avoid setting this
public String password;
}
and in my model :
Store store = new Store();
Binder.bindBean(params.getRootParamNode(), store, null);
validation.valid(store);
If the user POST email AND password, password will be also set, but I don’t want to.
How can I do that?
If you don’t want to persist the data, but you want it to be bound as part of the automatic binding, then you can use the @Transient annotation…
Example
If you don’t want it to be bound at all, then use the NoBinding annotation
Example