forked from bufbuild/protoc-gen-validate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
maps.proto
41 lines (31 loc) · 1.85 KB
/
maps.proto
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
syntax = "proto3";
package tests.harness.cases;
option go_package = "github.com/envoyproxy/protoc-gen-validate/tests/harness/cases/go;cases";
import "validate/validate.proto";
message MapNone { map<uint32,bool> val = 1; }
message MapMin { map<int32,float> val = 1 [(validate.rules).map.min_pairs = 2]; }
message MapMax { map<int64,double> val = 1 [(validate.rules).map.max_pairs = 3]; }
message MapMinMax { map<string,bool> val = 1 [(validate.rules).map = {min_pairs: 2, max_pairs: 4}]; }
message MapExact { map<uint64,string> val = 1 [(validate.rules).map = {min_pairs: 3, max_pairs: 3}]; }
message MapNoSparse {
map<uint32, Msg> val = 1 [(validate.rules).map.no_sparse = true];
message Msg {}
}
message MapKeys { map<sint64, string> val = 1 [(validate.rules).map.keys.sint64.lt = 0]; }
message MapValues { map<string, string> val = 1 [(validate.rules).map.values.string.min_len = 3]; }
message MapKeysPattern { map<string, string> val = 1 [(validate.rules).map.keys.string.pattern = "(?i)^[a-z0-9]+$"]; }
message MapValuesPattern { map<string, string> val = 1 [(validate.rules).map.values.string.pattern = "(?i)^[a-z0-9]+$"]; }
message MapRecursive {
map<uint32, Msg> val = 1;
message Msg {
string val = 1 [(validate.rules).string.min_len = 3];
}
}
message MapExactIgnore { map<uint64,string> val = 1 [(validate.rules).map = {min_pairs: 3, max_pairs: 3, ignore_empty: true}]; }
message MultipleMaps {
map <uint32, string> first = 1 [(validate.rules).map.keys.uint32.gt = 0];
map <int32, bool> second = 2 [(validate.rules).map.keys.int32.lt = 0];
map <int32, bool> third = 3 [(validate.rules).map.keys.int32.gt = 0];
}
message MapKeysIn {map<string, string> val = 1 [(validate.rules).map.keys.string = {in: ["foo", "bar"]}]; }
message MapKeysNotIn {map<string, string> val = 1 [(validate.rules).map.keys.string = {not_in: ["foo", "bar"]}]; }