predictype

predictype v0.8.1


predictype / predicates/strings/stringSubstring / stringSubstring

Function: stringSubstring()

stringSubstring(source, oper, target): boolean

Defined in: predicates/strings/stringSubstring.ts:26

Checks if a string contains, excludes, starts with, or ends with a substring using the specified operation.

Parameters

source

string

The string to check.

oper

StringSubstringOper

The substring operation to perform (e.g. ‘includes’, ‘starts_with’).

target

string

The substring to check for.

Returns

boolean

True if the substring check is valid according to the operator, otherwise false.

Throws

If the operation is not recognized.

Example

const str = 'foobar';

stringSubstring(str, 'includes', sub); // true
stringSubstring(str, 'starts_with', sub); // true

Remarks

Supported Operators: