The value to check against the type guard
true if the value is of type T, false otherwise
Creates a type guard for an intersection of types
Shorthand for isIntersection
Creates a type guard for T[]
Shorthand for isArray
Creates a type guard for Record<PropertyKey, T>
Shorthand for isIndexRecord
Creates a type guard for T | null.
Shorthand for isMaybe
Creates a type guard for T | undefined.
Shorthand for isOptional
Creates a type guard for a union of types
Shorthand for isUnion
Creates a type guard for Set<T>
Shorthand for isSet
Creates a zod schema equivalent to this type guard.
You must have zod installed to use this feature.
The supported versions of zod start with zod@3.20.0 and end with zod@5.0.0 (not included)
Important
The schema returned by .zod() might not exactly represent the guarded type in certain edge cases.
For example: isNumber(NaN) returns true while z.number() marks NaN as invalid.
The differences vary between zod versions, but these are the most common:
NaN, Infinity, -Infinity) are valid when using isguard-ts but invalid when using zod.zod ignores symbol property keys while isguard-ts doesn't.
Represents a type guard function that checks if a value is of type
T. Type guards are functions that return a boolean indicating whether the input value matches the expected type. This type includes methods for chaining type guards to create more complex validations.Example