predictype

predictype v0.8.1


predictype / predicates/strings/stringState / stringState

Function: stringState()

stringState(source, oper): boolean

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

Checks the state of a string (empty, not empty, blank, not blank) using the specified operation.

Parameters

source

string

The string to check.

oper

StringStateOper

The state operation to perform (e.g. ‘is_empty’, ‘is_not_blank’).

Returns

boolean

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

Throws

If the operation is not recognized.

Example

const str = '';
const str2 = '   ';

stringState(str, 'is_empty'); // true
stringState(str2, 'is_blank'); // true

Remarks

Supported Operators: