Skip to content

Allow "type guards" in VRL #91

Open
@jszwedko

Description

@jszwedko

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 if is_string was true.

Specifically, they had:

is_string(.message) && !contains(.message, s'test')

But you could also imagine this with if conditions:

if is_string(.message) {
 !contains(.message, s'test')
} else {
  false
}

I'm not 100% sold on if we want to do this, but opening for discussion.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: enhancementA value-adding code change that enhances its existing functionalityvrl: typedefChanges to the type system

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions