Skip to content
Discussion options

You must be logged in to vote

The key is testing (close(o) & #MyType) != _|_: https://cuelang.org/play/?id=BmdBQCRUbsv#w=function&i=cue&f=export&o=cue

Here I add Output: [...#MyType] constraint because the if expression evaluation does not propagate the constraint to Output. But because close(o) is omitted cue fails while evaluating it for output:

Output: [...#MyType]
Output: [for o in Input if (o & #MyType) != _|_ {o}]

->

Output.1.x: field is required but not present:
    -:9:3

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…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@JensRantil
Comment options

@deepbrook
Comment options

@infogulch
Comment options

Answer selected by JensRantil
@JensRantil
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants