class-validator is a decorator-based validation library for TypeScript classes that works in both browser and Node.js environments.
The tool solves the problem of validating class properties by allowing developers to attach validation decorators directly to class fields. It internally uses validator.js to perform the actual validation checks. Developers can apply decorators like @IsEmail, @IsNotEmpty, and others to properties, then call the validate function on class instances to get back an array of ValidationError objects describing any failures. The library supports both decorator-based and non-decorator-based validation approaches.
The tool suits projects using TypeScript with class-based architectures, particularly those handling data validation in API servers or applications that need to validate user input against defined schemas. It handles complex scenarios including nested object validation, arrays, sets, maps, and promises. The library offers validation groups for conditional validation logic, custom validation decorators for domain-specific rules, and options for whitelisting unknown properties or skipping missing properties. A ValidatorOptions parameter controls validation behavior, with forbidUnknownValues set to true by default for security.
Development activity shows consistent maintenance with automated testing via CI workflows and code coverage tracking. The project maintains comprehensive documentation covering all validation decorators and usage patterns. Pull requests and issues receive attention, indicating active engagement with the user community. The codebase remains stable with established patterns for extending functionality through custom validators and service container integration.