Skip to content

Commit

Permalink
Add user friendly error message
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrochevallier authored and dsyer committed May 16, 2024
1 parent c7bc8b1 commit 405cdc6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import jakarta.persistence.OneToMany;
import jakarta.persistence.OrderBy;
import jakarta.persistence.Table;
import jakarta.validation.constraints.Digits;
import jakarta.validation.constraints.Pattern;
import jakarta.validation.constraints.NotBlank;

/**
Expand All @@ -56,7 +56,7 @@ public class Owner extends Person {

@Column(name = "telephone")
@NotBlank
@Digits(fraction = 0, integer = 10)
@Pattern(regexp = "\\d{10}", message = "Telephone must be a 10-digit number")
private String telephone;

@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ void testProcessCreationFormSuccess() throws Exception {
.param("lastName", "Bloggs")
.param("address", "123 Caramel Street")
.param("city", "London")
.param("telephone", "01316761638"))
.param("telephone", "1316761638"))
.andExpect(status().is3xxRedirection());
}

Expand Down Expand Up @@ -188,7 +188,7 @@ void testProcessUpdateOwnerFormSuccess() throws Exception {
.param("lastName", "Bloggs")
.param("address", "123 Caramel Street")
.param("city", "London")
.param("telephone", "01616291589"))
.param("telephone", "1616291589"))
.andExpect(status().is3xxRedirection())
.andExpect(view().name("redirect:/owners/{ownerId}"));
}
Expand Down

0 comments on commit 405cdc6

Please sign in to comment.