I'm developing an spring web application (Spring MVC 4) using Bean Validation (JSR-303). But there are some occasions when i need a different validation on my frontend (thymeleaf), e.g. I need to build a register form to save user's information, for this, it's necessary fields like "emailConfirmation", "passwordConfirmation". This kind of fields i dont need to save in my db, so they are @Transient, but there are also @NotNull, because i need to validate the form.
When i need to do something else with this domain and save it, the Bean Validation blocks me, because they are @NotNull or @NotEmpty fields.
My question is, what should i do in this situation?
What i've already thought:
- Make a custom validation for this domain, and remove @NotNull, @NotEmpty annotations from those fields.
- Create a different domain just to use it in my frontend, and after validate it, copy it to the entity domain.
Thx, Alexandre.