-
Notifications
You must be signed in to change notification settings - Fork 8
3. Recursivity
Selene edited this page Mar 30, 2023
·
1 revision
Cuetsy allows structural cycles based on the same rules than Cuelang. In summary, all values should have a "stop" condition to be a valid cue schema.
CUE | TypeScript |
---|---|
Recursive: {
simpleNode: null | Recursive
list: [...Recursive]
map: [string]: Recursive
optionalNode?: Recursive
} @cuetsy(kind="interface") |
export interface Recursive {
list: Array<Recursive>;
map: Record<string, Recursive>;
optionalNode?: Recursive;
simpleNode: Recursive;
} |
In the example, simpleNode
is a union with a null
value that it's necessary to add to have the stop condition. Otherwise, cue fails in the validation step.
Lists, maps and optionals could be null by default and its why null
isn't necessary here.