Skip to content

in

Description

Return true if a given value matches any value in a list of candidates, otherwise return false.

Syntax

Like many functions in DataPrime, in supports two notations, function and method notation. These interchangeable forms allow flexibility in how you structure expressions.

in(comparand: any, value: any, ...values: any): bool
(comparand: any).in(value: any, ...values: any): bool

Arguments

NameTypeRequiredDescription
comparandanytrueThe value to check
valueanytrueThe first candidate to compare against
...valuesanytrueAdditional candidates to compare against

Example

Use case: Flag membership in a predefined group

A team name can be compared against a list of department members to determine if it belongs to Engineering.

{
    "team": "Developers"
},
{
    "team": "Marketing"
},
{
    "team": "QA Testing"
}
create is_in_engineering from in(team, 'Developers', 'QA Testing', 'Front End Engineers', 'DevOps Team')
create is_in_engineering from team.in('Developers', 'QA Testing', 'Front End Engineers', 'DevOps Team')

Output

{
    "team": "Developers",
    "is_in_engineering": true
},
{
    "team": "Marketing",
    "is_in_engineering": false
},
{
    "team": "QA Testing",
    "is_in_engineering": true
}