Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 5 additions & 12 deletions plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// See LICENSE for licensing terms.

/*

The validator plugin generates a Validate method for each message.
By default, if none of the message's fields are annotated with the gogo validator annotation, it returns a nil.
In case some of the fields are annotated, the Validate function returns nil upon sucessful validation, or an error
Expand All @@ -28,23 +27,17 @@ The equal plugin also generates a test given it is enabled using one of the foll

Let us look at:

github.com/gogo/protobuf/test/example/example.proto
github.com/gogo/protobuf/test/example/example.proto

Btw all the output can be seen at:

github.com/gogo/protobuf/test/example/*
github.com/gogo/protobuf/test/example/*

The following message:



given to the equal plugin, will generate the following code:



and the following test code:


*/
package plugin

Expand Down Expand Up @@ -677,11 +670,11 @@ func (p *plugin) validatorWithNonRepeatedConstraint(fv *validator.FieldValidator
}

// Identify non-repeated constraints based on their name.
if fieldName != "RepeatedCountMin" && fieldName != "RepeatedCountMax" {
return true
if fieldName == "RepeatedCountMin" || fieldName == "RepeatedCountMax" {
return false
}
}
return false
return true
}

func (p *plugin) regexName(ccTypeName string, fieldName string) string {
Expand Down