-
Notifications
You must be signed in to change notification settings - Fork 77
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
Allow "type guards" in VRL #91
Comments
see also: vectordotdev/vector#5261 (comment) |
(Just to leave a comment reflecting my use case) I think this kind of expression shortcutting is both common and expected in many contexts. However, the real value is in the separation of concerns. The example in the OP is good:
This is essentially: "if the message conforms to my expectations, then evaluate some expression that relies on those expectations", where these two parts are decoupled and explicitly defined. Relying on coercion and failure handling instead makes things messy or unclear (at least, it certainly is less clear to me, being less familiar with the intricate details of VRL). From discord, for example:
So this solution is both more verbose and still not complete and correct. A solution like All in all, given that properties which don't exist are "null", then the expression |
I believe we've discussed this in other places before as well, but it came up again in vectordotdev/vector#9406 where a user expected that if they used
is_string()
that VRL would be able to determine that the argument thereafter was a string if the rest of the expression only executed ifis_string
was true.Specifically, they had:
But you could also imagine this with
if
conditions:I'm not 100% sold on if we want to do this, but opening for discussion.
The text was updated successfully, but these errors were encountered: