Toolbox-XToolbox-X
GuardsPrimitive Type Guards

Composite Type Guards

Runtime type guards to validate composite primitive values.

Runtime type guards to validate composite primitive values.

Imports

import { isPrimitive, isNormalPrimitive, isNonEmptyString, isFalsy, isTruthy } from 'toolbox-x/guards';

isPrimitive

Validates if a value is a JavaScript primitive. It covers string | number | boolean | symbol | bigint | null | undefined

Signature

isPrimitive(value: unknown): value is Primitive

Examples

playground.ts

isNormalPrimitive

Validates if a value is a normal JavaScript primitive. It covers string | number | boolean | null | undefined

Signature

isNormalPrimitive(value: unknown): value is NormalPrimitive

Examples

playground.ts

isNonEmptyString

Validates if a value is a non-empty string.

Signature

function isNonEmptyString(value: unknown): value is string

Examples

playground.ts

isFalsy

Validates if a value is falsy.

Signature

isFalsy(value: unknown): value is FalsyPrimitive

Examples

playground.ts

isTruthy

Validates if a value is truthy.

Signature

isTruthy<T>(value: T): value is Exclude<T, FalsyPrimitive>

Examples

playground.ts

Last updated: Sat, Jun 06, 2026 09:29:26AM (UTC)

On this page