Open lb151 opened 4 years ago
I've written an example to test it. There are three errors in Addresses
, but only one error is given.
The code is as follows:
func TestIssue353(t *testing.T) {
type Address struct {
CountryCode string `json:"country_code11" valid:"ISO3166Alpha3"`
}
type Details struct {
Email string `json:"email" valid:"email"`
}
type Person struct {
Details Details `json:"details"`
Addresses []Address `json:"addresses"`
}
p := Person{
Details: Details{
Email: "gogopher@example-com", //gogopher@example-com
},
Addresses: []Address{
{CountryCode: "GBP"},
{CountryCode: "AUS"},
{CountryCode: "CUS"},
{CountryCode: "DUS"},
},
}
_, err := ValidateStruct(p)
fmt.Println(strings.ReplaceAll(err.Error(), ";", "\n"))
//output:
//Addresses.0.addresses: GBP does not validate as ISO3166Alpha3
//Details.email: gogopher@example-com does not validate as email
}
Hello guys! I forked this package cause owner disappeared. Hope, he will be back, but it would be easier to merge these changes back if he is back Link to my repo: create issue there and we'll discuss it.
The result of the structure verification is returned and a single error message is returned,Validation stops at one error and returns an error instead of validating all