Skip to main content

Typanion

Type-safe runtime type validation with no dependencies

ts
import * as t from 'typanion';
 
const isPort = t.cascade(t.isNumber(), [
t.isInteger(),
t.isInInclusiveRange(1, 65535),
]);
 
if (isPort(value)) {
server.listen(value);
}
ts
import * as t from 'typanion';
 
const isPort = t.cascade(t.isNumber(), [
t.isInteger(),
t.isInInclusiveRange(1, 65535),
]);
 
if (isPort(value)) {
server.listen(value);
}

TypeScript integration

Typanion provides strong type inference; if your validator functions pass, TypeScript will refine values accordingly.

Feature complete

Despite being very small, Typanion supports error messages, coercions, and various utilities outside of pure JSON validation.

Tree-shakeable

Typanion uses a functional approach that lends itself very well to being optimized away by most bundlers.