1 package validator 2 3 // Option represents a configurations option to be applied to validator during initialization. 4 type Option func(*Validate) 5 6 // WithRequiredStructEnabled enables required tag on non-pointer structs to be applied instead of ignored. 7 // 8 // This was made opt-in behaviour in order to maintain backward compatibility with the behaviour previous 9 // to being able to apply struct level validations on struct fields directly. 10 // 11 // It is recommended you enabled this as it will be the default behaviour in v11+ 12 func WithRequiredStructEnabled() Option { 13 return func(v *Validate) { 14 v.requiredStructEnabled = true 15 } 16 } 17 18 // WithPrivateFieldValidation activates validation for unexported fields via the use of the `unsafe` package. 19 // 20 // By opting into this feature you are acknowledging that you are aware of the risks and accept any current or future 21 // consequences of using this feature. 22 func WithPrivateFieldValidation() Option { 23 return func(v *Validate) { 24 v.privateFieldValidation = true 25 } 26 } 27