asaskevich / govalidator

[Go] Package of validators and sanitizers for strings, numerics, slices and structs
MIT License
5.97k stars 554 forks source link

Multiple validation but with "OR" logic - e.g. valid:"host|ip" #459

Open padurean opened 2 years ago

padurean commented 2 years ago

Feature Request

Is it possible to use multiple validators on a struct field with "OR" logic? For example the following would mean that Address must be either a valid host name or a valid IP:

type Config struct {
  Address string `validate:"host|ip, required"`
}