Announcement Announcement Module
Collapse
No announcement yet.
Can I re-use my validations? Do I create a different class per form? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Can I re-use my validations? Do I create a different class per form?

    I have a UserForm.java file, that has:

    Code:
    public class UserForm {
        @NotNull(message = "Email cannot be empty.")
        @Size(min=3, max=100, message="Email must be between 3 and 100 characters long.")
        private String email;
        ..
        ..
    }
    I am using this when creating a user. Now when I am updating/editing a user, some of the validations are not relevant like the password field etc.

    I should create a new class per form correct?

    Is it possible to re-use the validations so I don't repeat the same validation logic for UserForm and EditForm?
    i.e. I will have the same email validation on both edit and create forms.
Working...
X