Closed yumin5723 closed 4 years ago
how to rewrite error.go function Error()?thanks
Because validation.Errors
is a map, you can iterate the errors in it and generate your preferred error string.
Tried to do this one,
val := validation.Errors{
"name": validation.Validate(user.Name, validation.Required),
"email": validation.Validate(user.Email, validation.Required, is.Email),
}
for _, e := range val {
return e
}
return val.Format()
It does terminate name:
from the error message, but the bad thing is it skips email and the rest of validation because of the return in the loop. Have no idea what else can I do. Can you provide an example of this?
how can i skip the element in err message