predictype / predicates/strings/stringMembership / stringMembership
stringMembership(
source
,oper
,target
):boolean
Defined in: predicates/strings/stringMembership.ts:26
Checks if a string is (or is not) a member of a set of strings using the specified operation.
string
The string to check.
The membership operation to perform (e.g. ‘in’, ‘not_in’).
string
[]
The array of strings to check membership against.
boolean
True if the membership check is valid according to the operator, otherwise false.
If the operation is not recognized.
const arr = ['foo', 'bar'];
const value1 = 'foo';
const value2 = 'baz';
stringMembership(value1, 'in', arr); // true
stringMembership(value2, 'not_in', arr); // true
Supported Operators: