Overview
Semantic type guards check whether a value represents a specific meaningful concept in JavaScript: such as dates, errors, timestamps, or JSON‑compatible data. These helpers validate semantics rather than primitive type or structure, returning simple booleans with no side effects.
- isDate: Checks whether a value is a
Dateinstance. - isEnumValue: Checks whether a value is a valid member of a TypeScript enum.
- isError: Checks whether a value is an
Errorinstance. - isFunction: Checks whether a value is a function.
- isHexString: Checks whether a value is a valid hexadecimal string.
- isJSON: Checks whether a value is valid JSON data (objects, arrays, or JSON primitives).
- isKeyOf: Checks whether a value is a valid key of a given object or record type.
- isPlainFunction: Checks whether a value is a non‑class, non‑generator, non‑async plain function.
- isPort: Checks whether a value is a valid TCP/UDP port number.
- isRegExp: Checks whether a value is a
RegExpinstance. - isTimestamp: Checks whether a value is a valid Unix timestamp (milliseconds since epoch).
- isURL: Checks whether a value is a valid URL instance or URL‑parsable string.
- isUUID: Checks whether a value is a valid UUID (v1–v5).
- isValueOf: Checks whether a value is one of the allowed values of a given object or enum‑like structure.
All semantic guards are pure, predictable, and safe to use before normalization or validation.