You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
package main
import (
"fmt""github.com/gookit/validate"
)
typeSamplestruct {
Val*bool`validate:"required"`
}
typeNestedstruct {
Samples []Sample`validate:"slice"`
}
funcmain() {
val, val2:=false, truedata:=Sample{
Val: &val,
}
data2:=Sample{
Val: &val2,
}
data3:=Sample{
Val: nil,
}
data4:=Nested{
Samples: []Sample{data, data2},
}
v1:=validate.Struct(data)
ok1:=v1.Validate()
v2:=validate.Struct(data2)
ok2:=v2.Validate()
v3:=validate.Struct(data3)
ok3:=v3.Validate()
v4:=validate.Struct(data4)
ok4:=v4.Validate()
fmt.Println(ok1, v1.Errors) // Should not fail and does not fail.fmt.Println(ok2, v2.Errors) // Should not fail and does not fail.fmt.Println(ok3, v3.Errors) // Should fail and fails.fmt.Println(ok4, v4.Errors) // Should not fail and fails.
}
Expected behavior
The Nested data structure at data4 should validate correctly.
Screenshots
n/a
Additional context
n/a
The text was updated successfully, but these errors were encountered:
System (please complete the following information):
macOS
1.20
1.4.6
Describe the bug
Nested resources are evaluated differently. This is super confusing and buggy.
To Reproduce
https://go.dev/play/p/-4zzXj4NxLK
Expected behavior
The Nested data structure at
data4
should validate correctly.Screenshots
n/a
Additional context
n/a
The text was updated successfully, but these errors were encountered: