-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathvalidations.proto
More file actions
98 lines (83 loc) · 2.33 KB
/
validations.proto
File metadata and controls
98 lines (83 loc) · 2.33 KB
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
// Copyright 2023-2025 Buf Technologies, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
syntax = "proto3";
package tests.example.v1;
import "buf/validate/validate.proto";
import "google/protobuf/timestamp.proto";
message MultipleValidations {
string title = 1 [(buf.validate.field).string.prefix = "foo"];
string name = 2 [(buf.validate.field).string.min_len = 5];
}
message DoubleFinite {
double val = 1 [(buf.validate.field).double.finite = true];
}
message SFixed64ExLTGT {
sfixed64 val = 1 [(buf.validate.field).sfixed64 = {
lt: 0
gt: 10
}];
}
message TestOneofMsg {
bool val = 1 [(buf.validate.field).bool.const = true];
}
message Oneof {
oneof o {
string x = 1 [(buf.validate.field).string.prefix = "foo"];
int32 y = 2 [(buf.validate.field).int32.gt = 0];
TestOneofMsg z = 3;
}
}
message ProtovalidateOneof {
string a = 1;
string b = 2;
bool unrelated = 3;
option (buf.validate.message).oneof = {
fields: ["a", "b"]
};
}
message ProtovalidateOneofRequired {
string a = 1;
string b = 2;
bool unrelated = 3;
option (buf.validate.message).oneof = {
fields: ["a", "b"]
required: true
};
}
message ProtovalidateOneofUnknownFieldName {
string a = 1;
string b = 2;
bool unrelated = 3;
option (buf.validate.message).oneof = {
fields: ["a", "b", "xxx"]
};
}
message TimestampGTNow {
google.protobuf.Timestamp val = 1 [(buf.validate.field).timestamp.gt_now = true];
}
message MapMinMax {
map<string, bool> val = 1 [(buf.validate.field).map = {
min_pairs: 2
max_pairs: 4
}];
}
message MapKeys {
map<sint64, string> val = 1 [(buf.validate.field).map.keys.sint64.lt = 0];
}
message Embed {
int64 val = 1 [(buf.validate.field).int64.gt = 0];
}
message RepeatedEmbedSkip {
repeated Embed val = 1 [(buf.validate.field).repeated.items.ignore = IGNORE_ALWAYS];
}