You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/en/docs/reference/using-api/declarative-validation.md
+47-47Lines changed: 47 additions & 47 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -70,30 +70,30 @@ This document provides a comprehensive reference for all available declarative v
70
70
71
71
| Tag | Description |
72
72
| --- | --- |
73
-
|[`+k8s:eachKey`](#k8seachkey)| Declares a validation for each key in a map. |
74
-
|[`+k8s:eachVal`](#k8seachval)| Declares a validation for each value in a map or list. |
75
-
|[`+k8s:enum`](#k8senum)| Indicates that a string type is an enum. |
76
-
|[`+k8s:forbidden`](#k8sforbidden)| Indicates that a field may not be specified. |
77
-
|[`+k8s:format`](#k8sformat)| Indicates that a string field has a particular format. |
78
-
|[`+k8s:ifDisabled`](#k8sifdisabled)| Declares a validation that only applies when an option is disabled. |
79
-
|[`+k8s:ifEnabled`](#k8sifenabled)| Declares a validation that only applies when an option is enabled. |
80
-
|[`+k8s:immutable`](#k8simmutable)| Indicates that a field may not be updated. |
81
-
|[`+k8s:isSubresource`](#k8sissubresource)| Specifies that validations in a package only apply to a specific subresource. |
82
-
|[`+k8s:item`](#k8sitem)| Declares a validation for an item of a slice declared as a `+k8s:listType=map`. |
83
-
|[`+k8s:listMapKey`](#k8slistmapkey)| Declares a named sub-field of a list's value-type to be part of the list-map key. |
84
-
|[`+k8s:listType`](#k8slisttype)| Declares a list field's semantic type. |
85
-
|[`+k8s:maxItems`](#k8smaxitems)| Indicates that a list field has a limit on its size. |
86
-
|[`+k8s:maxLength`](#k8smaxlength)| Indicates that a string field has a limit on its length. |
87
-
|[`+k8s:minimum`](#k8sminimum)| Indicates that a numeric field has a minimum value. |
88
-
|[`+k8s:neq`](#k8sneq)| Verifies the field's value is not equal to a specific disallowed value. |
89
-
|[`+k8s:opaqueType`](#k8sopaquetype)| Indicates that any validations declared on the referenced type will be ignored. |
90
-
|[`+k8s:optional`](#k8soptional)| Indicates that a field is optional to clients. |
91
-
|[`+k8s:required`](#k8srequired)| Indicates that a field must be specified by clients. |
92
-
|[`+k8s:subfield`](#k8ssubfield)| Declares a validation for a subfield of a struct. |
93
-
|[`+k8s:supportsSubresource`](#k8ssupportssubresource)| Declares a supported subresource for the types within a package. |
94
-
|[`+k8s:unionDiscriminator`](#k8suniondiscriminator)| Indicates that this field is the discriminator for a union. |
95
-
|[`+k8s:unionMember`](#k8sunionmember)| Indicates that this field is a member of a union. |
96
-
|[`+k8s:zeroOrOneOfMember`](#k8szerooroneofmember)| Indicates that this field is a member of a zero-or-one-of union. |
73
+
|[`+k8s:eachKey`](#tag-eachKey)| Declares a validation for each key in a map. |
74
+
|[`+k8s:eachVal`](#tag-eachVal)| Declares a validation for each value in a map or list. |
75
+
|[`+k8s:enum`](#tag-enum)| Indicates that a string type is an enum. |
76
+
|[`+k8s:forbidden`](#tag-forbidden)| Indicates that a field may not be specified. |
77
+
|[`+k8s:format`](#tag-format)| Indicates that a string field has a particular format. |
78
+
|[`+k8s:ifDisabled`](#tag-ifDisabled)| Declares a validation that only applies when an option is disabled. |
79
+
|[`+k8s:ifEnabled`](#tag-ifEnabled)| Declares a validation that only applies when an option is enabled. |
80
+
|[`+k8s:immutable`](#tag-immutable)| Indicates that a field may not be updated. |
81
+
|[`+k8s:isSubresource`](#tag-isSubresource)| Specifies that validations in a package only apply to a specific subresource. |
82
+
|[`+k8s:item`](#tag-item)| Declares a validation for an item of a slice declared as a `+k8s:listType=map`. |
83
+
|[`+k8s:listMapKey`](#tag-listMapKey)| Declares a named sub-field of a list's value-type to be part of the list-map key. |
84
+
|[`+k8s:listType`](#tag-listType)| Declares a list field's semantic type. |
85
+
|[`+k8s:maxItems`](#tag-maxItems)| Indicates that a list field has a limit on its size. |
86
+
|[`+k8s:maxLength`](#tag-maxLength)| Indicates that a string field has a limit on its length. |
87
+
|[`+k8s:minimum`](#tag-minimum)| Indicates that a numeric field has a minimum value. |
88
+
|[`+k8s:neq`](#tag-neq)| Verifies the field's value is not equal to a specific disallowed value. |
89
+
|[`+k8s:opaqueType`](#tag-opaqueType)| Indicates that any validations declared on the referenced type will be ignored. |
90
+
|[`+k8s:optional`](#tag-optional)| Indicates that a field is optional to clients. |
91
+
|[`+k8s:required`](#tag-required)| Indicates that a field must be specified by clients. |
92
+
|[`+k8s:subfield`](#tag-subfield)| Declares a validation for a subfield of a struct. |
93
+
|[`+k8s:supportsSubresource`](#tag-supportsSubresource)| Declares a supported subresource for the types within a package. |
94
+
|[`+k8s:unionDiscriminator`](#tag-unionDiscriminator)| Indicates that this field is the discriminator for a union. |
95
+
|[`+k8s:unionMember`](#tag-unionMember)| Indicates that this field is a member of a union group. |
96
+
|[`+k8s:zeroOrOneOfMember`](#tag-zeroOrOneOfMember)| Indicates that this field is a member of a zero-or-one-of group. |
97
97
98
98
---
99
99
@@ -120,7 +120,7 @@ type MyObject struct {
120
120
121
121
In this example, `eachKey` is used to specify that the `+k8s:minimum` tag should be applied to each `int` key in `MyMap`. This means that all keys in the map must be >= 1.
122
122
123
-
### `+k8s:eachVal`
123
+
### `+k8s:eachVal` {#tag-eachVal}
124
124
125
125
**Description:**
126
126
@@ -141,7 +141,7 @@ type MyObject struct {
141
141
142
142
In this example, `eachVal` is used to specify that the `+k8s:minimum` tag should be applied to each element in `MyList`. This means that all fields in `MyStruct` must be >= 1.
143
143
144
-
### `+k8s:enum`
144
+
### `+k8s:enum` {#tag-enum}
145
145
146
146
**Description:**
147
147
@@ -171,7 +171,7 @@ type MyObject struct {
171
171
172
172
The validation logic will ensure that `MyField` is one of the defined enum values (`"A"` or `"B"`).
173
173
174
-
### `+k8s:forbidden`
174
+
### `+k8s:forbidden` {#tag-forbidden}
175
175
176
176
**Description:**
177
177
@@ -188,7 +188,7 @@ type MyObject struct {
188
188
189
189
In this example, `MyField` cannot be provided (it is forbidden) when creating or updating `MyObject`.
190
190
191
-
### `+k8s:format`
191
+
### `+k8s:format` {#tag-format}
192
192
193
193
**Description:**
194
194
@@ -220,7 +220,7 @@ In this example:
220
220
*`Subdomain` must be a valid DNS subdomain.
221
221
*`Label` must be a valid DNS label.
222
222
223
-
### `+k8s:ifDisabled`
223
+
### `+k8s:ifDisabled` {#tag-ifDisabled}
224
224
225
225
**Description:**
226
226
@@ -245,7 +245,7 @@ type MyObject struct {
245
245
246
246
In this example, `MyField` is required only if the "my-feature" option is disabled.
247
247
248
-
### `+k8s:ifEnabled`
248
+
### `+k8s:ifEnabled` {#tag-ifEnabled}
249
249
250
250
**Description:**
251
251
@@ -270,7 +270,7 @@ type MyObject struct {
270
270
271
271
In this example, `MyField` is required only if the "my-feature" option is enabled.
272
272
273
-
### `+k8s:isSubresource`
273
+
### `+k8s:isSubresource` {#tag-isSubresource}
274
274
275
275
**Description:**
276
276
@@ -310,7 +310,7 @@ type T1 struct {
310
310
}
311
311
```
312
312
313
-
### `+k8s:item`
313
+
### `+k8s:item` {#tag-item}
314
314
315
315
**Description:**
316
316
@@ -348,7 +348,7 @@ In this example:
348
348
* The item with `name` "http" and `port` 80 is immutable.
349
349
* The item with `name` "https" and `port` 443 is required.
350
350
351
-
### `+k8s:listMapKey`
351
+
### `+k8s:listMapKey` {#tag-listMapKey}
352
352
353
353
**Description:**
354
354
@@ -375,7 +375,7 @@ type MyStruct struct {
375
375
376
376
In this example, `listMapKey` is used to specify that the `keyField` of `MyStruct` should be used as the key for the list-map.
377
377
378
-
### `+k8s:listType`
378
+
### `+k8s:listType` {#tag-listType}
379
379
380
380
**Description:**
381
381
@@ -402,7 +402,7 @@ type MyStruct struct {
402
402
403
403
In this example, `MyList` is declared as a list of type `map`, with `keyField` as the key. This means that the validation logic will ensure that each element in the list has a unique `keyField`.
404
404
405
-
### `+k8s:maxItems`
405
+
### `+k8s:maxItems` {#tag-maxItems}
406
406
407
407
**Description:**
408
408
@@ -423,7 +423,7 @@ type MyObject struct {
423
423
424
424
In this example, `MyList` cannot contain more than 5 items.
425
425
426
-
### `+k8s:maxLength`
426
+
### `+k8s:maxLength` {#tag-maxLength}
427
427
428
428
**Description:**
429
429
@@ -444,7 +444,7 @@ type MyObject struct {
444
444
445
445
In this example, `MyString` cannot be longer than 10 characters.
446
446
447
-
### `+k8s:minimum`
447
+
### `+k8s:minimum` {#tag-minimum}
448
448
449
449
**Description:**
450
450
@@ -465,7 +465,7 @@ type MyObject struct {
465
465
466
466
In this example, `MyInt` must be greater than or equal to 0.
467
467
468
-
### `+k8s:neq`
468
+
### `+k8s:neq` {#tag-neq}
469
469
470
470
**Description:**
471
471
@@ -495,7 +495,7 @@ In this example:
495
495
*`MyInt` cannot be equal to `0`.
496
496
*`MyBool` cannot be equal to `true`.
497
497
498
-
### `+k8s:opaqueType`
498
+
### `+k8s:opaqueType` {#tag-opaqueType}
499
499
500
500
**Description:**
501
501
@@ -514,7 +514,7 @@ type MyObject struct {
514
514
515
515
In this example, any validation tags on `package.ExternalType` will be ignored.
516
516
517
-
### `+k8s:optional`
517
+
### `+k8s:optional` {#tag-optional}
518
518
519
519
**Description:**
520
520
@@ -531,7 +531,7 @@ type MyObject struct {
531
531
532
532
In this example, `MyField` is not required to be provided when creating or updating `MyObject`.
533
533
534
-
### `+k8s:required`
534
+
### `+k8s:required` {#tag-required}
535
535
536
536
**Description:**
537
537
@@ -548,7 +548,7 @@ type MyObject struct {
548
548
549
549
In this example, `MyField` must be provided when creating or updating `MyObject`.
550
550
551
-
### `+k8s:subfield`
551
+
### `+k8s:subfield` {#tag-subfield}
552
552
553
553
**Description:**
554
554
@@ -577,7 +577,7 @@ type MyStruct struct {
577
577
578
578
In this example, `MySubfield` within `MyStruct` is required.
In this example, the package `v1` declares that the `/status` and `/scale` subresources are supported, allowing validation rules to be specifically targeted to them.
In this example, the `Type` field is the discriminator for the union. The value of `Type` will determine which of the union members (`A` or `B`) is expected to be present.
632
632
633
-
### `+k8s:unionMember`
633
+
### `+k8s:unionMember` {#tag-unionMember}
634
634
635
635
**Description:**
636
636
@@ -658,7 +658,7 @@ type MyObject struct {
658
658
659
659
In this example, `A` and `B` are members of the union. If the `Type` field has the value `"a"`, then the `a` field is expected to be present. If the `Type` field has the value `"b-member"`, then the `b` field is expected to be present.
0 commit comments