Skip to content

Commit

Permalink
Fix custom error message test
Browse files Browse the repository at this point in the history
  • Loading branch information
navamedha committed Oct 20, 2023
1 parent dd6cdb4 commit b58bb0b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -673,16 +673,16 @@ type TestCustomErrMsgStruct struct {
LastName string `json:"lname" validate:"required"`
Age uint8 `validate:"gte=0,lte=130" msg:"Age must be between 0 and 130, inclusive"`
Email string `json:"email" validate:"required,email" msg:"Email is invalid"`
Addr11 string `json:"addr1sdf"`
Addr1 string `json:"addr1"`
Addr2 string
Addr3 string `json:"addr3"`
}

func StructValidationTestStructCustomErrorMessage(sl StructLevel) {
st := sl.Current().Interface().(TestCustomErrMsgStruct)

if st.Addr11 == "" && st.Addr2 == "" && st.Addr3 == "" {
sl.ReportErrorWithMsg(st.Addr11, "addr1", "Addr1", "addr1oraddr2oraddr3", "",
if st.Addr1 == "" && st.Addr2 == "" && st.Addr3 == "" {
sl.ReportErrorWithMsg(st.Addr1, "addr1", "Addr1", "addr1oraddr2oraddr3", "",
"Any one of Addr1 or Addr2 or Addr3 must be provided")
sl.ReportErrorWithMsg(st.Addr2, "Addr2", "Addr2", "addr1oraddr2oraddr3", "",
"Any one of Addr1 or Addr2 or Addr3 must be provided")
Expand Down

0 comments on commit b58bb0b

Please sign in to comment.