Condition on optional field #3360
Answered
by
slewiskelly
MichaelStetner
asked this question in
Q&A
-
I'm trying to validate some YAML that looks like this:
The rules are:
I tried writing the following cue to validate it:
This works fine as long as "employed" is present. So the example at the top validates, and so does this:
But I get an error when I try to validate this:
The error message from
Is there something I could write in cue to make this validate? |
Beta Was this translation helpful? Give feedback.
Answered by
slewiskelly
Aug 8, 2024
Replies: 1 comment 1 reply
-
Either of the following should work: #Person: {
name: string
} | {
name: string
employed: bool
if employed == true {
jobtitle: string
}
} #Person: {
name: string
employed?: bool
if employed != _|_ {
if employed == true {
jobtitle: string
}
}
} |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
MichaelStetner
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Either of the following should work: