mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-22 15:55:49 +00:00
added user friendly messages on blank fields
This commit is contained in:
parent
923e2b7aa3
commit
0a0e40a8cf
2 changed files with 7 additions and 7 deletions
|
@ -28,11 +28,11 @@ import jakarta.validation.constraints.NotBlank;
|
|||
public class Person extends BaseEntity {
|
||||
|
||||
@Column(name = "first_name")
|
||||
@NotBlank
|
||||
@NotBlank(message = "First Name cannot be blank")
|
||||
private String firstName;
|
||||
|
||||
@Column(name = "last_name")
|
||||
@NotBlank
|
||||
@NotBlank(message = "Last Name cannot be blank")
|
||||
private String lastName;
|
||||
|
||||
public String getFirstName() {
|
||||
|
|
|
@ -30,8 +30,8 @@ import jakarta.persistence.JoinColumn;
|
|||
import jakarta.persistence.OneToMany;
|
||||
import jakarta.persistence.OrderBy;
|
||||
import jakarta.persistence.Table;
|
||||
import jakarta.validation.constraints.Digits;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
|
||||
/**
|
||||
* Simple JavaBean domain object representing an owner.
|
||||
|
@ -47,16 +47,16 @@ import jakarta.validation.constraints.NotBlank;
|
|||
public class Owner extends Person {
|
||||
|
||||
@Column(name = "address")
|
||||
@NotBlank
|
||||
@NotBlank(message = "Address cannot be blank")
|
||||
private String address;
|
||||
|
||||
@Column(name = "city")
|
||||
@NotBlank
|
||||
@NotBlank(message = "City cannot be blank")
|
||||
private String city;
|
||||
|
||||
@Column(name = "telephone")
|
||||
@NotBlank
|
||||
@Digits(fraction = 0, integer = 10)
|
||||
@NotBlank(message = "Telephone cannot be blank")
|
||||
@Pattern(regexp = "\\d{10}", message = "Telephone must be a 10-digit number")
|
||||
private String telephone;
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
|
||||
|
|
Loading…
Reference in a new issue