Skip to content

Commit 7d92164

Browse files
authored
Merge pull request #15 from askurydzin/master
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"
2 parents 3748bf8 + a3e2c33 commit 7d92164

File tree

9 files changed

+604
-228
lines changed

9 files changed

+604
-228
lines changed

Gopkg.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ required = ["github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger"]
22

33
[[constraint]]
44
name = "github.com/gogo/protobuf"
5-
version = "1.1.1"
5+
version = "1.0.0"
66

77
[[constraint]]
88
name = "github.com/infobloxopen/atlas-app-toolkit"

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@ vendor:
2626

2727
.PHONY: gentool
2828
gentool:
29-
docker build -t infoblox/atlas-gentool:test-query .
29+
docker build -t infoblox/atlas-gentool:atlas-validate-query-dev .
3030
docker image prune -f --filter label=stage=server-intermediate

example/example.pb.atlas.query.validate.go

Lines changed: 43 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/example.proto

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ import "github.com/infobloxopen/protoc-gen-atlas-query-validate/options/query_va
77
import "github.com/infobloxopen/atlas-app-toolkit/query/collection_operators.proto";
88

99
message User {
10+
option (atlas.query.message) = {
11+
validate: {name: "custom_search", value: {value_type_url: ".example.Address", nested_fields: ["country"]}};
12+
validate: {name: "custom_search_2", value: {value_type: STRING, filtering: {allow: MATCH, allow: EQ}}};
13+
validate: {name: "list_of_addresses", value: {value_type_url: ".example.Address", enable_nested_fields: true, field_selection: {disable: false}}};
14+
validate: {name: "user_friend", value: {value_type_url: ".example.User", enable_nested_fields: true}};
15+
};
16+
1017
string first_name = 1 [(atlas.query.validate).filtering = {allow: MATCH, allow: EQ}];
1118
float weight = 2 [(atlas.query.validate).filtering.deny = LE];
1219
bool on_vacation = 3 [(atlas.query.validate).sorting.disable = true];
@@ -21,6 +28,7 @@ message User {
2128
Address work_address = 12;
2229
string company = 13 [(atlas.query.validate).filtering.deny = IEQ];
2330
string nationality = 14 [(atlas.query.validate).filtering.deny = IN];
31+
bool boolean_field = 15;
2432
}
2533

2634
message CustomType {
@@ -58,4 +66,5 @@ service TestService {
5866

5967
rpc Read (ReadRequest) returns (ReadUserResponse) {
6068
}
61-
}
69+
}
70+

example/example_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ func TestValidateFiltering(t *testing.T) {
3838
{`nationality in ["American", "Сhinese"]`, true},
3939
{`weight in [10, 20, 30]`, false},
4040
{`comment in [10, 20, 30]`, true},
41+
{`boolean_field in ["true", "1", "t", "True", "TRUE", "false", "0", "f", "False", "FALSE"]`, false},
42+
{`boolean_field in ["tRuE"]`, true},
43+
{`boolean_field=="True"`, false},
44+
{`boolean_field=="Blah"`, true},
45+
{`boolean_field:="True"`, true},
4146
}
4247

4348
for _, test := range tests {

0 commit comments

Comments
 (0)