class-validator
Reasonable, with limits. 7th of 10 validation libraries.
class-validator checks class instances with decorators such as @IsString and @IsEmail. The NestJS docs still use it, but it does not infer types from a schema, it depends on legacy decorators, and its maintenance is thin. It is a reasonable pick inside NestJS, but for most new projects Zod or Valibot is the better choice.
Best for: NestJS teams that want DTO classes with the built-in ValidationPipe and the patterns in the official docs.
Scores
Overall5.6
How strongly do we recommend it for a new project today?
Claude Opus 5.5: 5.0, likely 4.0 to 6.0
Inside NestJS it is still a working, documented and familiar default, so it stays reasonable there. Outside that niche, Zod, Valibot and ArkType give type inference, plain-data validation and active maintenance, and NestJS 12 now accepts them directly. Thin maintenance and a falling share keep it in the middle of the category.
- peers downloads ratio: Grows slower than Zod and Valibot and below the median
- dev.to/x4nent/nestjs-12-deep-dive-full-esm-migration-standard-schema-route-validation-and-the-4fe0: Standard Schema in NestJS 12 removes its lock-in
- dev.to/young_gao/input-validation-in-typescript-apis-zod-vs-joi-vs-class-validator-2gcg: Independent comparison of the API validation options
GPT-6.2 Sol: 6.1, likely 5.0 to 7.2
Class-validator is a reasonable choice for new NestJS modules that already use decorated DTOs, where its built-in checks and framework integration save setup. For most new validation work, Zod offers simpler parsing of plain data and derives TypeScript types from the rules. Slow maintenance and below-baseline download growth lower the recommendation, while ongoing framework support keeps the class-based choice viable.
- docs.nestjs.com/application/validation: Compares the supported class-based and schema-based validation workflows.
- github.com/immich-app/immich/releases/tag/v3.0.0: Documents a production project's move to Zod.
- github.commitsLastYear, npm.latestPublishedAt, peers Zod commitsLastYear and latestPublishedAt: Class-validator was substantially less active than Zod in the supplied snapshot.
- npm.downloadsLast4Weeks, npm.downloadsSame4WeeksYearAgo, medianDownloadsRatio: Relative download share declined despite a rise in raw installs.
Needed by many4.8
How many developers need a tool for this job?
Claude Opus 5.5: 5.0, likely 4.0 to 6.0
Most JS and TS developers need a validator, but this decorator-and-class approach fits mainly backends built with classes, above all NestJS. It needs the legacy TypeScript decorator setting, and it suits frontend forms or plain-object code poorly. That makes its audience narrower than the category's.
- github description: Decorator-based property validation for classes
- wildandfreetools.com/blog/zod-vs-class-validator-nestjs: Its strongest fit is the NestJS ValidationPipe
- dev.to/young_gao/input-validation-in-typescript-apis-zod-vs-joi-vs-class-validator-2gcg: Compared mainly for backend API input validation
GPT-6.2 Sol: 4.6, likely 3.5 to 5.7
Runtime validation is useful across APIs, forms, and configuration, but this library's main workflow serves developers who model data as decorated classes. It runs in Node.js and browsers and has integrations beyond NestJS. The share of JavaScript and TypeScript developers who prefer class-based validation is hard to measure.
- github.com/typestack/class-validator: Supports Node.js and browsers, with class instances required for decorator-based validation.
- docs.nestjs.com/application/validation: Documents the class-based and schema-based request validation workflows.
- typegraphql.com/docs/validation.html: Supports decorator-based validation of GraphQL arguments and inputs.
Helps a lot6.0
How well does it do the job for those who need it?
Claude Opus 5.5: 5.0, likely 4.0 to 6.0
It has a broad set of validators, nested validation, groups and custom constraints, and it integrates tightly with NestJS. But it does not infer types, it needs class-transformer to turn plain objects into classes, synthetic benchmarks show it slower than Zod, and some defaults such as forbidUnknownValues have surprised users. AI agents write it well because NestJS examples are everywhere.
- wildandfreetools.com/blog/zod-vs-class-validator-nestjs: Zod gives better inference and is faster in simple benchmarks
- dev.to/abdulghofurme/zod-vs-class-validator-class-transformer-3oam: Hard to share schemas between client and server
- raw.githubusercontent.com/typestack/class-validator/HEAD/CHANGELOG.md: forbidUnknownValues became the default in 0.14; IsIBAN signature changed in 0.15.1
GPT-6.2 Sol: 6.9, likely 5.7 to 8.0
Version 0.15.1 offers a broad set of checks, custom async rules, and structured errors with configurable messages. It uses declared class types, and nested JSON needs explicit transformation and validation setup that developers and coding agents can miss. A user reported that validation gets slower as more decorated classes are registered, and benchmark results depend on the payload and transformation setup.
- github.com/typestack/class-validator: Documents built-in checks, custom constraints, validation errors, and nested class requirements.
- docs.nestjs.com/application/validation: Shows runtime class import requirements and schema-derived typing in the alternative pipe.
- github.com/moltar/typescript-runtime-type-benchmarks: Independent benchmark suite tests class-validator together with class-transformer.
- github.com/typestack/class-validator/issues/2686: User reports per-call metadata lookup cost that grows with the number of decorated classes.
Holds up over time4.4
Will it still be a good choice in two years?
Claude Opus 5.5: 4.0, likely 3.0 to 5.5
Only 16 commits and 4 releases came out last year, the last push was in March 2026, and the Scorecard Maintained check scores 0. Volunteers maintain it with no visible funding, and the backlog holds 283 open issues. NestJS 12 adds Standard Schema validation, so the ecosystem is slowly moving to schema libraries, but its large NestJS base keeps it from being abandoned soon.
- github commitsLastYear: 16 commits, last push 2026-03-25
- scorecard Maintained: Score 0
- github.com/typestack/class-validator/issues/1775: Community worry about the lack of a dedicated maintainer
- dev.to/x4nent/nestjs-12-deep-dive-full-esm-migration-standard-schema-route-validation-and-the-4fe0: NestJS 12 adds Standard Schema route validation as an option
GPT-6.2 Sol: 4.8, likely 3.4 to 6.3
The supplied snapshot shows 16 commits and three npm versions in a year, with the last publish in February 2026. Recent GitHub releases came from one maintainer, and users reported upgrade failures after a validation default changed in 0.14.0. NestJS still supports the class-based workflow and now offers a built-in schema pipeline, so continued compatibility looks more likely than renewed adoption. Funding and backup publishing capacity are unclear.
- github.commitsLastYear, github.pushedAt, github.openPullRequests, npm.versionsLastYear, npm.latestPublishedAt: Sixteen commits, a March push, 46 open pull requests, and three npm versions through February.
- github.com/typestack/class-validator/releases: Recent releases came from one maintainer and included dependency fixes.
- github.com/nestjs/nest/issues/10683: Users reported validation failures after upgrading to 0.14.0.
- docs.nestjs.com/migration-guide: NestJS retains class-based validation and adds first-class Standard Schema support.
- peers Zod and Valibot commitsLastYear: Zod and Valibot each recorded more than 400 commits.
Used widely6.0
How many use it, and is that growing?
Claude Opus 5.5: 6.5, likely 5.5 to 7.5
About 70M downloads in four weeks and 56k dependent repositories show heavy real use, mostly through NestJS projects. Its growth ratio of 3.2 is below the 4.1 median, so it is losing share, while Zod (8.4) and Valibot (14.9) grow much faster. Bluesky and Hacker News show almost no attention.
- npm downloadsLast4Weeks: 69.9M now vs 21.7M a year ago, ratio 3.2 < median 4.1
- dependents: 56,346 repos and 3,854 packages
- bluesky posts: Only 1 post, vs 32 for Zod
GPT-6.2 Sol: 5.5, likely 4.4 to 6.6
The partial index found 56,346 dependent repositories and 3,854 packages, consistent with an established user base in the tens of thousands. Four-week downloads rose from 21.7 million to 69.9 million, but 3.22× growth trailed the 4.1× catalog baseline and Zod's 8.40×. Repeated installs and framework-driven use make downloads a loose proxy for new choices, and one Bluesky link post gives little evidence of fresh attention.
- dependents.repos, dependents.packages, github.stars: 56,346 indexed repositories, 3,854 packages, and 11,855 GitHub stars.
- npm.downloadsLast4Weeks, npm.downloadsSame4WeeksYearAgo, medianDownloadsRatio: Downloads grew 3.22× against the 4.1× catalog median.
- peers Zod and Valibot downloadsLast4Weeks, downloadsSame4WeeksYearAgo, blueskyPosts: Zod and Valibot grew 8.40× and 14.89× and drew more Bluesky links.
- bluesky.posts: One repository link post in the collection window.
- docs.nestjs.com/application/validation: Installing class-validator is part of the documented class-based ValidationPipe setup.
Vouched for6.2
Who stands behind it being good?
Claude Opus 5.5: 6.0, likely 5.0 to 7.0
The official NestJS docs use it, and so do many production NestJS backends, which is real, current backing. Independent write-ups describe it as the NestJS default, but they usually favour Zod for new work, and some teams record decisions to move away from it. It has no presence in surveys or independent benchmarks beyond that.
- wildandfreetools.com/blog/zod-vs-class-validator-nestjs: Native NestJS ValidationPipe integration in the official docs
- ideony-docs.pages.dev/decisions/0016-zod-over-class-validator: A team's decision record choosing Zod over class-validator
- NestJS documentation: The validation chapter is built on class-validator and class-transformer
GPT-6.2 Sol: 6.4, likely 5.3 to 7.5
NestJS and TypeGraphQL integrate class-validator, and Ever Gauzy documents using it for backend DTOs. Immich moved to Zod in v3, and some NestJS users report that combining validation and framework decorators becomes cumbersome. The State of JavaScript survey shows Zod's momentum and gives no class-validator satisfaction measure, so confidence is strongest within class-based stacks.
- docs.nestjs.com/application/validation: NestJS supports and documents the built-in decorator-based validation pipe.
- typegraphql.com/docs/validation.html: TypeGraphQL documents built-in class-validator integration.
- github.com/ever-co/ever-gauzy-docs/blob/develop/website/docs/architecture/technology-stack.md: Ever Gauzy lists class-validator for backend DTO validation.
- github.com/immich-app/immich/releases/tag/v3.0.0: Immich shipped its migration from class-validator to Zod.
- reddit.com/r/nestjs/comments/1jsnr3r/how_to_manage_a_long_list_of_validator_decorators: NestJS users describe decorator overhead on DTOs, including GraphQL inputs.
- 2025.stateofjs.com/en-US/other-tools: Survey reports increased regular use of Zod and does not measure class-validator satisfaction.
Safe5.9
How safe is it to depend on?
Claude Opus 5.5: 6.0, likely 5.0 to 7.0
There is one old critical advisory from 2021, which was disputed and mitigated in 0.14 by defaulting forbidUnknownValues to true, and none in the last 24 months. It has only three dependencies, but validator.js is among them and has had its own advisories. The OpenSSF Scorecard is weak at 4.7, with 0 on Security-Policy, Token-Permissions, SAST and Maintained. The licence is MIT.
- advisories: 1 total (GHSA-fj58-h2fr-3pp2, 2021), 0 in 24 months
- scorecard score: 4.7 with several 0 checks
- npm dependencies: 3 dependencies, MIT
- raw.githubusercontent.com/typestack/class-validator/HEAD/CHANGELOG.md: 0.14.4 updated validator.js to 13.15.22
GPT-6.2 Sol: 5.8, likely 4.6 to 7.0
The MIT licence and three direct dependencies keep the dependency footprint modest. The critical advisory was fixed in 0.14.0 in December 2022, about 14 months after the GitHub listing, and the bundle records no newer direct advisories. Recent releases also patched dependencies, but Scorecard gives 4.7 with weak workflow token permissions and no detected fuzzing or security policy. Recent GitHub releases name one releaser, and npm publishing controls are unclear.
- npm.license, npm.dependencies, advisories.last24Months: MIT licence, three direct dependencies, and no direct advisories recorded in the last 24 months.
- github.com/advisories/GHSA-fj58-h2fr-3pp2: Critical advisory listed in October 2021 and fixed in 0.14.0.
- github.com/typestack/class-validator/blob/develop/CHANGELOG.md: Dates the 0.14.0 fix and records recent dependency security updates.
- scorecard.score, scorecard.checks: Score 4.7, with branch protection at 8 and token permissions, fuzzing, and security policy at 0.
- github.com/typestack/class-validator/releases: One GitHub releaser handled the recent release series.
Good
- It works out of the box with the NestJS ValidationPipe and is the approach the NestJS docs show.
- It has a large set of ready-made validators (email, UUID, IBAN, phone numbers and more), built on validator.js.
- One DTO class can serve as the validation rules, the TypeScript type and the source for Swagger docs.
- It pulls in only three dependencies and uses the permissive MIT licence.
Bad
- It needs legacy experimentalDecorators and works on class instances, usually with class-transformer, rather than on plain data.
- It cannot infer types from a schema, and the classes are hard to share with frontend code.
- Maintenance is thin: there were 16 commits last year, no push since March 2026, and about 280 open issues.
- NestJS 12 adds Standard Schema validation, so Zod, Valibot or ArkType can now be used in NestJS without class-validator.
The numbers
- npm downloads, 4 weeks
- 70M ×3.2 in a year
- GitHub stars
- 12k
- Commits, 12 months
- 16
- npm version
- 0.15.1 Feb 2026
- Versions, 12 months
- 3
- Advisories, 24 months
- 0 of 1 ever
- OpenSSF Scorecard
- 4.7 out of 10, Nov 2026
- Licence
- MIT
Read on 21 November 2026 from GitHub (typestack/class-validator), npm (class-validator), OSV and the OpenSSF Scorecard.