Skip to content

AnyOf Pattern doesn't work when fields are optional and array #72

@kak-bo-che

Description

@kak-bo-che
import "list"

#test: this={
	a?:        [...string]
	b?:        string
	c?:        string
	#AnyOfABC: true & list.MinItems([ for label, val in this if list.Contains(["a", "b", "c"], label) {label}], 1)
}
{
	"a": ["bar"],
	"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

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions