| 1 | ===Record Validation=== |
| 2 | |
| 3 | {{{ |
| 4 | type structure_enclosure = { |
| 5 | 'type' : string with match(self, 'blade|dumb|hypervisor') |
| 6 | 'children' : string[1..] with is_profile_list(self) |
| 7 | 'maxchildren' ? long(1..) |
| 8 | } with { |
| 9 | if (exists(self['maxchildren'])) { |
| 10 | self['maxchildren'] >= length(self['children']); |
| 11 | } else { |
| 12 | true; |
| 13 | }; |
| 14 | }; |
| 15 | }}} |
| 16 | |
| 17 | For the older compiler (v6) you must define an intermediate type as a 'with' clause on a record definition is not valid in the older compiler. |
| 18 | |
| 19 | That is, |
| 20 | |
| 21 | {{{ |
| 22 | type structure_enclosure = { |
| 23 | 'type' : string with match(self, 'blade|dumb|hypervisor') |
| 24 | 'children' : string[1..] with is_profile_list(self) |
| 25 | 'maxchildren' ? long(1..) |
| 26 | } with { |
| 27 | if (exists(self['maxchildren'])) { |
| 28 | self['maxchildren'] >= length(self['children']); |
| 29 | } else { |
| 30 | true; |
| 31 | }; |
| 32 | }; |
| 33 | |
| 34 | type validated_structure_enclosure = |
| 35 | structure_enclosure with { |
| 36 | if (exists(self['maxchildren'])) { |
| 37 | self['maxchildren'] >= length(self['children']); |
| 38 | } else { |
| 39 | true; |
| 40 | }; |
| 41 | }; |
| 42 | }}} |
| 43 | |