-
Notifications
You must be signed in to change notification settings - Fork 235
Open
Description
I wanted to validate a struct. For example:
type User struct {
Name string
Cars []Car
}
type Car struct {
ID int
Name string
}
func (v User) Validate() error {
return validation.ValidateStruct(&v,
validation.Field(&v.Name, validation.Required),
validation.Field(&v.Cars, validation.Length(1, 0)), // car's validation is triggered here... But I don't really care... How can I skip it
)
}
func (c Car) Validate() error {
return validation.ValidateStruct(&c,
validation.Field(&c.Name, validation.Required),
)
}
As of the documentation, Car
struct implements the Validatable
interface. Hence, it will be .Validate()
will be called. But what if I want to skip it? Just the validation.Length()
.
Thank you so much.
Metadata
Metadata
Assignees
Labels
No labels