-
-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AnyOf Pattern doesn't work when fields are optional and array #72
Comments
yeah, I never tested that. There are better solutions on the horizon in https://cuetorials.com/cueology/futurology/builtin-helpers/ |
Changing the list to non-optional only works because the empty list will have a label and the constraint will pass as the label is always available. The underlying issue seems to be that the simplified example as given in the tutorial doesn't seem to work when providing data to validate instead of embedding it in the definition: test.cueimport "list"
#test: this={
a?: string
b?: string
c?: string
#AnyOfABC: true & list.MinItems([ for label, _ in this if list.Contains(["a", "b", "c"], label) {label}], 1)
} test.json{
"b": "foo"
} cue eval -c ./test.cue ./testany.json -d "#test"
#test.#AnyOfABC: conflicting values false and true:
./test.cue:7:13
./test.cue:7:20 |
I think this is because So I suspect there are some scoping complexities at play here. The optional list works with the example from the page: https://cuelang.org/play/?id=yDm35mVv9iR#cue@export@cue |
changing from array a to string works or changing the array field from optional to default works as well. This is slightly outside of the content of the page, bug a simple derivative.
The text was updated successfully, but these errors were encountered: