Unable to raise exception after checking a specific condition #2224
Replies: 2 comments 1 reply
-
I suppose you could do something like: if len(a) > 0 {
_err: _|_
} But it wouldn't be an encouraged pattern. I think maybe you are trying employ concepts and techniques from imperative, general-purpose, programming languages that don't apply to CUE. In CUE, you would add a constrain to specify that Using your specific example, you could use either of the following: a: [] import "list"
a: [...string] & list.MaxItems(0) a: [...string]
_ok: true & len(a) < 1 Choosing one over the other would depend on a specific situation, but the first two are likely suitable for the majority of cases. |
Beta Was this translation helpful? Give feedback.
-
@debuggerrr can you provide a bit more information about what you're trying to do here? How/where are you using CUE? In a policy setting? |
Beta Was this translation helpful? Give feedback.
-
I want to raise an issue for suppose below example:
if len(a)>0 { raise exception }
How can be it done using CUE? I didn't find any specific example w.r.t raising an exception.
Beta Was this translation helpful? Give feedback.
All reactions