Skip to content

Commit

Permalink
Add flag to disable parameter validation (#595)
Browse files Browse the repository at this point in the history
Set validation.Disabled to true to globally disable param validation.
This is an escape hatch to work around bugs in param validation.
  • Loading branch information
jhendrixMSFT authored Dec 8, 2020
1 parent 6afd852 commit 446f41b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions autorest/validation/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ import (
"strings"
)

// Disabled controls if parameter validation should be globally disabled. The default is false.
var Disabled bool

// Constraint stores constraint name, target field name
// Rule and chain validations.
type Constraint struct {
Expand Down Expand Up @@ -68,6 +71,9 @@ const (
// Validate method validates constraints on parameter
// passed in validation array.
func Validate(m []Validation) error {
if Disabled {
return nil
}
for _, item := range m {
v := reflect.ValueOf(item.TargetValue)
for _, constraint := range item.Constraints {
Expand Down

0 comments on commit 446f41b

Please sign in to comment.