Skip to content

Commit

Permalink
Merge pull request #392 from htdvisser/fix/validate-extension
Browse files Browse the repository at this point in the history
Bugfix for envoyproxy/validate extension
  • Loading branch information
pseudomuto authored May 7, 2020
2 parents 1da6242 + b62fb0e commit 557ff76
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Changed

* Stripped unnecessary whitespace from markdown templates
* Renamed `lyft_validate` extension to `envoyproxy_validate`
* Fixed `envoyproxy_validate` rules with slice values such as `in` and `not_in`

## [v1.3.1](https://github.com/pseudomuto/protoc-gen-doc/compare/v1.3.0...v1.3.1)

Expand Down
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
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"}},
})
}
9 changes: 9 additions & 0 deletions extensions/lyft_validate/alias.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package extensions

import evp "github.com/pseudomuto/protoc-gen-doc/extensions/envoyproxy_validate"

// ValidateRule represents a single validator rule from the (validate.rules) method option extension.
type ValidateRule = evp.ValidateRule

// ValidateExtension contains the rules set by the (validate.rules) method option extension.
type ValidateExtension = evp.ValidateExtension

0 comments on commit 557ff76

Please sign in to comment.