22
33### Purpose
44
5- A [protobuf](https://developers.google.com/protocol-buffers/) compiler plugin
5+ A [protobuf](https://developers.google.com/protocol-buffers/) compiler plugin
66designed to simplify validation of [Atlas](https://github.com/infobloxopen/atlas-app-toolkit)
77[gRPC](https://grpc.io/) List [query](https://github.com/infobloxopen/atlas-app-toolkit/blob/master/query/collection_operators.proto) parameters
88by generating .pb.atlas.query.validate.go files with validation rules and functions.
@@ -58,7 +58,7 @@ The following table shows what is allowed for each *value_type*:
5858
5959| | STRING | NUMBER |
6060|-------------------------------------|--------|--------|
61- | **Filtering operators** | EQ, MATCH, GT, GE, LT, LE, IEQ, IN | EQ, GT, GE, LT, LE, IN |
61+ | **Filtering operators** | EQ, MATCH, GT, GE, LT, LE, IEQ, IN | EQ, GT, GE, LT, LE, IN |
6262| **Filtering value type/condition type** | String, null/StringCondition, NullCondition, StringArray(only for IN)| Number, null/NumberCondition, NullCondition, NumberArray(only for IN)|
6363
6464The next table shows how *value_type* is computed from a proto field type:
@@ -118,7 +118,7 @@ field-level options in order to support different validation rules for List meth
118118bool on_vacation = 3 [(atlas.query.validate).sorting.disable = true];
119119```
120120
121- * In order to customize the list of allowed filtering operators pass either a set of `(atlas.query.validate).filtering.allow` or
121+ * In order to customize the list of allowed filtering operators pass either a set of `(atlas.query.validate).filtering.allow` or
122122a set of `(atlas.query.validate).filtering.deny` options.
123123 - In case of using `(atlas.query.validate).filtering.allow` only specified filtering operators are allowed:
124124 ```golang
@@ -133,9 +133,17 @@ a set of `(atlas.query.validate).filtering.deny` options.
133133CustomType custom_type_string = 10 [(atlas.query.validate) = {value_type: STRING}];
134134```
135135* In order to enable filtering/sorting by nested fields set `(atlas.query.validate).enable_nested_fields` option to true
136- on the field of a message type.
136+ on the field of a message type or as message option.
137+ Note that this overrides any field level settings.
137138
138139```golang
140+ message User {
141+ option (atlas.query.message) = {
142+ enable_nested_fields: true;
143+ };
144+ ...
145+ }
146+
139147message User {
140148 Address home_address = 11 [(atlas.query.validate) = {enable_nested_fields: true}];
141149 Address work_address = 12;
@@ -147,6 +155,27 @@ message Address {
147155}
148156```
149157
158+ * You can also specify the maximum nesting depth using the `nested_field_depth_limit`
159+ option at the message level (the default is second level fields only).
160+
161+ ```golang
162+ message User {
163+ option (atlas.query.message) = {
164+ enable_nested_fields: true;
165+ nested_field_depth_limit: 3;
166+ };
167+ ...
168+ }
169+ ```
170+
171+ * Nesting and nested field depth can also be set for the entire code generation
172+ process as parameters on the protoc command
173+
174+ ```sh
175+ protoc ... \
176+ --atlas-query-validate_out="nested_field_depth_limit=3,enable_nested_fields=true:." \
177+ example/example.proto
178+ ```
150179
151180### Examples
152181
0 commit comments