-
Notifications
You must be signed in to change notification settings - Fork 139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for data values schema without defaults #556
Comments
Hey @redbaron 👋🏻 Yes! This is a use-case we're looking to tackle in an upcoming track of work: Schema Validations. (epic: #561) We're still working out the details, but this case could be handled like so: #@schema/nullable
#@schema/validate not_null=True
connector: "" That is:
What do you think? |
Great stuff! Why there is a |
cannot be null
because from a type system perspective there are 2 valid types: string OR null (vs other fields that may only support type string -- or some other type). however, we do not want to allow values to be null, hence the validation. this option however is not somethign we would recommend for most uses... (jump to next section)
id like to push back on this assumption -- can you provide some concrete examples. example i can think of is asking users for aws secret key. the type of the key is string (it can only be string; it can never be null; in Go this would be |
App name, passwords, references to other resources, API enpoints of dependencies, etc.
Seems that, you do it in validation because type system is not expressive enough. Allowing null at the type level , just to reject in in validation later is a bit confusing, but maybe it is a good compromise. Maybe extending type system can help to simplify this corner case (not sure it is worth it, just throwing an idea):
then data value internally becomes following:
allowing you distinguish betwen 3 possible states:
|
that's exactly my point though, in reasonably powerful type system above is |
OK got it, you are saying that it is possible to bypass null state and just check the value directly. Generally speaking what I want is to require user to provide variable value. We can approximate it by checking that final value, after all overlays computed is not equal to default , this wont catch case when user provides a value equal to default, but I can think where it can become a problem. I can see it workig for strings, but what about numbers? How this would work for non scalar variables? Lets say I expect user to provide a struct (map with known keys), do I resort to Also, what error message user is going to see? If it comes from validation, it'll say that value doesn't pass validation, which is not as good as "please provide this value", especially as app evolves and users apply new version using old values file. Overall, I can see how validation can be used to approximate required variables and it is great to have this feature, however having dedicated
If you keep current type system same, |
I'm getting, @redbaron, that the key point here is having a quality UX... both for those who are reading the schema, itself; and for those who get the error messages from running with such a schema. 👍🏻 I'm thinking we can get there from here with some thoughtful choices: As @cppforlife pointed out, above, authors will want to specify constraints anyway. If we can craft error messages around zero-values that could read well for both cases, that might be a good balance (given that adding both the specific constraint/validation and Example: #@data/values-schema
---
appName: ""
#@schema/nullable
#@schema/validate not_null=True
db_conn:
host: ""
#@schema/validate min=1025 max=65535
port: 0
username: ""
password: ""
db_name: "" where:
More generically:
|
I am facing same situation again, started to google just to find my own issue :) Another idea might be to allow type to be set by annotation:
here we declare type, but provide impossible (because there is no |
Thank you for the bump, @redbaron. Great news: release v0.43.0 is eminent — in it, the Data Values Validation feature will become Generally Available. Your use case: wanting to require the end-user to supply a Data Value is the top use case. Here's the relevant docs in draft. We're in the final stages; can't commit to a timeline, but we're talking days, not weeks. If you wanted to kick the tires right now, much of this functionality is in experimental mode in v0.42.0. Check out our blog post that announced the preview. |
EDIT: There was a typo in the annotation name ( Discard the rest. I was also looking into that and think it is worth reporting that it doesn't seem to work for me.
I'd expect an error, because |
Thanks for the report @Zebradil.
Yeah, we've had (short) conversations about this in the past: #114 There's some ambiguity left in that conversation; worth circling back to see if we can't have a more consistent+cohesive approach (and better user experience). |
Describe the problem/challenge you have
Some data values don't have sensible defaults and I'd like template users to always provide them
Describe the solution you'd like
Maybe special value for
@schema/default
annotation , which would indicate that there is no deafult value at all? Schema is then used to define just type of the value, expecting template user to always provide it.Anything else you would like to add:
Currently it can be simulated with assert, but it is too verbose.
Vote on this request
This is an invitation to the community to vote on issues, to help us prioritize our backlog. Use the "smiley face" up to the right of this comment to vote.
👍 "I would like to see this addressed as soon as possible"
👎 "There are other more important things to focus on right now"
We are also happy to receive and review Pull Requests if you want to help working on this issue.
The text was updated successfully, but these errors were encountered: