-
Notifications
You must be signed in to change notification settings - Fork 0
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
Support for checking existence of objects #1
Comments
Checking the existence of fields can be done following the same pattern, even the same API. It's a tiny bit awkward, though. We can have a "checking selector" which returns false if the field doesn't exist or modifier applied to it, if it does.
Ofc. something similar applied to arrays is also possible. Then it could be used as:
It's (expectedly) awkward to use change interface for checking if fields exist - there's this
In this case strings would mean to |
Currently I see the following kinds of operations besides current "strict modification".
Each of them can follow the same selector/modifier pattern, but it potentially warrants its own default meaning of strings and numbers. I'm also afraid they don't necessarily need to play together very well, i.e. it's not immediately clear to me what is going to happen when checking selectors and modifying selectors are mixed and if it makes sense at all. Perhaps we could check and prohibit that or perhaps it is actually useful. Well, mixing just strict and nonstrict variants of the same thing, e.g. strict getting of one field and safe getting of another definitely makes sense. So another classification is that we have strict and non-strict versions of:
Perhaps checking can be eliminated (or reduced to a convenience method) by checking if safe indexing found any values. |
The need for this was mentioned here:
https://groups.google.com/d/msg/jsonnet/4gaCg_l3ZsA/NeGpAgIGCAAJ
And here:
https://groups.google.com/forum/#!topic/jsonnet/1nEJOYmS78I
Related:
The text was updated successfully, but these errors were encountered: