ozzo-validation icon indicating copy to clipboard operation
ozzo-validation copied to clipboard

Multiple errors in the same field

Open nerock opened this issue 4 years ago • 3 comments

Hi, is it possible to get all the errors of a field in an array instead just the first? The code I'm trying right now:

func (r Request) Valid() error {
    return validation.ValidateStruct(&r,
        validation.Field(&r.Name,
            validation.Length(MIN, MAX).Error("Length must be between 1 and 10),
            validation.In("nerock").Error("Must be my name"),
        ),
        validation.Field(&r.Email,
            validation.Required.Error("You need email"),
        ),
    )
}

nerock avatar Jun 04 '20 16:06 nerock

If anyone is interested I forked it to do just that, https://github.com/nerock/ozzo-validation

nerock avatar Jun 15 '20 19:06 nerock

@qiangxue Hi. Could you implement such behavior?)

voodoo-dn avatar Jun 02 '21 14:06 voodoo-dn

It's been nearly 3 years. Is there no possibility to support this? @nerock Creating a fork is an option, surely, but it needs to be updated constantly, so not a great option. @voodoo-dn What did you end up using?

OFFTOPIC: Is this library even maintained? Or are you already using alternatives?

thexpand avatar Apr 13 '23 22:04 thexpand