class-validator

Decorator-based property validation for TypeScript and JavaScript classes, on both Node.js and the browser.

Library
npm
v0.15.1
11,824stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
49/100Fair
Development Activity8
Maintenance20
Community68
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
86/100Excellent
Architecture85
Code Quality85
Innovation90
Learning Curve80

class-validator lets you attach validation rules directly to class properties using TypeScript decorators such as @IsEmail, @Length, and @Min, then validate instances with a single call. It ships more than a hundred built-in constraint decorators and, internally, delegates string checks to the battle-tested validator.js library.

Beyond simple property checks it supports nested-object validation, conditional rules, validation groups, custom decorators, whitelisting of unknown properties, and both asynchronous and synchronous validation. It works the same way in the browser and in Node.js, and integrates cleanly with frameworks like NestJS and dependency-injection containers.

What You Get

  • 100+ ready-made constraint decorators covering strings, numbers, dates, arrays, sets, maps, and common formats (email, URL, UUID, phone, and more)
  • Structured ValidationError results that report the target, property, offending value, and per-constraint messages, including nested children
  • Advanced validation features: nested objects, validation groups, conditional validation, whitelisting, and custom validators and decorators
  • Both async (validate/validateOrReject) and sync (validateSync) APIs that run identically in Node.js and the browser

Common Use Cases

  • Validating incoming request DTOs in a NestJS or Express API before they reach business logic
  • Enforcing shape and format on user-submitted form data on the client side
  • Guarding configuration or message payloads against malformed values in shared browser/Node code

Under The Hood

Architecture The public surface in src/index.ts exposes thin validate/validateOrReject/validateSync helpers that instantiate a Validator and delegate to a ValidationExecutor (src/validation/ValidationExecutor.ts). Decorators register constraint metadata into a global MetadataStorage (src/metadata/MetadataStorage.ts) at class-definition time; at validation time the executor reads that metadata, resolves each constraint through an IoC container (src/container.ts, overridable via useContainer for DI frameworks), runs the constraints, collects async work into an awaitingPromises list, and builds nested ValidationError trees. This metadata-plus-executor split cleanly separates declaration from execution.

Tech Stack Written almost entirely in TypeScript (99.8% of the source). Runtime dependencies are minimal: validator.js for the underlying string checks and libphonenumber-js for phone validation. It builds to CommonJS, ESM5, ES2015, and UMD bundles via tsc and Rollup, so it consumes cleanly in bundlers and Node alike. reflect-metadata is used for decorator metadata.

Code Quality The repo has a substantial test suite: 15 spec files including a large functional test directory (validation-functions-and-decorators, whitelist-validation, custom-decorators, promise-validation, inherited-validation, sync-validation) run under Jest with coverage. Code is consistently typed, ESLint- and Prettier-enforced, and organized by decorator family under src/decorator/. Nine runnable samples document real usage patterns.

API Design The developer experience is a core strength: decorators read almost like documentation on the property they guard, getting started needs only an import and an annotation, and the 100+ decorators follow a consistent Is*/@Min/@Max naming scheme. The README is extensive, covering options, custom decorators, groups, and framework integration, making the learning curve gentle for the common cases.

Used by 23 apps in this directory

TypeScript
72%
AGPL 3.0

APITable

Low Code Platforms · Databases

15,526

API-first collaborative spreadsheet-database platform that auto-generates REST APIs and lets teams build internal tools, CRMs, and dashboards without code.

View details
53
Repo Health
77
Technical
60
Dependency
Built with
TypeScript72%
Java22%
Updated 9 months ago
TypeScript
96%
Other

Amplication

Developer Tools · AI Code Assistants · Automation

16,010

Create production-ready backend services with your organization's standards baked in — generating NestJS, Prisma, and GraphQL code that you own and control.

View details
61
Repo Health
84
Technical
60
Dependency
Built with
TypeScript96%
Updated 1 months ago
TypeScript
97%
AGPL 3.0

Bigcapital

Invoicing Finance

3,846

Self-hostable double-entry accounting platform with invoicing, inventory, multi-currency, and real-time financial reporting for small and medium businesses.

View details
91
Repo Health
77
Technical
64
Dependency
Built with
TypeScript97%
Updated yesterday
TypeScript
96%
Other

Cal.diy

Scheduling

47,796

The 100% MIT-licensed, community-driven scheduling platform — self-host your own booking infrastructure with no enterprise strings attached.

View details
93
Repo Health
86
Technical
66
Dependency
Built with
TypeScript96%
Updated 1 weeks ago
TypeScript
95%
AGPL 3.0

Docmost

Productivity · Note Taking · Collaboration

21,411

Self-hosted collaborative wiki and knowledge base with real-time editing, diagrams, AI assistance, and enterprise access controls — a modern alternative to Confluence and Notion.

View details
89
Repo Health
70
Technical
71
Dependency
Built with
TypeScript95%
Updated yesterday
TypeScript
74%
AGPL 3.0

Ghostfolio

Invoicing Finance

9,153

Track your stocks, ETFs, and crypto with a privacy-first, self-hostable wealth management platform built for data-driven investors.

View details
93
Repo Health
79
Technical
71
Dependency
Built with
TypeScript74%
HTML23%
Updated yesterday
TypeScript
98%
Other

Hexabot

AI Development · Automation

1,186

Build and run agentic workflows across channels with YAML, tools, and RAG

View details
79
Repo Health
76
Technical
70
Dependency
Built with
TypeScript98%
Updated yesterday
TypeScript
95%
AGPL 3.0

HeyForm

Forms Surveys · No Code Platforms

8,938

Open-source conversational form builder with AI generation, conditional logic, and 30+ integrations — self-host with full data ownership.

View details
86
Repo Health
67
Technical
69
Dependency
Built with
TypeScript95%
Updated today
TypeScript
71%
Other

highlight.io

Developer Tools · Analytics · Monitoring

9,367

Open-source full-stack monitoring that unifies session replay, error tracking, logging, and distributed tracing so you can stop context-switching between tools.

View details
69
Repo Health
78
Technical
66
Dependency
Built with
TypeScript71%
Go16%
Updated yesterday

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search