#mandatory fields
1 messages · Page 1 of 1 (latest)
I think you would reference the field if
There's still something I don't get, sorry: can you please enumerate all the cases you want to considerate with the two fields ?
field1is mandatory,field2is optional
Example:
- if
field1andfield2are set - If
field1is set andfield2not set
What am I missing ?
If field 1 and field2 are set I’ll go with field2 and ignore field 1 but I don’t want to allow both field 1 and field2 are missing
If field1 is set I’ll derive field2 that’s ok
I don’t want to set field1 mandatory - I want user to have a choice to set field2 and ignore field1
Using a third field is the way to go ? https://cuelang.org/play/?id=pcrHnRCxmPp#cue@export@cue
Oh, so the two would be optional
Yes!
But we both are missing - I can’t proceed in that case I’d like to throw error
the only way i see is to fix is yo handle it in script. 🙃
By always referencing the result key, it would error in case neither f1 and f2 are not concrete
The key is to use a third variable always referenced and whose concreteness is conditional on the concreteness of the two. Would that work ?
Ah! That makes sense.
If I refer the third variable then it’ll just say I can’t find variable ist it ? How would I tell the user the variables are missing ?
Cue does it by design, at evaluation time (and we have some heuristics too)
When evaluating the plan, we check if the key is not to be filled by the runtime, if it is not, then we make sure it is concrete. Otherwise it fails (pre-run)
With pleasure, don't hesitate to ping 😇