Skip to content

Commit 29a21da

Browse files
authored
Merge pull request #33659 from macno/patch-1
Update Validation Rules Examples
2 parents 0fa1da9 + 9d08caf commit 29a21da

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

content/en/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -811,14 +811,15 @@ Validation Rules Examples:
811811
| `'Available' in self.stateCounts` | Validate that an entry with the 'Available' key exists in a map |
812812
| `(size(self.list1) == 0) != (size(self.list2) == 0)` | Validate that one of two lists is non-empty, but not both |
813813
| <code>!('MY_KEY' in self.map1) &#124;&#124; self['MY_KEY'].matches('^[a-zA-Z]*$')</code> | Validate the value of a map for a specific key, if it is in the map |
814-
| `self.envars.filter(e, e.name = 'MY_ENV').all(e, e.value.matches('^[a-zA-Z]*$')` | Validate the 'value' field of a listMap entry where key field 'name' is 'MY_ENV' |
814+
| `self.envars.filter(e, e.name == 'MY_ENV').all(e, e.value.matches('^[a-zA-Z]*$')` | Validate the 'value' field of a listMap entry where key field 'name' is 'MY_ENV' |
815815
| `has(self.expired) && self.created + self.ttl < self.expired` | Validate that 'expired' date is after a 'create' date plus a 'ttl' duration |
816816
| `self.health.startsWith('ok')` | Validate a 'health' string field has the prefix 'ok' |
817817
| `self.widgets.exists(w, w.key == 'x' && w.foo < 10)` | Validate that the 'foo' property of a listMap item with a key 'x' is less than 10 |
818818
| `type(self) == string ? self == '100%' : self == 1000` | Validate an int-or-string field for both the the int and string cases |
819819
| `self.metadata.name.startsWith(self.prefix)` | Validate that an object's name has the prefix of another field value |
820820
| `self.set1.all(e, !(e in self.set2))` | Validate that two listSets are disjoint |
821821
| `size(self.names) == size(self.details) && self.names.all(n, n in self.details)` | Validate the 'details' map is keyed by the items in the 'names' listSet |
822+
| `size(self.clusters.filter(c, c.name == self.primary)) == 1` | Validate that the 'primary' property has one and only one occurrence in the 'clusters' listMap |
822823

823824
Xref: [Supported evaluation on CEL](https://github.com/google/cel-spec/blob/v0.6.0/doc/langdef.md#evaluation)
824825

0 commit comments

Comments
 (0)