Skip to content

Commit

Permalink
Fix handling of slice rules of envoyproxy/validate
Browse files Browse the repository at this point in the history
  • Loading branch information
htdvisser committed May 5, 2020
1 parent e803e03 commit 09a73be
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions extensions/envoyproxy_validate/envoyproxy_validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ func flattenRules(prefix string, vv reflect.Value) (rules []ValidateRule) {
if vv.Len() == 0 {
return nil
}
fallthrough
default:
rules = append(rules, ValidateRule{Name: prefix, Value: vv.Interface()})
}
Expand Down
2 changes: 2 additions & 0 deletions extensions/envoyproxy_validate/envoyproxy_validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ func TestTransform(t *testing.T) {
Type: &validate.FieldRules_String_{
String_: &validate.StringRules{
MinLen: proto.Uint64(1),
NotIn: []string{"invalid"},
},
},
}
Expand All @@ -25,5 +26,6 @@ func TestTransform(t *testing.T) {
rules := transformed["validate.rules"].(ValidateExtension).Rules()
require.Equal(t, rules, []ValidateRule{
{Name: "string.min_len", Value: uint64(1)},
{Name: "string.not_in", Value: []string{"invalid"}},
})
}

0 comments on commit 09a73be

Please sign in to comment.