Skip to content

Commit

Permalink
Merge pull request #15 from askurydzin/master
Browse files Browse the repository at this point in the history
Add Boolean support;
Add message level synthetic query fields support;
Add disable flag for field selection and sorting;
Add value_type_url for proto referencing another proto message;
Add nested_fields to list exact fields (used with value_type_url);
Add depth level for sorting/filtering/field_selection as 2.
Do not distinguish between non-repeated "result" and repeated "results"
  • Loading branch information
askurydzin authored Aug 29, 2019
2 parents 3748bf8 + a3e2c33 commit 7d92164
Show file tree
Hide file tree
Showing 9 changed files with 604 additions and 228 deletions.
2 changes: 1 addition & 1 deletion Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ required = ["github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger"]

[[constraint]]
name = "github.com/gogo/protobuf"
version = "1.1.1"
version = "1.0.0"

[[constraint]]
name = "github.com/infobloxopen/atlas-app-toolkit"
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ vendor:

.PHONY: gentool
gentool:
docker build -t infoblox/atlas-gentool:test-query .
docker build -t infoblox/atlas-gentool:atlas-validate-query-dev .
docker image prune -f --filter label=stage=server-intermediate
58 changes: 43 additions & 15 deletions example/example.pb.atlas.query.validate.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion example/example.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ import "github.com/infobloxopen/protoc-gen-atlas-query-validate/options/query_va
import "github.com/infobloxopen/atlas-app-toolkit/query/collection_operators.proto";

message User {
option (atlas.query.message) = {
validate: {name: "custom_search", value: {value_type_url: ".example.Address", nested_fields: ["country"]}};
validate: {name: "custom_search_2", value: {value_type: STRING, filtering: {allow: MATCH, allow: EQ}}};
validate: {name: "list_of_addresses", value: {value_type_url: ".example.Address", enable_nested_fields: true, field_selection: {disable: false}}};
validate: {name: "user_friend", value: {value_type_url: ".example.User", enable_nested_fields: true}};
};

string first_name = 1 [(atlas.query.validate).filtering = {allow: MATCH, allow: EQ}];
float weight = 2 [(atlas.query.validate).filtering.deny = LE];
bool on_vacation = 3 [(atlas.query.validate).sorting.disable = true];
Expand All @@ -21,6 +28,7 @@ message User {
Address work_address = 12;
string company = 13 [(atlas.query.validate).filtering.deny = IEQ];
string nationality = 14 [(atlas.query.validate).filtering.deny = IN];
bool boolean_field = 15;
}

message CustomType {
Expand Down Expand Up @@ -58,4 +66,5 @@ service TestService {

rpc Read (ReadRequest) returns (ReadUserResponse) {
}
}
}

5 changes: 5 additions & 0 deletions example/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ func TestValidateFiltering(t *testing.T) {
{`nationality in ["American", "Сhinese"]`, true},
{`weight in [10, 20, 30]`, false},
{`comment in [10, 20, 30]`, true},
{`boolean_field in ["true", "1", "t", "True", "TRUE", "false", "0", "f", "False", "FALSE"]`, false},
{`boolean_field in ["tRuE"]`, true},
{`boolean_field=="True"`, false},
{`boolean_field=="Blah"`, true},
{`boolean_field:="True"`, true},
}

for _, test := range tests {
Expand Down
Loading

0 comments on commit 7d92164

Please sign in to comment.