options.go 630 B

12345678910111213141516
  1. package validator
  2. // Option represents a configurations option to be applied to validator during initialization.
  3. type Option func(*Validate)
  4. // WithRequiredStructEnabled enables required tag on non-pointer structs to be applied instead of ignored.
  5. //
  6. // This was made opt-in behaviour in order to maintain backward compatibility with the behaviour previous
  7. // to being able to apply struct level validations on struct fields directly.
  8. //
  9. // It is recommended you enabled this as it will be the default behaviour in v11+
  10. func WithRequiredStructEnabled() Option {
  11. return func(v *Validate) {
  12. v.requiredStructEnabled = true
  13. }
  14. }