@nebius/js-sdk 0.1.36 → 0.1.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/api/buf/validate/index.d.ts +482 -326
- package/dist/cjs/api/buf/validate/index.d.ts.map +1 -1
- package/dist/cjs/api/buf/validate/index.js +647 -386
- package/dist/cjs/api/buf/validate/index.js.map +1 -1
- package/dist/cjs/api/nebius/ai/v1/index.d.ts +12 -0
- package/dist/cjs/api/nebius/ai/v1/index.d.ts.map +1 -1
- package/dist/cjs/api/nebius/ai/v1/index.js +46 -0
- package/dist/cjs/api/nebius/ai/v1/index.js.map +1 -1
- package/dist/cjs/api/nebius/audit/v2/index.d.ts +5 -0
- package/dist/cjs/api/nebius/audit/v2/index.d.ts.map +1 -1
- package/dist/cjs/api/nebius/audit/v2/index.js +23 -0
- package/dist/cjs/api/nebius/audit/v2/index.js.map +1 -1
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/api/buf/validate/index.d.ts +482 -326
- package/dist/esm/api/buf/validate/index.d.ts.map +1 -1
- package/dist/esm/api/nebius/ai/v1/index.d.ts +12 -0
- package/dist/esm/api/nebius/ai/v1/index.d.ts.map +1 -1
- package/dist/esm/api/nebius/audit/v2/index.d.ts +5 -0
- package/dist/esm/api/nebius/audit/v2/index.d.ts.map +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/package.json +1 -1
|
@@ -3,192 +3,120 @@ import type { Dayjs, Duration, MessageFns, EnumInstance, EnumClass } from "../..
|
|
|
3
3
|
import { customJson } from "../../../runtime/util/logging";
|
|
4
4
|
import { FieldDescriptorProto_Type } from "../../google/protobuf";
|
|
5
5
|
/**
|
|
6
|
-
* Specifies how
|
|
7
|
-
*
|
|
6
|
+
* Specifies how `FieldRules.ignore` behaves, depending on the field's value, and
|
|
7
|
+
* whether the field tracks presence.
|
|
8
8
|
*
|
|
9
9
|
*/
|
|
10
|
-
export type Ignore = EnumInstance<"UNRECOGNIZED" | "IGNORE_UNSPECIFIED" | "
|
|
10
|
+
export type Ignore = EnumInstance<"UNRECOGNIZED" | "IGNORE_UNSPECIFIED" | "IGNORE_IF_ZERO_VALUE" | "IGNORE_ALWAYS">;
|
|
11
11
|
interface IgnoreValueMembers {
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* Ignore rules if the field tracks presence and is unset. This is the default
|
|
14
|
+
* behavior.
|
|
15
|
+
*
|
|
16
|
+
* In proto3, only message fields, members of a Protobuf `oneof`, and fields
|
|
17
|
+
* with the `optional` label track presence. Consequently, the following fields
|
|
18
|
+
* are always validated, whether a value is set or not:
|
|
14
19
|
*
|
|
15
20
|
* ```proto
|
|
16
21
|
* syntax="proto3";
|
|
17
22
|
*
|
|
18
|
-
* message
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* (buf.validate.field).string.uri = true
|
|
23
|
+
* message RulesApply {
|
|
24
|
+
* string email = 1 [
|
|
25
|
+
* (buf.validate.field).string.email = true
|
|
22
26
|
* ];
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* // set to the empty string.
|
|
26
|
-
* optional string bar = 2 [
|
|
27
|
-
* (buf.validate.field).string.uri = true
|
|
27
|
+
* int32 age = 2 [
|
|
28
|
+
* (buf.validate.field).int32.gt = 0
|
|
28
29
|
* ];
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* repeated string baz = 3 [
|
|
32
|
-
* (buf.validate.field).repeated.min_items = 3
|
|
33
|
-
* ];
|
|
34
|
-
*
|
|
35
|
-
* // The custom CEL rule applies only if the field is set, including if
|
|
36
|
-
* // it's the "zero" value of that message.
|
|
37
|
-
* SomeMessage quux = 4 [
|
|
38
|
-
* (buf.validate.field).cel = {/* ... * /}
|
|
30
|
+
* repeated string labels = 3 [
|
|
31
|
+
* (buf.validate.field).repeated.min_items = 1
|
|
39
32
|
* ];
|
|
40
33
|
* }
|
|
41
34
|
* ```
|
|
42
35
|
*
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Validation is skipped if the field is unpopulated. This rule is redundant
|
|
47
|
-
* if the field is already nullable. This value is equivalent behavior to the
|
|
48
|
-
* deprecated ignore_empty rule.
|
|
36
|
+
* In contrast, the following fields track presence, and are only validated if
|
|
37
|
+
* a value is set:
|
|
49
38
|
*
|
|
50
39
|
* ```proto
|
|
51
|
-
* syntax="proto3
|
|
52
|
-
*
|
|
53
|
-
* message Request {
|
|
54
|
-
* // The uri rule applies only if the value is not the empty string.
|
|
55
|
-
* string foo = 1 [
|
|
56
|
-
* (buf.validate.field).string.uri = true,
|
|
57
|
-
* (buf.validate.field).ignore = IGNORE_IF_UNPOPULATED
|
|
58
|
-
* ];
|
|
59
|
-
*
|
|
60
|
-
* // IGNORE_IF_UNPOPULATED is equivalent to IGNORE_UNSPECIFIED in this
|
|
61
|
-
* // case: the uri rule only applies if the field is set, including if
|
|
62
|
-
* // it's set to the empty string.
|
|
63
|
-
* optional string bar = 2 [
|
|
64
|
-
* (buf.validate.field).string.uri = true,
|
|
65
|
-
* (buf.validate.field).ignore = IGNORE_IF_UNPOPULATED
|
|
66
|
-
* ];
|
|
40
|
+
* syntax="proto3";
|
|
67
41
|
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
* (buf.validate.field).
|
|
71
|
-
* (buf.validate.field).ignore = IGNORE_IF_UNPOPULATED
|
|
42
|
+
* message RulesApplyIfSet {
|
|
43
|
+
* optional string email = 1 [
|
|
44
|
+
* (buf.validate.field).string.email = true
|
|
72
45
|
* ];
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
46
|
+
* oneof ref {
|
|
47
|
+
* string reference = 2 [
|
|
48
|
+
* (buf.validate.field).string.uuid = true
|
|
49
|
+
* ];
|
|
50
|
+
* string name = 3 [
|
|
51
|
+
* (buf.validate.field).string.min_len = 4
|
|
52
|
+
* ];
|
|
53
|
+
* }
|
|
54
|
+
* SomeMessage msg = 4 [
|
|
55
|
+
* (buf.validate.field).cel = {/* ... * /}
|
|
80
56
|
* ];
|
|
81
57
|
* }
|
|
82
58
|
* ```
|
|
83
59
|
*
|
|
84
|
-
|
|
85
|
-
readonly IGNORE_IF_UNPOPULATED: EnumInstance<"UNRECOGNIZED" | "IGNORE_UNSPECIFIED" | "IGNORE_IF_UNPOPULATED" | "IGNORE_IF_DEFAULT_VALUE" | "IGNORE_ALWAYS" | "IGNORE_EMPTY" | "IGNORE_DEFAULT">;
|
|
86
|
-
/**
|
|
87
|
-
* Validation is skipped if the field is unpopulated or if it is a nullable
|
|
88
|
-
* field populated with its default value. This is typically the zero or
|
|
89
|
-
* empty value, but proto2 scalars support custom defaults. For messages, the
|
|
90
|
-
* default is a non-null message with all its fields unpopulated.
|
|
60
|
+
* To ensure that such a field is set, add the `required` rule.
|
|
91
61
|
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
62
|
+
* To learn which fields track presence, see the
|
|
63
|
+
* [Field Presence cheat sheet](https://protobuf.dev/programming-guides/field_presence/#cheat).
|
|
94
64
|
*
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
*
|
|
99
|
-
* string foo = 1 [
|
|
100
|
-
* (buf.validate.field).string.uri = true,
|
|
101
|
-
* (buf.validate.field).ignore = IGNORE_IF_DEFAULT_VALUE
|
|
102
|
-
* ];
|
|
103
|
-
*
|
|
104
|
-
* // The uri rule only applies if the field is set to a value other than
|
|
105
|
-
* // the empty string.
|
|
106
|
-
* optional string bar = 2 [
|
|
107
|
-
* (buf.validate.field).string.uri = true,
|
|
108
|
-
* (buf.validate.field).ignore = IGNORE_IF_DEFAULT_VALUE
|
|
109
|
-
* ];
|
|
110
|
-
*
|
|
111
|
-
* // IGNORE_IF_DEFAULT_VALUE is equivalent to IGNORE_IF_UNPOPULATED in
|
|
112
|
-
* // this case; the min_items rule only applies if the list has at least
|
|
113
|
-
* // one item.
|
|
114
|
-
* repeated string baz = 3 [
|
|
115
|
-
* (buf.validate.field).repeated.min_items = 3,
|
|
116
|
-
* (buf.validate.field).ignore = IGNORE_IF_DEFAULT_VALUE
|
|
117
|
-
* ];
|
|
118
|
-
*
|
|
119
|
-
* // The custom CEL rule only applies if the field is set to a value other
|
|
120
|
-
* // than an empty message (i.e., fields are unpopulated).
|
|
121
|
-
* SomeMessage quux = 4 [
|
|
122
|
-
* (buf.validate.field).cel = {/* ... * /},
|
|
123
|
-
* (buf.validate.field).ignore = IGNORE_IF_DEFAULT_VALUE
|
|
124
|
-
* ];
|
|
125
|
-
* }
|
|
126
|
-
* ```
|
|
65
|
+
*/
|
|
66
|
+
readonly IGNORE_UNSPECIFIED: EnumInstance<"UNRECOGNIZED" | "IGNORE_UNSPECIFIED" | "IGNORE_IF_ZERO_VALUE" | "IGNORE_ALWAYS">;
|
|
67
|
+
/**
|
|
68
|
+
* Ignore rules if the field is unset, or set to the zero value.
|
|
127
69
|
*
|
|
128
|
-
*
|
|
70
|
+
* The zero value depends on the field type:
|
|
71
|
+
* - For strings, the zero value is the empty string.
|
|
72
|
+
* - For bytes, the zero value is empty bytes.
|
|
73
|
+
* - For bool, the zero value is false.
|
|
74
|
+
* - For numeric types, the zero value is zero.
|
|
75
|
+
* - For enums, the zero value is the first defined enum value.
|
|
76
|
+
* - For repeated fields, the zero is an empty list.
|
|
77
|
+
* - For map fields, the zero is an empty map.
|
|
78
|
+
* - For message fields, absence of the message (typically a null-value) is considered zero value.
|
|
129
79
|
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
* message Request {
|
|
134
|
-
* // The gt rule only applies if the field is set and it's value is not
|
|
135
|
-
* the default (i.e., not -42). The rule even applies if the field is set
|
|
136
|
-
* to zero since the default value differs.
|
|
137
|
-
* optional int32 value = 1 [
|
|
138
|
-
* default = -42,
|
|
139
|
-
* (buf.validate.field).int32.gt = 0,
|
|
140
|
-
* (buf.validate.field).ignore = IGNORE_IF_DEFAULT_VALUE
|
|
141
|
-
* ];
|
|
142
|
-
* }
|
|
80
|
+
* For fields that track presence (e.g. adding the `optional` label in proto3),
|
|
81
|
+
* this a no-op and behavior is the same as the default `IGNORE_UNSPECIFIED`.
|
|
143
82
|
*
|
|
144
83
|
*/
|
|
145
|
-
readonly
|
|
84
|
+
readonly IGNORE_IF_ZERO_VALUE: EnumInstance<"UNRECOGNIZED" | "IGNORE_UNSPECIFIED" | "IGNORE_IF_ZERO_VALUE" | "IGNORE_ALWAYS">;
|
|
146
85
|
/**
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
* temporarily
|
|
86
|
+
* Always ignore rules, including the `required` rule.
|
|
87
|
+
*
|
|
88
|
+
* This is useful for ignoring the rules of a referenced message, or to
|
|
89
|
+
* temporarily ignore rules during development.
|
|
151
90
|
*
|
|
152
91
|
* ```proto
|
|
153
92
|
* message MyMessage {
|
|
154
|
-
* // The field's rules will always be ignored, including any
|
|
93
|
+
* // The field's rules will always be ignored, including any validations
|
|
155
94
|
* // on value's fields.
|
|
156
95
|
* MyOtherMessage value = 1 [
|
|
157
|
-
* (buf.validate.field).ignore = IGNORE_ALWAYS
|
|
96
|
+
* (buf.validate.field).ignore = IGNORE_ALWAYS
|
|
97
|
+
* ];
|
|
158
98
|
* }
|
|
159
99
|
* ```
|
|
160
100
|
*
|
|
161
101
|
*/
|
|
162
|
-
readonly IGNORE_ALWAYS: EnumInstance<"UNRECOGNIZED" | "IGNORE_UNSPECIFIED" | "
|
|
163
|
-
/**
|
|
164
|
-
* Deprecated: Use IGNORE_IF_UNPOPULATED instead. TODO: Remove this value pre-v1.
|
|
165
|
-
*
|
|
166
|
-
* @deprecated Deprecated.
|
|
167
|
-
*/
|
|
168
|
-
readonly IGNORE_EMPTY: EnumInstance<"UNRECOGNIZED" | "IGNORE_UNSPECIFIED" | "IGNORE_IF_UNPOPULATED" | "IGNORE_IF_DEFAULT_VALUE" | "IGNORE_ALWAYS" | "IGNORE_EMPTY" | "IGNORE_DEFAULT">;
|
|
169
|
-
/**
|
|
170
|
-
* Deprecated: Use IGNORE_IF_DEFAULT_VALUE. TODO: Remove this value pre-v1.
|
|
171
|
-
*
|
|
172
|
-
* @deprecated Deprecated.
|
|
173
|
-
*/
|
|
174
|
-
readonly IGNORE_DEFAULT: EnumInstance<"UNRECOGNIZED" | "IGNORE_UNSPECIFIED" | "IGNORE_IF_UNPOPULATED" | "IGNORE_IF_DEFAULT_VALUE" | "IGNORE_ALWAYS" | "IGNORE_EMPTY" | "IGNORE_DEFAULT">;
|
|
102
|
+
readonly IGNORE_ALWAYS: EnumInstance<"UNRECOGNIZED" | "IGNORE_UNSPECIFIED" | "IGNORE_IF_ZERO_VALUE" | "IGNORE_ALWAYS">;
|
|
175
103
|
}
|
|
176
|
-
export type IgnoreClass = EnumClass<"UNRECOGNIZED" | "IGNORE_UNSPECIFIED" | "
|
|
104
|
+
export type IgnoreClass = EnumClass<"UNRECOGNIZED" | "IGNORE_UNSPECIFIED" | "IGNORE_IF_ZERO_VALUE" | "IGNORE_ALWAYS"> & IgnoreValueMembers;
|
|
177
105
|
export declare const Ignore: IgnoreClass;
|
|
178
106
|
/**
|
|
179
|
-
*
|
|
107
|
+
* KnownRegex contains some well-known patterns.
|
|
180
108
|
*
|
|
181
109
|
*/
|
|
182
110
|
export type KnownRegex = EnumInstance<"UNRECOGNIZED" | "KNOWN_REGEX_UNSPECIFIED" | "KNOWN_REGEX_HTTP_HEADER_NAME" | "KNOWN_REGEX_HTTP_HEADER_VALUE">;
|
|
183
111
|
interface KnownRegexValueMembers {
|
|
184
112
|
readonly KNOWN_REGEX_UNSPECIFIED: EnumInstance<"UNRECOGNIZED" | "KNOWN_REGEX_UNSPECIFIED" | "KNOWN_REGEX_HTTP_HEADER_NAME" | "KNOWN_REGEX_HTTP_HEADER_VALUE">;
|
|
185
113
|
/**
|
|
186
|
-
* HTTP header name as defined by [RFC 7230](https://
|
|
114
|
+
* HTTP header name as defined by [RFC 7230](https://datatracker.ietf.org/doc/html/rfc7230#section-3.2).
|
|
187
115
|
*
|
|
188
116
|
*/
|
|
189
117
|
readonly KNOWN_REGEX_HTTP_HEADER_NAME: EnumInstance<"UNRECOGNIZED" | "KNOWN_REGEX_UNSPECIFIED" | "KNOWN_REGEX_HTTP_HEADER_NAME" | "KNOWN_REGEX_HTTP_HEADER_VALUE">;
|
|
190
118
|
/**
|
|
191
|
-
* HTTP header value as defined by [RFC 7230](https://
|
|
119
|
+
* HTTP header value as defined by [RFC 7230](https://datatracker.ietf.org/doc/html/rfc7230#section-3.2.4).
|
|
192
120
|
*
|
|
193
121
|
*/
|
|
194
122
|
readonly KNOWN_REGEX_HTTP_HEADER_VALUE: EnumInstance<"UNRECOGNIZED" | "KNOWN_REGEX_UNSPECIFIED" | "KNOWN_REGEX_HTTP_HEADER_NAME" | "KNOWN_REGEX_HTTP_HEADER_VALUE">;
|
|
@@ -196,10 +124,10 @@ interface KnownRegexValueMembers {
|
|
|
196
124
|
export type KnownRegexClass = EnumClass<"UNRECOGNIZED" | "KNOWN_REGEX_UNSPECIFIED" | "KNOWN_REGEX_HTTP_HEADER_NAME" | "KNOWN_REGEX_HTTP_HEADER_VALUE"> & KnownRegexValueMembers;
|
|
197
125
|
export declare const KnownRegex: KnownRegexClass;
|
|
198
126
|
/**
|
|
199
|
-
* `
|
|
200
|
-
* Language (CEL) syntax. Each
|
|
127
|
+
* `Rule` represents a validation rule written in the Common Expression
|
|
128
|
+
* Language (CEL) syntax. Each Rule includes a unique identifier, an
|
|
201
129
|
* optional error message, and the CEL expression to evaluate. For more
|
|
202
|
-
* information
|
|
130
|
+
* information, [see our documentation](https://buf.build/docs/protovalidate/schemas/custom-rules/).
|
|
203
131
|
*
|
|
204
132
|
* ```proto
|
|
205
133
|
* message Foo {
|
|
@@ -213,19 +141,19 @@ export declare const KnownRegex: KnownRegexClass;
|
|
|
213
141
|
* ```
|
|
214
142
|
*
|
|
215
143
|
*/
|
|
216
|
-
export interface
|
|
217
|
-
$type: "buf.validate.
|
|
144
|
+
export interface Rule {
|
|
145
|
+
$type: "buf.validate.Rule";
|
|
218
146
|
[unknownFieldsSymbol]?: Uint8Array | undefined;
|
|
219
147
|
[customJson]?: () => unknown;
|
|
220
148
|
/**
|
|
221
|
-
* `id` is a string that serves as a machine-readable name for this
|
|
149
|
+
* `id` is a string that serves as a machine-readable name for this Rule.
|
|
222
150
|
* It should be unique within its scope, which could be either a message or a field.
|
|
223
151
|
*
|
|
224
152
|
*/
|
|
225
153
|
id?: string | undefined;
|
|
226
154
|
/**
|
|
227
155
|
* `message` is an optional field that provides a human-readable error message
|
|
228
|
-
* for this
|
|
156
|
+
* for this Rule when the CEL expression evaluates to false. If a
|
|
229
157
|
* non-empty message is provided, any strings resulting from the CEL
|
|
230
158
|
* expression evaluation are ignored.
|
|
231
159
|
*
|
|
@@ -240,33 +168,42 @@ export interface Constraint {
|
|
|
240
168
|
*/
|
|
241
169
|
expression?: string | undefined;
|
|
242
170
|
}
|
|
243
|
-
export declare const
|
|
171
|
+
export declare const Rule: MessageFns<Rule, "buf.validate.Rule">;
|
|
244
172
|
/**
|
|
245
|
-
*
|
|
246
|
-
* It includes disabling options and a list of
|
|
173
|
+
* MessageRules represents validation rules that are applied to the entire message.
|
|
174
|
+
* It includes disabling options and a list of Rule messages representing Common Expression Language (CEL) validation rules.
|
|
247
175
|
*
|
|
248
176
|
*/
|
|
249
|
-
export interface
|
|
250
|
-
$type: "buf.validate.
|
|
177
|
+
export interface MessageRules {
|
|
178
|
+
$type: "buf.validate.MessageRules";
|
|
251
179
|
[unknownFieldsSymbol]?: Uint8Array | undefined;
|
|
252
180
|
[customJson]?: () => unknown;
|
|
253
181
|
/**
|
|
254
|
-
* `
|
|
255
|
-
*
|
|
182
|
+
* `cel_expression` is a repeated field CEL expressions. Each expression specifies a validation
|
|
183
|
+
* rule to be applied to this message. These rules are written in Common Expression Language (CEL) syntax.
|
|
184
|
+
*
|
|
185
|
+
* This is a simplified form of the `cel` Rule field, where only `expression` is set. This allows for
|
|
186
|
+
* simpler syntax when defining CEL Rules where `id` and `message` derived from the `expression`. `id` will
|
|
187
|
+
* be same as the `expression`.
|
|
188
|
+
*
|
|
189
|
+
* For more information, [see our documentation](https://buf.build/docs/protovalidate/schemas/custom-rules/).
|
|
256
190
|
*
|
|
257
191
|
* ```proto
|
|
258
192
|
* message MyMessage {
|
|
259
|
-
* //
|
|
260
|
-
* option (buf.validate.message).
|
|
193
|
+
* // The field `foo` must be greater than 42.
|
|
194
|
+
* option (buf.validate.message).cel_expression = "this.foo > 42";
|
|
195
|
+
* // The field `foo` must be less than 84.
|
|
196
|
+
* option (buf.validate.message).cel_expression = "this.foo < 84";
|
|
197
|
+
* optional int32 foo = 1;
|
|
261
198
|
* }
|
|
262
199
|
* ```
|
|
263
200
|
*
|
|
264
201
|
*/
|
|
265
|
-
|
|
202
|
+
celExpression: string[];
|
|
266
203
|
/**
|
|
267
|
-
* `cel` is a repeated field of type
|
|
268
|
-
* These
|
|
269
|
-
*
|
|
204
|
+
* `cel` is a repeated field of type Rule. Each Rule specifies a validation rule to be applied to this message.
|
|
205
|
+
* These rules are written in Common Expression Language (CEL) syntax. For more information,
|
|
206
|
+
* [see our documentation](https://buf.build/docs/protovalidate/schemas/custom-rules/).
|
|
270
207
|
*
|
|
271
208
|
*
|
|
272
209
|
* ```proto
|
|
@@ -282,22 +219,77 @@ export interface MessageConstraints {
|
|
|
282
219
|
* ```
|
|
283
220
|
*
|
|
284
221
|
*/
|
|
285
|
-
cel:
|
|
222
|
+
cel: Rule[];
|
|
223
|
+
/**
|
|
224
|
+
* `oneof` is a repeated field of type MessageOneofRule that specifies a list of fields
|
|
225
|
+
* of which at most one can be present. If `required` is also specified, then exactly one
|
|
226
|
+
* of the specified fields _must_ be present.
|
|
227
|
+
*
|
|
228
|
+
* This will enforce oneof-like constraints with a few features not provided by
|
|
229
|
+
* actual Protobuf oneof declarations:
|
|
230
|
+
* 1. Repeated and map fields are allowed in this validation. In a Protobuf oneof,
|
|
231
|
+
* only scalar fields are allowed.
|
|
232
|
+
* 2. Fields with implicit presence are allowed. In a Protobuf oneof, all member
|
|
233
|
+
* fields have explicit presence. This means that, for the purpose of determining
|
|
234
|
+
* how many fields are set, explicitly setting such a field to its zero value is
|
|
235
|
+
* effectively the same as not setting it at all.
|
|
236
|
+
* 3. This will always generate validation errors for a message unmarshalled from
|
|
237
|
+
* serialized data that sets more than one field. With a Protobuf oneof, when
|
|
238
|
+
* multiple fields are present in the serialized form, earlier values are usually
|
|
239
|
+
* silently ignored when unmarshalling, with only the last field being set when
|
|
240
|
+
* unmarshalling completes.
|
|
241
|
+
*
|
|
242
|
+
* Note that adding a field to a `oneof` will also set the IGNORE_IF_ZERO_VALUE on the fields. This means
|
|
243
|
+
* only the field that is set will be validated and the unset fields are not validated according to the field rules.
|
|
244
|
+
* This behavior can be overridden by setting `ignore` against a field.
|
|
245
|
+
*
|
|
246
|
+
* ```proto
|
|
247
|
+
* message MyMessage {
|
|
248
|
+
* // Only one of `field1` or `field2` _can_ be present in this message.
|
|
249
|
+
* option (buf.validate.message).oneof = { fields: ["field1", "field2"] };
|
|
250
|
+
* // Exactly one of `field3` or `field4` _must_ be present in this message.
|
|
251
|
+
* option (buf.validate.message).oneof = { fields: ["field3", "field4"], required: true };
|
|
252
|
+
* string field1 = 1;
|
|
253
|
+
* bytes field2 = 2;
|
|
254
|
+
* bool field3 = 3;
|
|
255
|
+
* int32 field4 = 4;
|
|
256
|
+
* }
|
|
257
|
+
* ```
|
|
258
|
+
*
|
|
259
|
+
*/
|
|
260
|
+
oneof: MessageOneofRule[];
|
|
286
261
|
}
|
|
287
|
-
export declare const
|
|
262
|
+
export declare const MessageRules: MessageFns<MessageRules, "buf.validate.MessageRules">;
|
|
263
|
+
export interface MessageOneofRule {
|
|
264
|
+
$type: "buf.validate.MessageOneofRule";
|
|
265
|
+
[unknownFieldsSymbol]?: Uint8Array | undefined;
|
|
266
|
+
[customJson]?: () => unknown;
|
|
267
|
+
/**
|
|
268
|
+
* A list of field names to include in the oneof. All field names must be
|
|
269
|
+
* defined in the message. At least one field must be specified, and
|
|
270
|
+
* duplicates are not permitted.
|
|
271
|
+
*
|
|
272
|
+
*/
|
|
273
|
+
fields: string[];
|
|
274
|
+
/**
|
|
275
|
+
* If true, one of the fields specified _must_ be set.
|
|
276
|
+
*
|
|
277
|
+
*/
|
|
278
|
+
required?: boolean | undefined;
|
|
279
|
+
}
|
|
280
|
+
export declare const MessageOneofRule: MessageFns<MessageOneofRule, "buf.validate.MessageOneofRule">;
|
|
288
281
|
/**
|
|
289
|
-
* The `
|
|
282
|
+
* The `OneofRules` message type enables you to manage rules for
|
|
290
283
|
* oneof fields in your protobuf messages.
|
|
291
284
|
*
|
|
292
285
|
*/
|
|
293
|
-
export interface
|
|
294
|
-
$type: "buf.validate.
|
|
286
|
+
export interface OneofRules {
|
|
287
|
+
$type: "buf.validate.OneofRules";
|
|
295
288
|
[unknownFieldsSymbol]?: Uint8Array | undefined;
|
|
296
289
|
[customJson]?: () => unknown;
|
|
297
290
|
/**
|
|
298
|
-
* If `required` is true, exactly one field of the oneof must be
|
|
299
|
-
* validation error is returned if no fields in the oneof are
|
|
300
|
-
* field itself may still be a default value; further constraints
|
|
291
|
+
* If `required` is true, exactly one field of the oneof must be set. A
|
|
292
|
+
* validation error is returned if no fields in the oneof are set. Further rules
|
|
301
293
|
* should be placed on the fields themselves to ensure they are valid values,
|
|
302
294
|
* such as `min_len` or `gt`.
|
|
303
295
|
*
|
|
@@ -316,20 +308,39 @@ export interface OneofConstraints {
|
|
|
316
308
|
*/
|
|
317
309
|
required?: boolean | undefined;
|
|
318
310
|
}
|
|
319
|
-
export declare const
|
|
311
|
+
export declare const OneofRules: MessageFns<OneofRules, "buf.validate.OneofRules">;
|
|
320
312
|
/**
|
|
321
|
-
*
|
|
313
|
+
* FieldRules encapsulates the rules for each type of field. Depending on
|
|
322
314
|
* the field, the correct set should be used to ensure proper validations.
|
|
323
315
|
*
|
|
324
316
|
*/
|
|
325
|
-
export interface
|
|
326
|
-
$type: "buf.validate.
|
|
317
|
+
export interface FieldRules {
|
|
318
|
+
$type: "buf.validate.FieldRules";
|
|
327
319
|
[unknownFieldsSymbol]?: Uint8Array | undefined;
|
|
328
320
|
[customJson]?: () => unknown;
|
|
321
|
+
/**
|
|
322
|
+
* `cel_expression` is a repeated field CEL expressions. Each expression specifies a validation
|
|
323
|
+
* rule to be applied to this message. These rules are written in Common Expression Language (CEL) syntax.
|
|
324
|
+
*
|
|
325
|
+
* This is a simplified form of the `cel` Rule field, where only `expression` is set. This allows for
|
|
326
|
+
* simpler syntax when defining CEL Rules where `id` and `message` derived from the `expression`. `id` will
|
|
327
|
+
* be same as the `expression`.
|
|
328
|
+
*
|
|
329
|
+
* For more information, [see our documentation](https://buf.build/docs/protovalidate/schemas/custom-rules/).
|
|
330
|
+
*
|
|
331
|
+
* ```proto
|
|
332
|
+
* message MyMessage {
|
|
333
|
+
* // The field `value` must be greater than 42.
|
|
334
|
+
* optional int32 value = 1 [(buf.validate.field).cel_expression = "this > 42"];
|
|
335
|
+
* }
|
|
336
|
+
* ```
|
|
337
|
+
*
|
|
338
|
+
*/
|
|
339
|
+
celExpression: string[];
|
|
329
340
|
/**
|
|
330
341
|
* `cel` is a repeated field used to represent a textual expression
|
|
331
|
-
* in the Common Expression Language (CEL) syntax. For more information
|
|
332
|
-
*
|
|
342
|
+
* in the Common Expression Language (CEL) syntax. For more information,
|
|
343
|
+
* [see our documentation](https://buf.build/docs/protovalidate/schemas/custom-rules/).
|
|
333
344
|
*
|
|
334
345
|
* ```proto
|
|
335
346
|
* message MyMessage {
|
|
@@ -343,57 +354,83 @@ export interface FieldConstraints {
|
|
|
343
354
|
* ```
|
|
344
355
|
*
|
|
345
356
|
*/
|
|
346
|
-
cel:
|
|
357
|
+
cel: Rule[];
|
|
347
358
|
/**
|
|
348
|
-
* If `required` is true, the field must be
|
|
349
|
-
*
|
|
359
|
+
* If `required` is true, the field must be set. A validation error is returned
|
|
360
|
+
* if the field is not set.
|
|
350
361
|
*
|
|
351
|
-
*
|
|
352
|
-
*
|
|
353
|
-
*
|
|
354
|
-
*
|
|
355
|
-
*
|
|
356
|
-
*
|
|
357
|
-
*
|
|
362
|
+
* ```proto
|
|
363
|
+
* syntax="proto3";
|
|
364
|
+
*
|
|
365
|
+
* message FieldsWithPresence {
|
|
366
|
+
* // Requires any string to be set, including the empty string.
|
|
367
|
+
* optional string link = 1 [
|
|
368
|
+
* (buf.validate.field).required = true
|
|
369
|
+
* ];
|
|
370
|
+
* // Requires true or false to be set.
|
|
371
|
+
* optional bool disabled = 2 [
|
|
372
|
+
* (buf.validate.field).required = true
|
|
373
|
+
* ];
|
|
374
|
+
* // Requires a message to be set, including the empty message.
|
|
375
|
+
* SomeMessage msg = 4 [
|
|
376
|
+
* (buf.validate.field).required = true
|
|
377
|
+
* ];
|
|
378
|
+
* }
|
|
379
|
+
* ```
|
|
380
|
+
*
|
|
381
|
+
* All fields in the example above track presence. By default, Protovalidate
|
|
382
|
+
* ignores rules on those fields if no value is set. `required` ensures that
|
|
383
|
+
* the fields are set and valid.
|
|
384
|
+
*
|
|
385
|
+
* Fields that don't track presence are always validated by Protovalidate,
|
|
386
|
+
* whether they are set or not. It is not necessary to add `required`. It
|
|
387
|
+
* can be added to indicate that the field cannot be the zero value.
|
|
358
388
|
*
|
|
359
389
|
* ```proto
|
|
360
|
-
*
|
|
361
|
-
*
|
|
362
|
-
*
|
|
390
|
+
* syntax="proto3";
|
|
391
|
+
*
|
|
392
|
+
* message FieldsWithoutPresence {
|
|
393
|
+
* // `string.email` always applies, even to an empty string.
|
|
394
|
+
* string link = 1 [
|
|
395
|
+
* (buf.validate.field).string.email = true
|
|
396
|
+
* ];
|
|
397
|
+
* // `repeated.min_items` always applies, even to an empty list.
|
|
398
|
+
* repeated string labels = 2 [
|
|
399
|
+
* (buf.validate.field).repeated.min_items = 1
|
|
400
|
+
* ];
|
|
401
|
+
* // `required`, for fields that don't track presence, indicates
|
|
402
|
+
* // the value of the field can't be the zero value.
|
|
403
|
+
* int32 zero_value_not_allowed = 3 [
|
|
404
|
+
* (buf.validate.field).required = true
|
|
405
|
+
* ];
|
|
363
406
|
* }
|
|
364
407
|
* ```
|
|
365
408
|
*
|
|
409
|
+
* To learn which fields track presence, see the
|
|
410
|
+
* [Field Presence cheat sheet](https://protobuf.dev/programming-guides/field_presence/#cheat).
|
|
411
|
+
*
|
|
412
|
+
* Note: While field rules can be applied to repeated items, map keys, and map
|
|
413
|
+
* values, the elements are always considered to be set. Consequently,
|
|
414
|
+
* specifying `repeated.items.required` is redundant.
|
|
415
|
+
*
|
|
366
416
|
*/
|
|
367
417
|
required?: boolean | undefined;
|
|
368
418
|
/**
|
|
369
|
-
*
|
|
370
|
-
* See Ignore enum for details.
|
|
419
|
+
* Ignore validation rules on the field if its value matches the specified
|
|
420
|
+
* criteria. See the `Ignore` enum for details.
|
|
371
421
|
*
|
|
372
422
|
* ```proto
|
|
373
423
|
* message UpdateRequest {
|
|
374
|
-
* // The uri rule only applies if the field is
|
|
375
|
-
*
|
|
376
|
-
*
|
|
377
|
-
* (buf.validate.field).
|
|
378
|
-
* (buf.validate.field).string.uri = true,
|
|
424
|
+
* // The uri rule only applies if the field is not an empty string.
|
|
425
|
+
* string url = 1 [
|
|
426
|
+
* (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE,
|
|
427
|
+
* (buf.validate.field).string.uri = true
|
|
379
428
|
* ];
|
|
380
429
|
* }
|
|
381
430
|
* ```
|
|
382
431
|
*
|
|
383
432
|
*/
|
|
384
433
|
ignore?: Ignore | undefined;
|
|
385
|
-
/**
|
|
386
|
-
* DEPRECATED: use ignore=IGNORE_ALWAYS instead. TODO: remove this field pre-v1.
|
|
387
|
-
*
|
|
388
|
-
* @deprecated Deprecated.
|
|
389
|
-
*/
|
|
390
|
-
skipped?: boolean | undefined;
|
|
391
|
-
/**
|
|
392
|
-
* DEPRECATED: use ignore=IGNORE_IF_UNPOPULATED instead. TODO: remove this field pre-v1.
|
|
393
|
-
*
|
|
394
|
-
* @deprecated Deprecated.
|
|
395
|
-
*/
|
|
396
|
-
ignoreEmpty?: boolean | undefined;
|
|
397
434
|
type?: {
|
|
398
435
|
$case: "float";
|
|
399
436
|
float: FloatRules;
|
|
@@ -454,25 +491,28 @@ export interface FieldConstraints {
|
|
|
454
491
|
} | {
|
|
455
492
|
$case: "duration";
|
|
456
493
|
duration: DurationRules;
|
|
494
|
+
} | {
|
|
495
|
+
$case: "fieldMask";
|
|
496
|
+
fieldMask: FieldMaskRules;
|
|
457
497
|
} | {
|
|
458
498
|
$case: "timestamp";
|
|
459
499
|
timestamp: TimestampRules;
|
|
460
500
|
} | undefined;
|
|
461
501
|
}
|
|
462
|
-
export declare const
|
|
502
|
+
export declare const FieldRules: MessageFns<FieldRules, "buf.validate.FieldRules">;
|
|
463
503
|
/**
|
|
464
|
-
*
|
|
504
|
+
* PredefinedRules are custom rules that can be re-used with
|
|
465
505
|
* multiple fields.
|
|
466
506
|
*
|
|
467
507
|
*/
|
|
468
|
-
export interface
|
|
469
|
-
$type: "buf.validate.
|
|
508
|
+
export interface PredefinedRules {
|
|
509
|
+
$type: "buf.validate.PredefinedRules";
|
|
470
510
|
[unknownFieldsSymbol]?: Uint8Array | undefined;
|
|
471
511
|
[customJson]?: () => unknown;
|
|
472
512
|
/**
|
|
473
513
|
* `cel` is a repeated field used to represent a textual expression
|
|
474
|
-
* in the Common Expression Language (CEL) syntax. For more information
|
|
475
|
-
*
|
|
514
|
+
* in the Common Expression Language (CEL) syntax. For more information,
|
|
515
|
+
* [see our documentation](https://buf.build/docs/protovalidate/schemas/predefined-rules/).
|
|
476
516
|
*
|
|
477
517
|
* ```proto
|
|
478
518
|
* message MyMessage {
|
|
@@ -486,11 +526,11 @@ export interface PredefinedConstraints {
|
|
|
486
526
|
* ```
|
|
487
527
|
*
|
|
488
528
|
*/
|
|
489
|
-
cel:
|
|
529
|
+
cel: Rule[];
|
|
490
530
|
}
|
|
491
|
-
export declare const
|
|
531
|
+
export declare const PredefinedRules: MessageFns<PredefinedRules, "buf.validate.PredefinedRules">;
|
|
492
532
|
/**
|
|
493
|
-
* FloatRules describes the
|
|
533
|
+
* FloatRules describes the rules applied to `float` values. These
|
|
494
534
|
* rules may also be applied to the `google.protobuf.FloatValue` Well-Known-Type.
|
|
495
535
|
*
|
|
496
536
|
*/
|
|
@@ -519,7 +559,7 @@ export interface FloatRules {
|
|
|
519
559
|
* ```proto
|
|
520
560
|
* message MyFloat {
|
|
521
561
|
* // value must be in list [1.0, 2.0, 3.0]
|
|
522
|
-
*
|
|
562
|
+
* float value = 1 [(buf.validate.field).float = { in: [1.0, 2.0, 3.0] }];
|
|
523
563
|
* }
|
|
524
564
|
* ```
|
|
525
565
|
*
|
|
@@ -533,7 +573,7 @@ export interface FloatRules {
|
|
|
533
573
|
* ```proto
|
|
534
574
|
* message MyFloat {
|
|
535
575
|
* // value must not be in list [1.0, 2.0, 3.0]
|
|
536
|
-
*
|
|
576
|
+
* float value = 1 [(buf.validate.field).float = { not_in: [1.0, 2.0, 3.0] }];
|
|
537
577
|
* }
|
|
538
578
|
* ```
|
|
539
579
|
*
|
|
@@ -547,14 +587,14 @@ export interface FloatRules {
|
|
|
547
587
|
finite?: boolean | undefined;
|
|
548
588
|
/**
|
|
549
589
|
* `example` specifies values that the field may have. These values SHOULD
|
|
550
|
-
* conform to other
|
|
590
|
+
* conform to other rules. `example` values will not impact validation
|
|
551
591
|
* but may be used as helpful guidance on how to populate the given field.
|
|
552
592
|
*
|
|
553
593
|
* ```proto
|
|
554
594
|
* message MyFloat {
|
|
555
595
|
* float value = 1 [
|
|
556
596
|
* (buf.validate.field).float.example = 1.0,
|
|
557
|
-
* (buf.validate.field).float.example =
|
|
597
|
+
* (buf.validate.field).float.example = inf
|
|
558
598
|
* ];
|
|
559
599
|
* }
|
|
560
600
|
* ```
|
|
@@ -578,7 +618,7 @@ export interface FloatRules {
|
|
|
578
618
|
}
|
|
579
619
|
export declare const FloatRules: MessageFns<FloatRules, "buf.validate.FloatRules">;
|
|
580
620
|
/**
|
|
581
|
-
* DoubleRules describes the
|
|
621
|
+
* DoubleRules describes the rules applied to `double` values. These
|
|
582
622
|
* rules may also be applied to the `google.protobuf.DoubleValue` Well-Known-Type.
|
|
583
623
|
*
|
|
584
624
|
*/
|
|
@@ -607,7 +647,7 @@ export interface DoubleRules {
|
|
|
607
647
|
* ```proto
|
|
608
648
|
* message MyDouble {
|
|
609
649
|
* // value must be in list [1.0, 2.0, 3.0]
|
|
610
|
-
*
|
|
650
|
+
* double value = 1 [(buf.validate.field).double = { in: [1.0, 2.0, 3.0] }];
|
|
611
651
|
* }
|
|
612
652
|
* ```
|
|
613
653
|
*
|
|
@@ -621,7 +661,7 @@ export interface DoubleRules {
|
|
|
621
661
|
* ```proto
|
|
622
662
|
* message MyDouble {
|
|
623
663
|
* // value must not be in list [1.0, 2.0, 3.0]
|
|
624
|
-
*
|
|
664
|
+
* double value = 1 [(buf.validate.field).double = { not_in: [1.0, 2.0, 3.0] }];
|
|
625
665
|
* }
|
|
626
666
|
* ```
|
|
627
667
|
*
|
|
@@ -635,14 +675,14 @@ export interface DoubleRules {
|
|
|
635
675
|
finite?: boolean | undefined;
|
|
636
676
|
/**
|
|
637
677
|
* `example` specifies values that the field may have. These values SHOULD
|
|
638
|
-
* conform to other
|
|
678
|
+
* conform to other rules. `example` values will not impact validation
|
|
639
679
|
* but may be used as helpful guidance on how to populate the given field.
|
|
640
680
|
*
|
|
641
681
|
* ```proto
|
|
642
682
|
* message MyDouble {
|
|
643
683
|
* double value = 1 [
|
|
644
684
|
* (buf.validate.field).double.example = 1.0,
|
|
645
|
-
* (buf.validate.field).double.example =
|
|
685
|
+
* (buf.validate.field).double.example = inf
|
|
646
686
|
* ];
|
|
647
687
|
* }
|
|
648
688
|
* ```
|
|
@@ -666,7 +706,7 @@ export interface DoubleRules {
|
|
|
666
706
|
}
|
|
667
707
|
export declare const DoubleRules: MessageFns<DoubleRules, "buf.validate.DoubleRules">;
|
|
668
708
|
/**
|
|
669
|
-
* Int32Rules describes the
|
|
709
|
+
* Int32Rules describes the rules applied to `int32` values. These
|
|
670
710
|
* rules may also be applied to the `google.protobuf.Int32Value` Well-Known-Type.
|
|
671
711
|
*
|
|
672
712
|
*/
|
|
@@ -695,7 +735,7 @@ export interface Int32Rules {
|
|
|
695
735
|
* ```proto
|
|
696
736
|
* message MyInt32 {
|
|
697
737
|
* // value must be in list [1, 2, 3]
|
|
698
|
-
*
|
|
738
|
+
* int32 value = 1 [(buf.validate.field).int32 = { in: [1, 2, 3] }];
|
|
699
739
|
* }
|
|
700
740
|
* ```
|
|
701
741
|
*
|
|
@@ -709,7 +749,7 @@ export interface Int32Rules {
|
|
|
709
749
|
* ```proto
|
|
710
750
|
* message MyInt32 {
|
|
711
751
|
* // value must not be in list [1, 2, 3]
|
|
712
|
-
*
|
|
752
|
+
* int32 value = 1 [(buf.validate.field).int32 = { not_in: [1, 2, 3] }];
|
|
713
753
|
* }
|
|
714
754
|
* ```
|
|
715
755
|
*
|
|
@@ -717,7 +757,7 @@ export interface Int32Rules {
|
|
|
717
757
|
notIn: number[];
|
|
718
758
|
/**
|
|
719
759
|
* `example` specifies values that the field may have. These values SHOULD
|
|
720
|
-
* conform to other
|
|
760
|
+
* conform to other rules. `example` values will not impact validation
|
|
721
761
|
* but may be used as helpful guidance on how to populate the given field.
|
|
722
762
|
*
|
|
723
763
|
* ```proto
|
|
@@ -748,7 +788,7 @@ export interface Int32Rules {
|
|
|
748
788
|
}
|
|
749
789
|
export declare const Int32Rules: MessageFns<Int32Rules, "buf.validate.Int32Rules">;
|
|
750
790
|
/**
|
|
751
|
-
* Int64Rules describes the
|
|
791
|
+
* Int64Rules describes the rules applied to `int64` values. These
|
|
752
792
|
* rules may also be applied to the `google.protobuf.Int64Value` Well-Known-Type.
|
|
753
793
|
*
|
|
754
794
|
*/
|
|
@@ -777,7 +817,7 @@ export interface Int64Rules {
|
|
|
777
817
|
* ```proto
|
|
778
818
|
* message MyInt64 {
|
|
779
819
|
* // value must be in list [1, 2, 3]
|
|
780
|
-
*
|
|
820
|
+
* int64 value = 1 [(buf.validate.field).int64 = { in: [1, 2, 3] }];
|
|
781
821
|
* }
|
|
782
822
|
* ```
|
|
783
823
|
*
|
|
@@ -791,7 +831,7 @@ export interface Int64Rules {
|
|
|
791
831
|
* ```proto
|
|
792
832
|
* message MyInt64 {
|
|
793
833
|
* // value must not be in list [1, 2, 3]
|
|
794
|
-
*
|
|
834
|
+
* int64 value = 1 [(buf.validate.field).int64 = { not_in: [1, 2, 3] }];
|
|
795
835
|
* }
|
|
796
836
|
* ```
|
|
797
837
|
*
|
|
@@ -799,7 +839,7 @@ export interface Int64Rules {
|
|
|
799
839
|
notIn: Long[];
|
|
800
840
|
/**
|
|
801
841
|
* `example` specifies values that the field may have. These values SHOULD
|
|
802
|
-
* conform to other
|
|
842
|
+
* conform to other rules. `example` values will not impact validation
|
|
803
843
|
* but may be used as helpful guidance on how to populate the given field.
|
|
804
844
|
*
|
|
805
845
|
* ```proto
|
|
@@ -830,7 +870,7 @@ export interface Int64Rules {
|
|
|
830
870
|
}
|
|
831
871
|
export declare const Int64Rules: MessageFns<Int64Rules, "buf.validate.Int64Rules">;
|
|
832
872
|
/**
|
|
833
|
-
* UInt32Rules describes the
|
|
873
|
+
* UInt32Rules describes the rules applied to `uint32` values. These
|
|
834
874
|
* rules may also be applied to the `google.protobuf.UInt32Value` Well-Known-Type.
|
|
835
875
|
*
|
|
836
876
|
*/
|
|
@@ -859,7 +899,7 @@ export interface UInt32Rules {
|
|
|
859
899
|
* ```proto
|
|
860
900
|
* message MyUInt32 {
|
|
861
901
|
* // value must be in list [1, 2, 3]
|
|
862
|
-
*
|
|
902
|
+
* uint32 value = 1 [(buf.validate.field).uint32 = { in: [1, 2, 3] }];
|
|
863
903
|
* }
|
|
864
904
|
* ```
|
|
865
905
|
*
|
|
@@ -873,7 +913,7 @@ export interface UInt32Rules {
|
|
|
873
913
|
* ```proto
|
|
874
914
|
* message MyUInt32 {
|
|
875
915
|
* // value must not be in list [1, 2, 3]
|
|
876
|
-
*
|
|
916
|
+
* uint32 value = 1 [(buf.validate.field).uint32 = { not_in: [1, 2, 3] }];
|
|
877
917
|
* }
|
|
878
918
|
* ```
|
|
879
919
|
*
|
|
@@ -881,7 +921,7 @@ export interface UInt32Rules {
|
|
|
881
921
|
notIn: number[];
|
|
882
922
|
/**
|
|
883
923
|
* `example` specifies values that the field may have. These values SHOULD
|
|
884
|
-
* conform to other
|
|
924
|
+
* conform to other rules. `example` values will not impact validation
|
|
885
925
|
* but may be used as helpful guidance on how to populate the given field.
|
|
886
926
|
*
|
|
887
927
|
* ```proto
|
|
@@ -912,7 +952,7 @@ export interface UInt32Rules {
|
|
|
912
952
|
}
|
|
913
953
|
export declare const UInt32Rules: MessageFns<UInt32Rules, "buf.validate.UInt32Rules">;
|
|
914
954
|
/**
|
|
915
|
-
* UInt64Rules describes the
|
|
955
|
+
* UInt64Rules describes the rules applied to `uint64` values. These
|
|
916
956
|
* rules may also be applied to the `google.protobuf.UInt64Value` Well-Known-Type.
|
|
917
957
|
*
|
|
918
958
|
*/
|
|
@@ -941,7 +981,7 @@ export interface UInt64Rules {
|
|
|
941
981
|
* ```proto
|
|
942
982
|
* message MyUInt64 {
|
|
943
983
|
* // value must be in list [1, 2, 3]
|
|
944
|
-
*
|
|
984
|
+
* uint64 value = 1 [(buf.validate.field).uint64 = { in: [1, 2, 3] }];
|
|
945
985
|
* }
|
|
946
986
|
* ```
|
|
947
987
|
*
|
|
@@ -955,7 +995,7 @@ export interface UInt64Rules {
|
|
|
955
995
|
* ```proto
|
|
956
996
|
* message MyUInt64 {
|
|
957
997
|
* // value must not be in list [1, 2, 3]
|
|
958
|
-
*
|
|
998
|
+
* uint64 value = 1 [(buf.validate.field).uint64 = { not_in: [1, 2, 3] }];
|
|
959
999
|
* }
|
|
960
1000
|
* ```
|
|
961
1001
|
*
|
|
@@ -963,7 +1003,7 @@ export interface UInt64Rules {
|
|
|
963
1003
|
notIn: Long[];
|
|
964
1004
|
/**
|
|
965
1005
|
* `example` specifies values that the field may have. These values SHOULD
|
|
966
|
-
* conform to other
|
|
1006
|
+
* conform to other rules. `example` values will not impact validation
|
|
967
1007
|
* but may be used as helpful guidance on how to populate the given field.
|
|
968
1008
|
*
|
|
969
1009
|
* ```proto
|
|
@@ -994,7 +1034,7 @@ export interface UInt64Rules {
|
|
|
994
1034
|
}
|
|
995
1035
|
export declare const UInt64Rules: MessageFns<UInt64Rules, "buf.validate.UInt64Rules">;
|
|
996
1036
|
/**
|
|
997
|
-
* SInt32Rules describes the
|
|
1037
|
+
* SInt32Rules describes the rules applied to `sint32` values.
|
|
998
1038
|
*
|
|
999
1039
|
*/
|
|
1000
1040
|
export interface SInt32Rules {
|
|
@@ -1022,7 +1062,7 @@ export interface SInt32Rules {
|
|
|
1022
1062
|
* ```proto
|
|
1023
1063
|
* message MySInt32 {
|
|
1024
1064
|
* // value must be in list [1, 2, 3]
|
|
1025
|
-
*
|
|
1065
|
+
* sint32 value = 1 [(buf.validate.field).sint32 = { in: [1, 2, 3] }];
|
|
1026
1066
|
* }
|
|
1027
1067
|
* ```
|
|
1028
1068
|
*
|
|
@@ -1036,7 +1076,7 @@ export interface SInt32Rules {
|
|
|
1036
1076
|
* ```proto
|
|
1037
1077
|
* message MySInt32 {
|
|
1038
1078
|
* // value must not be in list [1, 2, 3]
|
|
1039
|
-
*
|
|
1079
|
+
* sint32 value = 1 [(buf.validate.field).sint32 = { not_in: [1, 2, 3] }];
|
|
1040
1080
|
* }
|
|
1041
1081
|
* ```
|
|
1042
1082
|
*
|
|
@@ -1044,7 +1084,7 @@ export interface SInt32Rules {
|
|
|
1044
1084
|
notIn: number[];
|
|
1045
1085
|
/**
|
|
1046
1086
|
* `example` specifies values that the field may have. These values SHOULD
|
|
1047
|
-
* conform to other
|
|
1087
|
+
* conform to other rules. `example` values will not impact validation
|
|
1048
1088
|
* but may be used as helpful guidance on how to populate the given field.
|
|
1049
1089
|
*
|
|
1050
1090
|
* ```proto
|
|
@@ -1075,7 +1115,7 @@ export interface SInt32Rules {
|
|
|
1075
1115
|
}
|
|
1076
1116
|
export declare const SInt32Rules: MessageFns<SInt32Rules, "buf.validate.SInt32Rules">;
|
|
1077
1117
|
/**
|
|
1078
|
-
* SInt64Rules describes the
|
|
1118
|
+
* SInt64Rules describes the rules applied to `sint64` values.
|
|
1079
1119
|
*
|
|
1080
1120
|
*/
|
|
1081
1121
|
export interface SInt64Rules {
|
|
@@ -1103,7 +1143,7 @@ export interface SInt64Rules {
|
|
|
1103
1143
|
* ```proto
|
|
1104
1144
|
* message MySInt64 {
|
|
1105
1145
|
* // value must be in list [1, 2, 3]
|
|
1106
|
-
*
|
|
1146
|
+
* sint64 value = 1 [(buf.validate.field).sint64 = { in: [1, 2, 3] }];
|
|
1107
1147
|
* }
|
|
1108
1148
|
* ```
|
|
1109
1149
|
*
|
|
@@ -1117,7 +1157,7 @@ export interface SInt64Rules {
|
|
|
1117
1157
|
* ```proto
|
|
1118
1158
|
* message MySInt64 {
|
|
1119
1159
|
* // value must not be in list [1, 2, 3]
|
|
1120
|
-
*
|
|
1160
|
+
* sint64 value = 1 [(buf.validate.field).sint64 = { not_in: [1, 2, 3] }];
|
|
1121
1161
|
* }
|
|
1122
1162
|
* ```
|
|
1123
1163
|
*
|
|
@@ -1125,7 +1165,7 @@ export interface SInt64Rules {
|
|
|
1125
1165
|
notIn: Long[];
|
|
1126
1166
|
/**
|
|
1127
1167
|
* `example` specifies values that the field may have. These values SHOULD
|
|
1128
|
-
* conform to other
|
|
1168
|
+
* conform to other rules. `example` values will not impact validation
|
|
1129
1169
|
* but may be used as helpful guidance on how to populate the given field.
|
|
1130
1170
|
*
|
|
1131
1171
|
* ```proto
|
|
@@ -1156,7 +1196,7 @@ export interface SInt64Rules {
|
|
|
1156
1196
|
}
|
|
1157
1197
|
export declare const SInt64Rules: MessageFns<SInt64Rules, "buf.validate.SInt64Rules">;
|
|
1158
1198
|
/**
|
|
1159
|
-
* Fixed32Rules describes the
|
|
1199
|
+
* Fixed32Rules describes the rules applied to `fixed32` values.
|
|
1160
1200
|
*
|
|
1161
1201
|
*/
|
|
1162
1202
|
export interface Fixed32Rules {
|
|
@@ -1184,7 +1224,7 @@ export interface Fixed32Rules {
|
|
|
1184
1224
|
* ```proto
|
|
1185
1225
|
* message MyFixed32 {
|
|
1186
1226
|
* // value must be in list [1, 2, 3]
|
|
1187
|
-
*
|
|
1227
|
+
* fixed32 value = 1 [(buf.validate.field).fixed32 = { in: [1, 2, 3] }];
|
|
1188
1228
|
* }
|
|
1189
1229
|
* ```
|
|
1190
1230
|
*
|
|
@@ -1198,7 +1238,7 @@ export interface Fixed32Rules {
|
|
|
1198
1238
|
* ```proto
|
|
1199
1239
|
* message MyFixed32 {
|
|
1200
1240
|
* // value must not be in list [1, 2, 3]
|
|
1201
|
-
*
|
|
1241
|
+
* fixed32 value = 1 [(buf.validate.field).fixed32 = { not_in: [1, 2, 3] }];
|
|
1202
1242
|
* }
|
|
1203
1243
|
* ```
|
|
1204
1244
|
*
|
|
@@ -1206,7 +1246,7 @@ export interface Fixed32Rules {
|
|
|
1206
1246
|
notIn: number[];
|
|
1207
1247
|
/**
|
|
1208
1248
|
* `example` specifies values that the field may have. These values SHOULD
|
|
1209
|
-
* conform to other
|
|
1249
|
+
* conform to other rules. `example` values will not impact validation
|
|
1210
1250
|
* but may be used as helpful guidance on how to populate the given field.
|
|
1211
1251
|
*
|
|
1212
1252
|
* ```proto
|
|
@@ -1237,7 +1277,7 @@ export interface Fixed32Rules {
|
|
|
1237
1277
|
}
|
|
1238
1278
|
export declare const Fixed32Rules: MessageFns<Fixed32Rules, "buf.validate.Fixed32Rules">;
|
|
1239
1279
|
/**
|
|
1240
|
-
* Fixed64Rules describes the
|
|
1280
|
+
* Fixed64Rules describes the rules applied to `fixed64` values.
|
|
1241
1281
|
*
|
|
1242
1282
|
*/
|
|
1243
1283
|
export interface Fixed64Rules {
|
|
@@ -1265,7 +1305,7 @@ export interface Fixed64Rules {
|
|
|
1265
1305
|
* ```proto
|
|
1266
1306
|
* message MyFixed64 {
|
|
1267
1307
|
* // value must be in list [1, 2, 3]
|
|
1268
|
-
*
|
|
1308
|
+
* fixed64 value = 1 [(buf.validate.field).fixed64 = { in: [1, 2, 3] }];
|
|
1269
1309
|
* }
|
|
1270
1310
|
* ```
|
|
1271
1311
|
*
|
|
@@ -1279,7 +1319,7 @@ export interface Fixed64Rules {
|
|
|
1279
1319
|
* ```proto
|
|
1280
1320
|
* message MyFixed64 {
|
|
1281
1321
|
* // value must not be in list [1, 2, 3]
|
|
1282
|
-
*
|
|
1322
|
+
* fixed64 value = 1 [(buf.validate.field).fixed64 = { not_in: [1, 2, 3] }];
|
|
1283
1323
|
* }
|
|
1284
1324
|
* ```
|
|
1285
1325
|
*
|
|
@@ -1287,7 +1327,7 @@ export interface Fixed64Rules {
|
|
|
1287
1327
|
notIn: Long[];
|
|
1288
1328
|
/**
|
|
1289
1329
|
* `example` specifies values that the field may have. These values SHOULD
|
|
1290
|
-
* conform to other
|
|
1330
|
+
* conform to other rules. `example` values will not impact validation
|
|
1291
1331
|
* but may be used as helpful guidance on how to populate the given field.
|
|
1292
1332
|
*
|
|
1293
1333
|
* ```proto
|
|
@@ -1318,7 +1358,7 @@ export interface Fixed64Rules {
|
|
|
1318
1358
|
}
|
|
1319
1359
|
export declare const Fixed64Rules: MessageFns<Fixed64Rules, "buf.validate.Fixed64Rules">;
|
|
1320
1360
|
/**
|
|
1321
|
-
* SFixed32Rules describes the
|
|
1361
|
+
* SFixed32Rules describes the rules applied to `fixed32` values.
|
|
1322
1362
|
*
|
|
1323
1363
|
*/
|
|
1324
1364
|
export interface SFixed32Rules {
|
|
@@ -1346,7 +1386,7 @@ export interface SFixed32Rules {
|
|
|
1346
1386
|
* ```proto
|
|
1347
1387
|
* message MySFixed32 {
|
|
1348
1388
|
* // value must be in list [1, 2, 3]
|
|
1349
|
-
*
|
|
1389
|
+
* sfixed32 value = 1 [(buf.validate.field).sfixed32 = { in: [1, 2, 3] }];
|
|
1350
1390
|
* }
|
|
1351
1391
|
* ```
|
|
1352
1392
|
*
|
|
@@ -1360,7 +1400,7 @@ export interface SFixed32Rules {
|
|
|
1360
1400
|
* ```proto
|
|
1361
1401
|
* message MySFixed32 {
|
|
1362
1402
|
* // value must not be in list [1, 2, 3]
|
|
1363
|
-
*
|
|
1403
|
+
* sfixed32 value = 1 [(buf.validate.field).sfixed32 = { not_in: [1, 2, 3] }];
|
|
1364
1404
|
* }
|
|
1365
1405
|
* ```
|
|
1366
1406
|
*
|
|
@@ -1368,7 +1408,7 @@ export interface SFixed32Rules {
|
|
|
1368
1408
|
notIn: number[];
|
|
1369
1409
|
/**
|
|
1370
1410
|
* `example` specifies values that the field may have. These values SHOULD
|
|
1371
|
-
* conform to other
|
|
1411
|
+
* conform to other rules. `example` values will not impact validation
|
|
1372
1412
|
* but may be used as helpful guidance on how to populate the given field.
|
|
1373
1413
|
*
|
|
1374
1414
|
* ```proto
|
|
@@ -1399,7 +1439,7 @@ export interface SFixed32Rules {
|
|
|
1399
1439
|
}
|
|
1400
1440
|
export declare const SFixed32Rules: MessageFns<SFixed32Rules, "buf.validate.SFixed32Rules">;
|
|
1401
1441
|
/**
|
|
1402
|
-
* SFixed64Rules describes the
|
|
1442
|
+
* SFixed64Rules describes the rules applied to `fixed64` values.
|
|
1403
1443
|
*
|
|
1404
1444
|
*/
|
|
1405
1445
|
export interface SFixed64Rules {
|
|
@@ -1427,7 +1467,7 @@ export interface SFixed64Rules {
|
|
|
1427
1467
|
* ```proto
|
|
1428
1468
|
* message MySFixed64 {
|
|
1429
1469
|
* // value must be in list [1, 2, 3]
|
|
1430
|
-
*
|
|
1470
|
+
* sfixed64 value = 1 [(buf.validate.field).sfixed64 = { in: [1, 2, 3] }];
|
|
1431
1471
|
* }
|
|
1432
1472
|
* ```
|
|
1433
1473
|
*
|
|
@@ -1441,7 +1481,7 @@ export interface SFixed64Rules {
|
|
|
1441
1481
|
* ```proto
|
|
1442
1482
|
* message MySFixed64 {
|
|
1443
1483
|
* // value must not be in list [1, 2, 3]
|
|
1444
|
-
*
|
|
1484
|
+
* sfixed64 value = 1 [(buf.validate.field).sfixed64 = { not_in: [1, 2, 3] }];
|
|
1445
1485
|
* }
|
|
1446
1486
|
* ```
|
|
1447
1487
|
*
|
|
@@ -1449,7 +1489,7 @@ export interface SFixed64Rules {
|
|
|
1449
1489
|
notIn: Long[];
|
|
1450
1490
|
/**
|
|
1451
1491
|
* `example` specifies values that the field may have. These values SHOULD
|
|
1452
|
-
* conform to other
|
|
1492
|
+
* conform to other rules. `example` values will not impact validation
|
|
1453
1493
|
* but may be used as helpful guidance on how to populate the given field.
|
|
1454
1494
|
*
|
|
1455
1495
|
* ```proto
|
|
@@ -1480,7 +1520,7 @@ export interface SFixed64Rules {
|
|
|
1480
1520
|
}
|
|
1481
1521
|
export declare const SFixed64Rules: MessageFns<SFixed64Rules, "buf.validate.SFixed64Rules">;
|
|
1482
1522
|
/**
|
|
1483
|
-
* BoolRules describes the
|
|
1523
|
+
* BoolRules describes the rules applied to `bool` values. These rules
|
|
1484
1524
|
* may also be applied to the `google.protobuf.BoolValue` Well-Known-Type.
|
|
1485
1525
|
*
|
|
1486
1526
|
*/
|
|
@@ -1503,7 +1543,7 @@ export interface BoolRules {
|
|
|
1503
1543
|
const?: boolean | undefined;
|
|
1504
1544
|
/**
|
|
1505
1545
|
* `example` specifies values that the field may have. These values SHOULD
|
|
1506
|
-
* conform to other
|
|
1546
|
+
* conform to other rules. `example` values will not impact validation
|
|
1507
1547
|
* but may be used as helpful guidance on how to populate the given field.
|
|
1508
1548
|
*
|
|
1509
1549
|
* ```proto
|
|
@@ -1520,7 +1560,7 @@ export interface BoolRules {
|
|
|
1520
1560
|
}
|
|
1521
1561
|
export declare const BoolRules: MessageFns<BoolRules, "buf.validate.BoolRules">;
|
|
1522
1562
|
/**
|
|
1523
|
-
* StringRules describes the
|
|
1563
|
+
* StringRules describes the rules applied to `string` values These
|
|
1524
1564
|
* rules may also be applied to the `google.protobuf.StringValue` Well-Known-Type.
|
|
1525
1565
|
*
|
|
1526
1566
|
*/
|
|
@@ -1709,7 +1749,7 @@ export interface StringRules {
|
|
|
1709
1749
|
* ```proto
|
|
1710
1750
|
* message MyString {
|
|
1711
1751
|
* // value must be in list ["apple", "banana"]
|
|
1712
|
-
*
|
|
1752
|
+
* string value = 1 [(buf.validate.field).string.in = "apple", (buf.validate.field).string.in = "banana"];
|
|
1713
1753
|
* }
|
|
1714
1754
|
* ```
|
|
1715
1755
|
*
|
|
@@ -1722,7 +1762,7 @@ export interface StringRules {
|
|
|
1722
1762
|
* ```proto
|
|
1723
1763
|
* message MyString {
|
|
1724
1764
|
* // value must not be in list ["orange", "grape"]
|
|
1725
|
-
*
|
|
1765
|
+
* string value = 1 [(buf.validate.field).string.not_in = "orange", (buf.validate.field).string.not_in = "grape"];
|
|
1726
1766
|
* }
|
|
1727
1767
|
* ```
|
|
1728
1768
|
*
|
|
@@ -1731,7 +1771,7 @@ export interface StringRules {
|
|
|
1731
1771
|
/**
|
|
1732
1772
|
* This applies to regexes `HTTP_HEADER_NAME` and `HTTP_HEADER_VALUE` to
|
|
1733
1773
|
* enable strict header validation. By default, this is true, and HTTP header
|
|
1734
|
-
* validations are [RFC-compliant](https://
|
|
1774
|
+
* validations are [RFC-compliant](https://datatracker.ietf.org/doc/html/rfc7230#section-3). Setting to false will enable looser
|
|
1735
1775
|
* validations that only disallow `\r\n\0` characters, which can be used to
|
|
1736
1776
|
* bypass header matching rules.
|
|
1737
1777
|
*
|
|
@@ -1746,7 +1786,7 @@ export interface StringRules {
|
|
|
1746
1786
|
strict?: boolean | undefined;
|
|
1747
1787
|
/**
|
|
1748
1788
|
* `example` specifies values that the field may have. These values SHOULD
|
|
1749
|
-
* conform to other
|
|
1789
|
+
* conform to other rules. `example` values will not impact validation
|
|
1750
1790
|
* but may be used as helpful guidance on how to populate the given field.
|
|
1751
1791
|
*
|
|
1752
1792
|
* ```proto
|
|
@@ -1761,8 +1801,8 @@ export interface StringRules {
|
|
|
1761
1801
|
*/
|
|
1762
1802
|
example: string[];
|
|
1763
1803
|
/**
|
|
1764
|
-
* `WellKnown` rules provide advanced
|
|
1765
|
-
* patterns
|
|
1804
|
+
* `WellKnown` rules provide advanced rules against common string
|
|
1805
|
+
* patterns.
|
|
1766
1806
|
*
|
|
1767
1807
|
*/
|
|
1768
1808
|
wellKnown?: {
|
|
@@ -1816,6 +1856,9 @@ export interface StringRules {
|
|
|
1816
1856
|
} | {
|
|
1817
1857
|
$case: "hostAndPort";
|
|
1818
1858
|
hostAndPort: boolean;
|
|
1859
|
+
} | {
|
|
1860
|
+
$case: "ulid";
|
|
1861
|
+
ulid: boolean;
|
|
1819
1862
|
} | {
|
|
1820
1863
|
$case: "wellKnownRegex";
|
|
1821
1864
|
wellKnownRegex: KnownRegex;
|
|
@@ -1823,7 +1866,7 @@ export interface StringRules {
|
|
|
1823
1866
|
}
|
|
1824
1867
|
export declare const StringRules: MessageFns<StringRules, "buf.validate.StringRules">;
|
|
1825
1868
|
/**
|
|
1826
|
-
* BytesRules describe the
|
|
1869
|
+
* BytesRules describe the rules applied to `bytes` values. These rules
|
|
1827
1870
|
* may also be applied to the `google.protobuf.BytesValue` Well-Known-Type.
|
|
1828
1871
|
*
|
|
1829
1872
|
*/
|
|
@@ -1934,7 +1977,7 @@ export interface BytesRules {
|
|
|
1934
1977
|
* the string.
|
|
1935
1978
|
* If the field value doesn't meet the requirement, an error message is generated.
|
|
1936
1979
|
*
|
|
1937
|
-
* ```
|
|
1980
|
+
* ```proto
|
|
1938
1981
|
* message MyBytes {
|
|
1939
1982
|
* // value does not contain \x02\x03
|
|
1940
1983
|
* optional bytes value = 1 [(buf.validate.field).bytes.contains = "\x02\x03"];
|
|
@@ -1948,7 +1991,7 @@ export interface BytesRules {
|
|
|
1948
1991
|
* values. If the field value doesn't match any of the specified values, an
|
|
1949
1992
|
* error message is generated.
|
|
1950
1993
|
*
|
|
1951
|
-
* ```
|
|
1994
|
+
* ```proto
|
|
1952
1995
|
* message MyBytes {
|
|
1953
1996
|
* // value must in ["\x01\x02", "\x02\x03", "\x03\x04"]
|
|
1954
1997
|
* optional bytes value = 1 [(buf.validate.field).bytes.in = {"\x01\x02", "\x02\x03", "\x03\x04"}];
|
|
@@ -1974,7 +2017,7 @@ export interface BytesRules {
|
|
|
1974
2017
|
notIn: Uint8Array[];
|
|
1975
2018
|
/**
|
|
1976
2019
|
* `example` specifies values that the field may have. These values SHOULD
|
|
1977
|
-
* conform to other
|
|
2020
|
+
* conform to other rules. `example` values will not impact validation
|
|
1978
2021
|
* but may be used as helpful guidance on how to populate the given field.
|
|
1979
2022
|
*
|
|
1980
2023
|
* ```proto
|
|
@@ -1989,7 +2032,7 @@ export interface BytesRules {
|
|
|
1989
2032
|
*/
|
|
1990
2033
|
example: Uint8Array[];
|
|
1991
2034
|
/**
|
|
1992
|
-
* WellKnown rules provide advanced
|
|
2035
|
+
* WellKnown rules provide advanced rules against common byte
|
|
1993
2036
|
* patterns
|
|
1994
2037
|
*
|
|
1995
2038
|
*/
|
|
@@ -2002,11 +2045,14 @@ export interface BytesRules {
|
|
|
2002
2045
|
} | {
|
|
2003
2046
|
$case: "ipv6";
|
|
2004
2047
|
ipv6: boolean;
|
|
2048
|
+
} | {
|
|
2049
|
+
$case: "uuid";
|
|
2050
|
+
uuid: boolean;
|
|
2005
2051
|
} | undefined;
|
|
2006
2052
|
}
|
|
2007
2053
|
export declare const BytesRules: MessageFns<BytesRules, "buf.validate.BytesRules">;
|
|
2008
2054
|
/**
|
|
2009
|
-
* EnumRules describe the
|
|
2055
|
+
* EnumRules describe the rules applied to `enum` values.
|
|
2010
2056
|
*
|
|
2011
2057
|
*/
|
|
2012
2058
|
export interface EnumRules {
|
|
@@ -2093,7 +2139,7 @@ export interface EnumRules {
|
|
|
2093
2139
|
notIn: number[];
|
|
2094
2140
|
/**
|
|
2095
2141
|
* `example` specifies values that the field may have. These values SHOULD
|
|
2096
|
-
* conform to other
|
|
2142
|
+
* conform to other rules. `example` values will not impact validation
|
|
2097
2143
|
* but may be used as helpful guidance on how to populate the given field.
|
|
2098
2144
|
*
|
|
2099
2145
|
* ```proto
|
|
@@ -2114,7 +2160,7 @@ export interface EnumRules {
|
|
|
2114
2160
|
}
|
|
2115
2161
|
export declare const EnumRules: MessageFns<EnumRules, "buf.validate.EnumRules">;
|
|
2116
2162
|
/**
|
|
2117
|
-
* RepeatedRules describe the
|
|
2163
|
+
* RepeatedRules describe the rules applied to `repeated` values.
|
|
2118
2164
|
*
|
|
2119
2165
|
*/
|
|
2120
2166
|
export interface RepeatedRules {
|
|
@@ -2153,7 +2199,7 @@ export interface RepeatedRules {
|
|
|
2153
2199
|
maxItems?: Long | undefined;
|
|
2154
2200
|
/**
|
|
2155
2201
|
* `unique` indicates that all elements in this field must
|
|
2156
|
-
* be unique. This
|
|
2202
|
+
* be unique. This rule is strictly applicable to scalar and enum
|
|
2157
2203
|
* types, with message types not being supported.
|
|
2158
2204
|
*
|
|
2159
2205
|
* ```proto
|
|
@@ -2166,13 +2212,13 @@ export interface RepeatedRules {
|
|
|
2166
2212
|
*/
|
|
2167
2213
|
unique?: boolean | undefined;
|
|
2168
2214
|
/**
|
|
2169
|
-
* `items` details the
|
|
2215
|
+
* `items` details the rules to be applied to each item
|
|
2170
2216
|
* in the field. Even for repeated message fields, validation is executed
|
|
2171
|
-
* against each item unless
|
|
2217
|
+
* against each item unless `ignore` is specified.
|
|
2172
2218
|
*
|
|
2173
2219
|
* ```proto
|
|
2174
2220
|
* message MyRepeated {
|
|
2175
|
-
* // The items in the field `value` must follow the specified
|
|
2221
|
+
* // The items in the field `value` must follow the specified rules.
|
|
2176
2222
|
* repeated string value = 1 [(buf.validate.field).repeated.items = {
|
|
2177
2223
|
* string: {
|
|
2178
2224
|
* min_len: 3
|
|
@@ -2182,12 +2228,15 @@ export interface RepeatedRules {
|
|
|
2182
2228
|
* }
|
|
2183
2229
|
* ```
|
|
2184
2230
|
*
|
|
2231
|
+
* Note that the `required` rule does not apply. Repeated items
|
|
2232
|
+
* cannot be unset.
|
|
2233
|
+
*
|
|
2185
2234
|
*/
|
|
2186
|
-
items?:
|
|
2235
|
+
items?: FieldRules | undefined;
|
|
2187
2236
|
}
|
|
2188
2237
|
export declare const RepeatedRules: MessageFns<RepeatedRules, "buf.validate.RepeatedRules">;
|
|
2189
2238
|
/**
|
|
2190
|
-
* MapRules describe the
|
|
2239
|
+
* MapRules describe the rules applied to `map` values.
|
|
2191
2240
|
*
|
|
2192
2241
|
*/
|
|
2193
2242
|
export interface MapRules {
|
|
@@ -2195,7 +2244,7 @@ export interface MapRules {
|
|
|
2195
2244
|
[unknownFieldsSymbol]?: Uint8Array | undefined;
|
|
2196
2245
|
[customJson]?: () => unknown;
|
|
2197
2246
|
/**
|
|
2198
|
-
*
|
|
2247
|
+
* Specifies the minimum number of key-value pairs allowed. If the field has
|
|
2199
2248
|
* fewer key-value pairs than specified, an error message is generated.
|
|
2200
2249
|
*
|
|
2201
2250
|
* ```proto
|
|
@@ -2208,7 +2257,7 @@ export interface MapRules {
|
|
|
2208
2257
|
*/
|
|
2209
2258
|
minPairs?: Long | undefined;
|
|
2210
2259
|
/**
|
|
2211
|
-
*
|
|
2260
|
+
* Specifies the maximum number of key-value pairs allowed. If the field has
|
|
2212
2261
|
* more key-value pairs than specified, an error message is generated.
|
|
2213
2262
|
*
|
|
2214
2263
|
* ```proto
|
|
@@ -2221,11 +2270,11 @@ export interface MapRules {
|
|
|
2221
2270
|
*/
|
|
2222
2271
|
maxPairs?: Long | undefined;
|
|
2223
2272
|
/**
|
|
2224
|
-
*
|
|
2273
|
+
* Specifies the rules to be applied to each key in the field.
|
|
2225
2274
|
*
|
|
2226
2275
|
* ```proto
|
|
2227
2276
|
* message MyMap {
|
|
2228
|
-
* // The keys in the field `value` must follow the specified
|
|
2277
|
+
* // The keys in the field `value` must follow the specified rules.
|
|
2229
2278
|
* map<string, string> value = 1 [(buf.validate.field).map.keys = {
|
|
2230
2279
|
* string: {
|
|
2231
2280
|
* min_len: 3
|
|
@@ -2235,16 +2284,18 @@ export interface MapRules {
|
|
|
2235
2284
|
* }
|
|
2236
2285
|
* ```
|
|
2237
2286
|
*
|
|
2287
|
+
* Note that the `required` rule does not apply. Map keys cannot be unset.
|
|
2288
|
+
*
|
|
2238
2289
|
*/
|
|
2239
|
-
keys?:
|
|
2290
|
+
keys?: FieldRules | undefined;
|
|
2240
2291
|
/**
|
|
2241
|
-
*
|
|
2292
|
+
* Specifies the rules to be applied to the value of each key in the
|
|
2242
2293
|
* field. Message values will still have their validations evaluated unless
|
|
2243
|
-
*
|
|
2294
|
+
* `ignore` is specified.
|
|
2244
2295
|
*
|
|
2245
2296
|
* ```proto
|
|
2246
2297
|
* message MyMap {
|
|
2247
|
-
* // The values in the field `value` must follow the specified
|
|
2298
|
+
* // The values in the field `value` must follow the specified rules.
|
|
2248
2299
|
* map<string, string> value = 1 [(buf.validate.field).map.values = {
|
|
2249
2300
|
* string: {
|
|
2250
2301
|
* min_len: 5
|
|
@@ -2253,13 +2304,14 @@ export interface MapRules {
|
|
|
2253
2304
|
* }];
|
|
2254
2305
|
* }
|
|
2255
2306
|
* ```
|
|
2307
|
+
* Note that the `required` rule does not apply. Map values cannot be unset.
|
|
2256
2308
|
*
|
|
2257
2309
|
*/
|
|
2258
|
-
values?:
|
|
2310
|
+
values?: FieldRules | undefined;
|
|
2259
2311
|
}
|
|
2260
2312
|
export declare const MapRules: MessageFns<MapRules, "buf.validate.MapRules">;
|
|
2261
2313
|
/**
|
|
2262
|
-
* AnyRules describe
|
|
2314
|
+
* AnyRules describe rules applied exclusively to the `google.protobuf.Any` well-known type.
|
|
2263
2315
|
*
|
|
2264
2316
|
*/
|
|
2265
2317
|
export interface AnyRules {
|
|
@@ -2274,7 +2326,9 @@ export interface AnyRules {
|
|
|
2274
2326
|
* ```proto
|
|
2275
2327
|
* message MyAny {
|
|
2276
2328
|
* // The `value` field must have a `type_url` equal to one of the specified values.
|
|
2277
|
-
* google.protobuf.Any value = 1 [(buf.validate.field).any
|
|
2329
|
+
* google.protobuf.Any value = 1 [(buf.validate.field).any = {
|
|
2330
|
+
* in: ["type.googleapis.com/MyType1", "type.googleapis.com/MyType2"]
|
|
2331
|
+
* }];
|
|
2278
2332
|
* }
|
|
2279
2333
|
* ```
|
|
2280
2334
|
*
|
|
@@ -2285,8 +2339,10 @@ export interface AnyRules {
|
|
|
2285
2339
|
*
|
|
2286
2340
|
* ```proto
|
|
2287
2341
|
* message MyAny {
|
|
2288
|
-
* //
|
|
2289
|
-
* google.protobuf.Any value = 1 [(buf.validate.field).any
|
|
2342
|
+
* // The `value` field must not have a `type_url` equal to any of the specified values.
|
|
2343
|
+
* google.protobuf.Any value = 1 [(buf.validate.field).any = {
|
|
2344
|
+
* not_in: ["type.googleapis.com/ForbiddenType1", "type.googleapis.com/ForbiddenType2"]
|
|
2345
|
+
* }];
|
|
2290
2346
|
* }
|
|
2291
2347
|
* ```
|
|
2292
2348
|
*
|
|
@@ -2295,7 +2351,7 @@ export interface AnyRules {
|
|
|
2295
2351
|
}
|
|
2296
2352
|
export declare const AnyRules: MessageFns<AnyRules, "buf.validate.AnyRules">;
|
|
2297
2353
|
/**
|
|
2298
|
-
* DurationRules describe the
|
|
2354
|
+
* DurationRules describe the rules applied exclusively to the `google.protobuf.Duration` well-known type.
|
|
2299
2355
|
*
|
|
2300
2356
|
*/
|
|
2301
2357
|
export interface DurationRules {
|
|
@@ -2347,7 +2403,7 @@ export interface DurationRules {
|
|
|
2347
2403
|
notIn: Duration[];
|
|
2348
2404
|
/**
|
|
2349
2405
|
* `example` specifies values that the field may have. These values SHOULD
|
|
2350
|
-
* conform to other
|
|
2406
|
+
* conform to other rules. `example` values will not impact validation
|
|
2351
2407
|
* but may be used as helpful guidance on how to populate the given field.
|
|
2352
2408
|
*
|
|
2353
2409
|
* ```proto
|
|
@@ -2378,7 +2434,85 @@ export interface DurationRules {
|
|
|
2378
2434
|
}
|
|
2379
2435
|
export declare const DurationRules: MessageFns<DurationRules, "buf.validate.DurationRules">;
|
|
2380
2436
|
/**
|
|
2381
|
-
*
|
|
2437
|
+
* FieldMaskRules describe rules applied exclusively to the `google.protobuf.FieldMask` well-known type.
|
|
2438
|
+
*
|
|
2439
|
+
*/
|
|
2440
|
+
export interface FieldMaskRules {
|
|
2441
|
+
$type: "buf.validate.FieldMaskRules";
|
|
2442
|
+
[unknownFieldsSymbol]?: Uint8Array | undefined;
|
|
2443
|
+
[customJson]?: () => unknown;
|
|
2444
|
+
/**
|
|
2445
|
+
* `const` dictates that the field must match the specified value of the `google.protobuf.FieldMask` type exactly.
|
|
2446
|
+
* If the field's value deviates from the specified value, an error message
|
|
2447
|
+
* will be generated.
|
|
2448
|
+
*
|
|
2449
|
+
* ```proto
|
|
2450
|
+
* message MyFieldMask {
|
|
2451
|
+
* // value must equal ["a"]
|
|
2452
|
+
* google.protobuf.FieldMask value = 1 [(buf.validate.field).field_mask.const = {
|
|
2453
|
+
* paths: ["a"]
|
|
2454
|
+
* }];
|
|
2455
|
+
* }
|
|
2456
|
+
* ```
|
|
2457
|
+
*
|
|
2458
|
+
*/
|
|
2459
|
+
const?: string[] | undefined;
|
|
2460
|
+
/**
|
|
2461
|
+
* `in` requires the field value to only contain paths matching specified
|
|
2462
|
+
* values or their subpaths.
|
|
2463
|
+
* If any of the field value's paths doesn't match the rule,
|
|
2464
|
+
* an error message is generated.
|
|
2465
|
+
* See: https://protobuf.dev/reference/protobuf/google.protobuf/#field-mask
|
|
2466
|
+
*
|
|
2467
|
+
* ```proto
|
|
2468
|
+
* message MyFieldMask {
|
|
2469
|
+
* // The `value` FieldMask must only contain paths listed in `in`.
|
|
2470
|
+
* google.protobuf.FieldMask value = 1 [(buf.validate.field).field_mask = {
|
|
2471
|
+
* in: ["a", "b", "c.a"]
|
|
2472
|
+
* }];
|
|
2473
|
+
* }
|
|
2474
|
+
* ```
|
|
2475
|
+
*
|
|
2476
|
+
*/
|
|
2477
|
+
in: string[];
|
|
2478
|
+
/**
|
|
2479
|
+
* `not_in` requires the field value to not contain paths matching specified
|
|
2480
|
+
* values or their subpaths.
|
|
2481
|
+
* If any of the field value's paths matches the rule,
|
|
2482
|
+
* an error message is generated.
|
|
2483
|
+
* See: https://protobuf.dev/reference/protobuf/google.protobuf/#field-mask
|
|
2484
|
+
*
|
|
2485
|
+
* ```proto
|
|
2486
|
+
* message MyFieldMask {
|
|
2487
|
+
* // The `value` FieldMask shall not contain paths listed in `not_in`.
|
|
2488
|
+
* google.protobuf.FieldMask value = 1 [(buf.validate.field).field_mask = {
|
|
2489
|
+
* not_in: ["forbidden", "immutable", "c.a"]
|
|
2490
|
+
* }];
|
|
2491
|
+
* }
|
|
2492
|
+
* ```
|
|
2493
|
+
*
|
|
2494
|
+
*/
|
|
2495
|
+
notIn: string[];
|
|
2496
|
+
/**
|
|
2497
|
+
* `example` specifies values that the field may have. These values SHOULD
|
|
2498
|
+
* conform to other rules. `example` values will not impact validation
|
|
2499
|
+
* but may be used as helpful guidance on how to populate the given field.
|
|
2500
|
+
*
|
|
2501
|
+
* ```proto
|
|
2502
|
+
* message MyFieldMask {
|
|
2503
|
+
* google.protobuf.FieldMask value = 1 [
|
|
2504
|
+
* (buf.validate.field).field_mask.example = { paths: ["a", "b"] },
|
|
2505
|
+
* (buf.validate.field).field_mask.example = { paths: ["c.a", "d"] },
|
|
2506
|
+
* ];
|
|
2507
|
+
* }
|
|
2508
|
+
* ```
|
|
2509
|
+
*
|
|
2510
|
+
*/
|
|
2511
|
+
example: string[][];
|
|
2512
|
+
}
|
|
2513
|
+
export declare const FieldMaskRules: MessageFns<FieldMaskRules, "buf.validate.FieldMaskRules">;
|
|
2514
|
+
/**
|
|
2515
|
+
* TimestampRules describe the rules applied exclusively to the `google.protobuf.Timestamp` well-known type.
|
|
2382
2516
|
*
|
|
2383
2517
|
*/
|
|
2384
2518
|
export interface TimestampRules {
|
|
@@ -2411,7 +2545,7 @@ export interface TimestampRules {
|
|
|
2411
2545
|
within?: Duration | undefined;
|
|
2412
2546
|
/**
|
|
2413
2547
|
* `example` specifies values that the field may have. These values SHOULD
|
|
2414
|
-
* conform to other
|
|
2548
|
+
* conform to other rules. `example` values will not impact validation
|
|
2415
2549
|
* but may be used as helpful guidance on how to populate the given field.
|
|
2416
2550
|
*
|
|
2417
2551
|
* ```proto
|
|
@@ -2449,7 +2583,7 @@ export interface TimestampRules {
|
|
|
2449
2583
|
export declare const TimestampRules: MessageFns<TimestampRules, "buf.validate.TimestampRules">;
|
|
2450
2584
|
/**
|
|
2451
2585
|
* `Violations` is a collection of `Violation` messages. This message type is returned by
|
|
2452
|
-
*
|
|
2586
|
+
* Protovalidate when a proto message fails to meet the requirements set by the `Rule` validation rules.
|
|
2453
2587
|
* Each individual violation is represented by a `Violation` message.
|
|
2454
2588
|
*
|
|
2455
2589
|
*/
|
|
@@ -2466,15 +2600,46 @@ export interface Violations {
|
|
|
2466
2600
|
export declare const Violations: MessageFns<Violations, "buf.validate.Violations">;
|
|
2467
2601
|
/**
|
|
2468
2602
|
* `Violation` represents a single instance where a validation rule, expressed
|
|
2469
|
-
* as a `
|
|
2470
|
-
* caused the violation, the specific
|
|
2603
|
+
* as a `Rule`, was not met. It provides information about the field that
|
|
2604
|
+
* caused the violation, the specific rule that wasn't fulfilled, and a
|
|
2471
2605
|
* human-readable error message.
|
|
2472
2606
|
*
|
|
2607
|
+
* For example, consider the following message:
|
|
2608
|
+
*
|
|
2609
|
+
* ```proto
|
|
2610
|
+
* message User {
|
|
2611
|
+
* int32 age = 1 [(buf.validate.field).cel = {
|
|
2612
|
+
* id: "user.age",
|
|
2613
|
+
* expression: "this < 18 ? 'User must be at least 18 years old' : ''",
|
|
2614
|
+
* }];
|
|
2615
|
+
* }
|
|
2616
|
+
* ```
|
|
2617
|
+
*
|
|
2618
|
+
* It could produce the following violation:
|
|
2619
|
+
*
|
|
2473
2620
|
* ```json
|
|
2474
2621
|
* {
|
|
2475
|
-
* "
|
|
2476
|
-
* "
|
|
2477
|
-
* "
|
|
2622
|
+
* "ruleId": "user.age",
|
|
2623
|
+
* "message": "User must be at least 18 years old",
|
|
2624
|
+
* "field": {
|
|
2625
|
+
* "elements": [
|
|
2626
|
+
* {
|
|
2627
|
+
* "fieldNumber": 1,
|
|
2628
|
+
* "fieldName": "age",
|
|
2629
|
+
* "fieldType": "TYPE_INT32"
|
|
2630
|
+
* }
|
|
2631
|
+
* ]
|
|
2632
|
+
* },
|
|
2633
|
+
* "rule": {
|
|
2634
|
+
* "elements": [
|
|
2635
|
+
* {
|
|
2636
|
+
* "fieldNumber": 23,
|
|
2637
|
+
* "fieldName": "cel",
|
|
2638
|
+
* "fieldType": "TYPE_MESSAGE",
|
|
2639
|
+
* "index": "0"
|
|
2640
|
+
* }
|
|
2641
|
+
* ]
|
|
2642
|
+
* }
|
|
2478
2643
|
* }
|
|
2479
2644
|
* ```
|
|
2480
2645
|
*
|
|
@@ -2507,9 +2672,9 @@ export interface Violation {
|
|
|
2507
2672
|
*/
|
|
2508
2673
|
field?: FieldPath | undefined;
|
|
2509
2674
|
/**
|
|
2510
|
-
* `rule` is a machine-readable path that points to the specific
|
|
2511
|
-
* This will be a nested field starting from the
|
|
2512
|
-
* For custom
|
|
2675
|
+
* `rule` is a machine-readable path that points to the specific rule that failed validation.
|
|
2676
|
+
* This will be a nested field starting from the FieldRules of the field that failed validation.
|
|
2677
|
+
* For custom rules, this will provide the path of the rule, e.g. `cel[0]`.
|
|
2513
2678
|
*
|
|
2514
2679
|
* For example, consider the following message:
|
|
2515
2680
|
*
|
|
@@ -2517,7 +2682,7 @@ export interface Violation {
|
|
|
2517
2682
|
* message Message {
|
|
2518
2683
|
* bool a = 1 [(buf.validate.field).required = true];
|
|
2519
2684
|
* bool b = 2 [(buf.validate.field).cel = {
|
|
2520
|
-
* id: "
|
|
2685
|
+
* id: "custom_rule",
|
|
2521
2686
|
* expression: "!this ? 'b must be true': ''"
|
|
2522
2687
|
* }]
|
|
2523
2688
|
* }
|
|
@@ -2539,23 +2704,14 @@ export interface Violation {
|
|
|
2539
2704
|
*/
|
|
2540
2705
|
rule?: FieldPath | undefined;
|
|
2541
2706
|
/**
|
|
2542
|
-
* `
|
|
2543
|
-
* This
|
|
2544
|
-
*
|
|
2545
|
-
* Deprecated: use the `field` instead.
|
|
2546
|
-
*
|
|
2547
|
-
* @deprecated Deprecated.
|
|
2548
|
-
*/
|
|
2549
|
-
fieldPath?: string | undefined;
|
|
2550
|
-
/**
|
|
2551
|
-
* `constraint_id` is the unique identifier of the `Constraint` that was not fulfilled.
|
|
2552
|
-
* This is the same `id` that was specified in the `Constraint` message, allowing easy tracing of which rule was violated.
|
|
2707
|
+
* `rule_id` is the unique identifier of the `Rule` that was not fulfilled.
|
|
2708
|
+
* This is the same `id` that was specified in the `Rule` message, allowing easy tracing of which rule was violated.
|
|
2553
2709
|
*
|
|
2554
2710
|
*/
|
|
2555
|
-
|
|
2711
|
+
ruleId?: string | undefined;
|
|
2556
2712
|
/**
|
|
2557
2713
|
* `message` is a human-readable error message that describes the nature of the violation.
|
|
2558
|
-
* This can be the default error message from the violated `
|
|
2714
|
+
* This can be the default error message from the violated `Rule`, or it can be a custom message that gives more context about the violation.
|
|
2559
2715
|
*
|
|
2560
2716
|
*/
|
|
2561
2717
|
message?: string | undefined;
|
|
@@ -2659,22 +2815,22 @@ export declare const FieldPathElement: MessageFns<FieldPathElement, "buf.validat
|
|
|
2659
2815
|
import "../../google/protobuf/index";
|
|
2660
2816
|
declare module '../../google/protobuf/index' {
|
|
2661
2817
|
interface MessageOptions {
|
|
2662
|
-
message?:
|
|
2818
|
+
message?: MessageRules;
|
|
2663
2819
|
}
|
|
2664
2820
|
}
|
|
2665
2821
|
declare module '../../google/protobuf/index' {
|
|
2666
2822
|
interface OneofOptions {
|
|
2667
|
-
oneof?:
|
|
2823
|
+
oneof?: OneofRules;
|
|
2668
2824
|
}
|
|
2669
2825
|
}
|
|
2670
2826
|
declare module '../../google/protobuf/index' {
|
|
2671
2827
|
interface FieldOptions {
|
|
2672
|
-
field?:
|
|
2828
|
+
field?: FieldRules;
|
|
2673
2829
|
}
|
|
2674
2830
|
}
|
|
2675
2831
|
declare module '../../google/protobuf/index' {
|
|
2676
2832
|
interface FieldOptions {
|
|
2677
|
-
predefined?:
|
|
2833
|
+
predefined?: PredefinedRules;
|
|
2678
2834
|
}
|
|
2679
2835
|
}
|
|
2680
2836
|
export {};
|