predictype

predictype v0.8.1


predictype / predicates/strings / stringComparison

Function: stringComparison()

stringComparison(source, oper, target): boolean

Defined in: predicates/strings/stringComparison.ts:27

Compares two strings using the specified operation.

Parameters

source

string

The first string.

oper

StringComparisonOper

The comparison operation to perform (e.g. ‘equals’, ‘greater_than’).

target

string

The second string.

Returns

boolean

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

Throws

If the operation is not recognized.

Example

const a = 'foo';
const b = 'bar';

stringComparison(a, 'greater_than', b); // true
stringComparison(a, 'equals', a); // true

Remarks

Supported Operators: