Replies: 1 comment 3 replies
-
Maybe just me, but I find it better to specify a definition explicitly with the A slightly modified schema: -- in.yaml --
kind: Attribute
specs:
- key: TEST
name: testing
archived: false
description: Attribute used to test a provider
-- schema.cue --
import "strings"
#Flag: {
name: strings.MinRunes(1)
description?: string
key: strings.MinRunes(1)
value: strings.MinRunes(1)
}
#Attribute: {
archived?: bool | *false
description?: string
name: strings.MinRunes(1)
key: strings.MinRunes(1)
}
#In: {
kind: "Attribute"
specs: [#Attribute, ...#Attribute]
} | {
kind: "Flag"
specs: [#Flag, ...#Flag]
} Seems to work as you expect, when specifying the specific definition to validate against: $ cue vet -d '#In' schema.cue in.yaml
$ sed -i '' 's/kind: Attribute/kind: Flag/' in.yaml
$ cue vet -d '#In' schema.cue in.yaml
2 errors in empty disjunction:
kind: conflicting values "Attribute" and "Flag":
./in.yaml:1:8
./schema.cue:18:8
specs.0: field not allowed: archived:
./in.yaml:5:6
./schema.cue:3:8
./schema.cue:17:6
./schema.cue:22:10 |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
With the following schema:
When will I validate this yaml:
I have this error:
And I need the spec list to be dynamic according to the kind value. Can you help me?
Beta Was this translation helpful? Give feedback.
All reactions