asaskevich / govalidator

[Go] Package of validators and sanitizers for strings, numerics, slices and structs
MIT License
6.05k stars 555 forks source link

get the first error message #400

Open ghost opened 4 years ago

ghost commented 4 years ago

I hope there is an api to get the first error in the error, instead of getting all the errors

 user := &User{}

 _, e := govalidator.ValidateStruct(user)

if e != nil {
    fmt.Println(govalidator.FirstError(e).Error()) // first error message
}
sergeyglazyrindev commented 3 years ago

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.