is.object({ ... })
Validates that a value is a plain object whose fields satisfy the provided shape. Fields not listed in the shape are allowed by default.
Helpers
.strict — disallows extra keys not listed in the shape.
.partial — makes all fields optional (T | undefined).
.pick([keys]) — keeps only the listed keys.
.omit([keys]) — removes the listed keys from the shape.
.extend({ ... }) — merges additional fields into the shape. Returns a new guard.
is.array(guard?)
Validates that a value is an array. Pass one or more element guards to validate every item.
Helpers
| Helper | Validates |
|---|---|
.min(n) | Length ≥ n |
.max(n) | Length ≤ n |
.length(n) | Exact length of n |
.nonEmpty | Length ≥ 1 |
is.record(keyGuard, valueGuard)
Validates that a value is a plain object where every key and value satisfies the provided guards.
When keyGuard has a finite set of values (is.enum or is.literal), the record performs exhaustive key checking — all keys must be present and no extra keys are allowed. This matches TypeScript’s Record<'a' | 'b', V> semantics.
When keyGuard is open-ended (is.string, is.number), it validates that every existing key/value pair satisfies the guards without requiring any specific keys.
.partial makes all enum/literal keys optional.
is.tuple([...], restGuard?)
Validates a fixed-length array where each position has its own guard. Pass a second argument to allow variadic trailing elements.
is.union(...), is.intersection(...), is.xor(...)
is.union(...guards) — passes if the value satisfies at least one guard.
is.intersection(...guards) — passes if the value satisfies all guards.
is.xor(...guards) — passes if the value satisfies exactly one guard.
is.templateLiteral(...)
Validates that a string matches a template literal pattern. Accepts a mix of string segments and guards for interpolated positions.
Built-in type guards
is.date
Validates a Date instance.
| Helper | Validates |
|---|---|
.before(date) | Date is before the given date |
.after(date) | Date is after the given date |
.startOf(unit) | Transformer — truncates to start of 'year', 'month', 'day', etc. |
is.regexp
Validates a RegExp instance. Optionally validates against a specific pattern.
is.url
Validates a URL instance (not a string — use is.string.url for strings).
is.map(keyGuard?, valueGuard?)
Validates a Map instance with optional key and value guards.
is.set(valueGuard?)
Validates a Set instance with an optional value guard.
is.promise
Validates any thenable (has a .then method).
is.error
Validates an Error instance.
| Helper | Validates |
|---|---|
.message(str) | Error message equals str |
.name(str) | Error name equals str |
is.file
Validates a File or Blob instance.
| Helper | Validates |
|---|---|
.type(mimeType) | MIME type matches |
.maxSize(bytes) | File size ≤ bytes |
Custom and chas-specific guards
is.custom(fn)
Creates a guard from any predicate function. Use a TypeScript type predicate for full narrowing, or pass a generic type parameter.
is.result()
Guards a Result<T, E> value from the ts-chas result module.
is.option()
Guards an Option<T> value.
is.tagged(factory)
Guards tagged errors created with defineErrs.