Open aku-ato opened 1 year ago
I found the solution here https://github.com/go-playground/validator/issues/624#issuecomment-937714455
type User struct {
Password *string `validate:"required_without=UpdatedAt,omitempty,min=9,max=20"`
UpdatedAt *time.Time
}
Package version eg. v9, v10:
v10
Issue, Question or Enhancement:
I am using
go-playground/validator
to validate my struct fields. I've encountered an issue where, if a field (e.g.,Password
) should be required only under certain conditions using therequired_without
tag, other validation constraints (likemin
,max
) still get executed even when the field is deemed not required.I expected other validation constraints not to run if the field is not required due to
required_without
.Code sample, to showcase or reproduce: