predictype

predictype v0.8.1


predictype / predicates/dates/dateState / dateState

Function: dateState()

dateState(source, oper): boolean

Defined in: predicates/dates/dateState.ts:34

Checks the state of a date (valid or invalid) in UTC using the specified operation.

Parameters

source

Date

The date to check.

oper

DateStateOper

The state operation to perform (e.g. ‘is_valid’, ‘is_invalid’).

Returns

boolean

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

Throws

If the operation is not recognized.

Example

const validDate = new Date('2025-01-01');
const invalidDate = new Date('invalid');

dateState(validDate, 'is_valid'); // true
dateState(invalidDate, 'is_invalid'); // true

Remarks

Supported Operators: