Replies: 1 comment 1 reply
-
@roylisto you are running up against one the use cases that motivated #822. So for now what you want to do is not possible. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Validate() function will not return any error if I validate the empty yaml file by cue definition.
I would like to expect Validate() function to throw an error like "a key is required"
for example
test.cue
apiVersion: "v1"
Here is my test case so far
if I validate it by empty yaml file or omit the apiVersion key, currently it won't return any error (not expected)
if I put apiVersion: v2 in the yaml file, it will returns
apiVersion: conflicting values "v1" and "v2"
(expected)if I change the cue validation to be
apiVersion: string
and omit the key from yaml file, it will returnsapiVersion: incomplete value string
, this is expected but the value I want is v1. By this approach, people can write any value to apiVersion, and I don't want thatThe last approach is by using regex, so
apiVersion: =~"^v1$"
, by this way, now it will check my "required" value and will returnsapiVersion: incomplete value =~"^v1$"
if I omit the key, and will returnsapiVersion: invalid value "v2" (out of bound =~"^v1$")
when I put v2 as apiVersion valueThe question is my approach correct? or is there a better way?
Beta Was this translation helpful? Give feedback.
All reactions