Adding a name to the User entity
We have already coded our User entity like this:
@Entity
@Table(name="usr")
public class User extends AbstractUser<User,Long> {
private static final long serialVersionUID = 2716710947175132319L;
}
Add a name field to it, looking like this:
public static final int NAME_MIN = 1;
public static final int NAME_MAX = 50;
@JsonView(SignupInput.class)
@NotBlank(message = "{blank.name}", groups = {SignUpValidation.class, UpdateValidation.class})
@Size(min=NAME_MIN, max=NAME_MAX, groups = {SignUpValidation.class, UpdateValidation.class})
@Column(nullable = false, length = NAME_MAX)
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
Note that groups = {SignUpValidation.class, UpdateValidation.class}
tells Spring Lemon to apply the validation only while signing up or updating profile. For more details, refer the documentation and resources.