Skip to content

Commit

Permalink
🐛 fix: util convTypeByBaseKind support more basic type convert. issues
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Jan 5, 2024
1 parent 372b694 commit b24adf8
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions issues_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1480,6 +1480,23 @@ func TestIssues_223(t *testing.T) {
assert.StrContains(t, s, "clinics.*.doctors.*.duration value must be an integer")
}

// https://github.com/gookit/validate/issues/245
// required_if 中,当指定的 anotherField 为 uint8 类型时,校验失效
func TestIssues_245(t *testing.T) {
type MyStruct struct {
ID int64 `json:"id" validate:"required"`
Type uint8 `json:"ip_type" validate:"in:0,1"`
IpList []string `json:"ip_list" validate:"required|validateIP"`

Check warning on line 1489 in issues_test.go

View workflow job for this annotation

GitHub Actions / linter

var-naming: struct field IpList should be IPList (revive)
Field int `json:"field" validate:"required_if:Type,1"`
}

ms := &MyStruct{Type: 1}
v := validate.Struct(ms)
assert.False(t, v.Validate())
assert.ErrSubMsg(t, v.Errors, "id is required to not be empty")
// fmt.Println(v.Errors)
}

// issues#246 类似这样的结构体和规则
type CertStore struct {
Type string `form:"type" json:"type"`
Expand Down

0 comments on commit b24adf8

Please sign in to comment.