nvie/decoders
Fork: 29 Star: 440 (更新于 2026-04-08 07:31:55)
license: MIT
Language: TypeScript .
Elegant validation library for type-safe input data for TypeScript
最后发布版本: v2.9.3 ( 2026-04-08 04:46:10)

Elegant and battle-tested validation library for type-safe input data for TypeScript.
Basic example
import { array, isoDate, number, object, optional, string } from 'decoders';
// Incoming data at runtime, e.g. the request body
// The point is that this data is untrusted and its type unknown
const externalData = {
id: 123,
name: 'Alison Roberts',
createdAt: '2026-01-11T12:26:37.024Z',
tags: ['foo', 'bar'],
};
// Write the decoder (= what you expect the data to look like)
const userDecoder = object({
id: number,
name: string,
createdAt: optional(isoDate),
tags: array(string),
});
// Call .verify() on the incoming data
const user = userDecoder.verify(externalData);
// ^^^^
// TypeScript will infer this type as:
// {
// id: number;
// name: string;
// createdAt?: Date;
// tags: string[];
// }
Installation
npm install decoders
Requirements
You must set strict: true in your tsconfig.json in order for type inference to work
correctly!
// tsconfig.json
{
"compilerOptions": {
"strict": true
}
}
Documentation
Documentation can be found on decoders.cc.
There is a dedicated page that explains how to build your own decoders.
最近版本更新:(数据更新于 2026-04-08 07:31:38)
2026-04-08 04:46:10 v2.9.3
2026-03-31 05:22:07 v2.9.2
2026-03-11 22:40:33 v2.9.1
2026-03-09 05:09:55 v2.9.0
2026-03-06 21:04:42 v2.9.0-pre.5
2026-02-22 21:42:57 v2.8.0
2025-09-03 03:47:00 v2.7.5
2025-09-03 00:05:32 v2.7.4
2025-09-02 23:30:09 v2.7.3
2025-09-01 23:29:18 v2.7.2
主题(topics):
browser, bun, cloudflare-workers, javascript, nodejs, schema-validation, typescript
nvie/decoders同语言 TypeScript最近更新仓库
2026-04-19 02:40:58 bbc/sqs-producer
2026-04-18 19:46:48 ueberdosis/tiptap
2026-04-18 14:23:51 lobehub/lobehub
2026-04-18 13:48:48 thunderbird/thunderbolt
2026-04-18 13:23:09 simstudioai/sim
2026-04-18 10:46:33 TanStack/table
