Extract all list items matching a template #4245
-
|
I have a list of items, Example input: The expected output should be |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
|
You can use a comparison of the unified result and bottom ( If you combine this with the switch pattern, you can create a type switch but note that your schema currently does not require the field If you need the result of that field to be concrete, you can either:
The latter two options would produce the output you want. |
Beta Was this translation helpful? Give feedback.
The key is testing
(close(o) & #MyType) != _|_: https://cuelang.org/play/?id=BmdBQCRUbsv#w=function&i=cue&f=export&o=cueHere I add
Output: [...#MyType]constraint because the if expression evaluation does not propagate the constraint toOutput. But becauseclose(o)is omitted cue fails while evaluating it for output:The confusion here is that by default cue doesn't require open structs to pass all validations until they are actually output by the top level because the user might end up unifying the result with something else that fixes it later. You can…