cue vet and json.Validate behave differently #842
Replies: 6 comments 7 replies
-
This does not match what I see. To get the error you describe, you have to supply the Are you doing the equivalent in the Go version? |
Beta Was this translation helpful? Give feedback.
-
Hey @verdverm. Thank you for your response. You're correct. For the
There is no error reported. However, if the
It will error out: |
Beta Was this translation helpful? Give feedback.
-
You probably want to do something like:
I suspect that you have an non-existent value after your lookup. You could also try making the key |
Beta Was this translation helpful? Give feedback.
-
@dinhxuanvu I've migrated this to be a discussion because I'm not clear there's an issue/bug right now, given what's described above. We can of course create issues for bugs/other that come from this discussion. |
Beta Was this translation helpful? Give feedback.
-
See also the #822. In general, people seem to want the behavior of ignoring inconcrete values when exporting, and instead be explicit if a value should be required. This is because in large APIs most fields tend to be optional. |
Beta Was this translation helpful? Give feedback.
-
This discussion has been migrated to cue-lang/cue#842. For more details about CUE's migration to a new home, please see cue-lang/cue#1078. |
Beta Was this translation helpful? Give feedback.
-
What version of CUE are you using (
cue version
)?Does this issue reproduce with the latest release?
Yes
What did you do?
I have a cue file with some definitions and a JSON file that I would like to run validation against the constraints that are specified in that cue file. I use both cue CLI and cue library to perform this task.
schema.cue
test.json
What did you expect to see?
I would expect both cue CLI and library would behave the same in term of validation.
What did you see instead?
When I run
cue vet test.json schema.cue
, it will complainname: incomplete value !=""
as expected. However, when I useValidate(b []byte, v cue.Value)
fromencoding/json
in go code, there is no error.I wonder if this is expected behavior or a bug.
Beta Was this translation helpful? Give feedback.
All reactions