"Hashmaps" are not evaluated properly? #2328
-
It seems like that hashmaps constraints What version of CUE are you using (
|
Beta Was this translation helpful? Give feedback.
Replies: 10 comments
-
What command are you running? (there are some guidelines here for creating reproducers: https://github.com/cue-lang/cue/wiki/Creating-test-or-performance-reproducers) It looks enforced to me: https://cuelang.org/play/?id=gfsCb0vmY2h#cue@def@cue I suspect you are using a |
Beta Was this translation helpful? Give feedback.
-
I am sorry, I made a mistake in the original post. It is supposed to be:
I will now edit the original post. here.
I used
which should be rejected because it's an empty hashmap. |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
I switched to:
And it didn't change that the example JSON I provided is not rejected, I think? |
Beta Was this translation helpful? Give feedback.
-
I think there is an understanding gap here. The following is expected output, but does not mean that the constraints are not enforced. You can see this by providing invalid input I would recommend using
I also think you may have an extra level of nesting that is not actually needed or wanted, if I understand the data shape you want. |
Beta Was this translation helpful? Give feedback.
-
Thank you for your patience, I am sorry if I am having trouble expressing myself, but I tried to provide invalid input: The Therefore, I don't think the constraints are enforced.
Understood. |
Beta Was this translation helpful? Give feedback.
-
There are a number of inconsistencies between the various examples you have provided. A complete, working reproducer would be helpful |
Beta Was this translation helpful? Give feedback.
-
Schemaimport "struct"
#BootspecV1: {
system: string
init: string
initrd?: string
initrdSecrets?: string
kernel: string
kernelParams: [...string]
label: string
toplevel: string
}
// A restricted document does not allow any official specialisation
// information in it to avoid "recursive specialisations".
#RestrictedDocument: {
"org.nixos.bootspec.v1": #BootspecV1
[=~"^"]: #BootspecExtension
}
// Specialisations are a hashmap of strings
#BootspecSpecialisationV1: [string]: struct.MinFields(1) & #RestrictedDocument
// Bootspec extensions are defined by the extension author.
#BootspecExtension: {...}
// A "full" document allows official specialisation information
// in the top-level with a reserved namespaced key.
Document: #RestrictedDocument & {
"org.nixos.specialisation.v1"?: #BootspecSpecialisationV1
} Invalid input which is considered as valid{
"org.nixos.bootspec.v1": {
"init": "a",
"kernel": "b",
"label": "c",
"system": "d",
"toplevel": "e"
},
"org.nixos.bootspec.specialisation.v1": {
"work": {}
}
} Reproducer invocation$ cue vet invalid.json schema.cue -d 'Document' |
Beta Was this translation helpful? Give feedback.
-
You still have typos in your example, those top level Document fields do not match |
Beta Was this translation helpful? Give feedback.
-
Thank you so much, I am sorry for making you waste your time! |
Beta Was this translation helpful? Give feedback.
cue def
is your friend, it will show you more of the structure: https://cuelang.org/play/?id=glUCheCIw0H#cue@def@cueYou still have typos in your example, those top level Document fields do not match