-
Notifications
You must be signed in to change notification settings - Fork 582
/
enums.proto
71 lines (56 loc) · 2.9 KB
/
enums.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
syntax = "proto3";
package tests.harness.cases;
option go_package = "github.com/envoyproxy/protoc-gen-validate/tests/harness/cases/go;cases";
import "validate/validate.proto";
import "tests/harness/cases/other_package/embed.proto";
import "tests/harness/cases/yet_another_package/embed.proto";
import "tests/harness/cases/sort/sort.proto";
enum TestEnum {
ZERO = 0;
ONE = 1;
TWO = 2;
}
enum TestEnumAlias {
option allow_alias = true;
A = 0;
B = 1;
C = 2;
ALPHA = 0;
BETA = 1;
GAMMA = 2;
}
message EnumNone { TestEnum val = 1; }
message EnumConst { TestEnum val = 1 [(validate.rules).enum.const = 2];}
message EnumAliasConst { TestEnumAlias val = 1 [(validate.rules).enum.const = 2];}
message EnumDefined { TestEnum val = 1 [(validate.rules).enum.defined_only = true];}
message EnumAliasDefined { TestEnumAlias val = 1 [(validate.rules).enum.defined_only = true];}
message EnumIn { TestEnum val = 1 [(validate.rules).enum = { in: [0, 2]}];}
message EnumAliasIn { TestEnumAlias val = 1 [(validate.rules).enum = { in: [0, 2]}];}
message EnumNotIn { TestEnum val = 1 [(validate.rules).enum = { not_in: [1]}];}
message EnumAliasNotIn { TestEnumAlias val = 1 [(validate.rules).enum = { not_in: [1]}]; }
message EnumExternal { other_package.Embed.Enumerated val = 1 [(validate.rules).enum.defined_only = true]; }
message EnumExternal2 { other_package.Embed.DoubleEmbed.DoubleEnumerated val = 1 [(validate.rules).enum.defined_only = true]; }
message EnumExternal3 {
other_package.Embed.FooNumber foo = 1 [(validate.rules).enum = { in: [0, 2] }];
yet_another_package.Embed.BarNumber bar = 2 [(validate.rules).enum = { not_in: [1] }];
}
message EnumExternal4 {
sort.Direction sort_direction = 1 [(validate.rules).enum.const = 1];
}
message RepeatedEnumDefined { repeated TestEnum val = 1 [(validate.rules).repeated.items.enum.defined_only = true]; }
message RepeatedExternalEnumDefined { repeated other_package.Embed.Enumerated val = 1 [(validate.rules).repeated.items.enum.defined_only = true]; }
message RepeatedYetAnotherExternalEnumDefined { repeated yet_another_package.Embed.Enumerated val = 1 [(validate.rules).repeated.items.enum.defined_only = true]; }
message RepeatedEnumExternal {
repeated other_package.Embed.FooNumber foo = 1 [(validate.rules).repeated.items.enum = { in: [0, 2] }];
repeated yet_another_package.Embed.BarNumber bar = 2 [(validate.rules).repeated.items.enum = { not_in: [1] }];
}
message MapEnumDefined { map<string, TestEnum> val = 1 [(validate.rules).map.values.enum.defined_only = true]; }
message MapExternalEnumDefined { map<string, other_package.Embed.Enumerated> val = 1 [(validate.rules).map.values.enum.defined_only = true]; }
message EnumInsideOneOf {
oneof foo {
TestEnum val = 1 [(validate.rules).enum.defined_only = true];
}
oneof bar {
TestEnum val2 = 2 [(validate.rules).enum = {defined_only : true not_in : 0}];
}
}