go-ozzo / ozzo-validation

An idiomatic Go (golang) validation package. Supports configurable and extensible validation rules (validators) using normal language constructs instead of error-prone struct tags.
MIT License
3.73k stars 224 forks source link

Multiple errors in the same field #115

Open nerock opened 4 years ago

nerock commented 4 years ago

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 commented 4 years ago

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

voodoo-dn commented 3 years ago

@qiangxue Hi. Could you implement such behavior?)

thexpand commented 1 year ago

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?