class-validator supports groups — decorators declare which groups they belong to, and ValidationPipe is configured with a specific group to run. Extend ValidationPipe with different group settings for create (all fields required) and update (all fields optional) handlers.
Decorators without a groups option apply to ALL groups — always specify groups explicitly.
Use skipMissingProperties: true on update groups so absent fields are not treated as errors.
Groups are passed as a string array — multiple groups can be active simultaneously.
A decorator with groups: ['create'] is completely ignored during update validation.
For simple create/update patterns, separate CreateDto and UpdateDto classes (with PartialType) is often cleaner.
We have a CreateUserDto and an UpdateUserDto. How would you set up class-validator so that the email field is required on create but optional on update using validation groups?
If you forget to pass a validation group to the ValidationPipe, what will happen to the rules you defined for the 'update' group?
Show me how you would annotate a password field to be required only for the 'register' group.
During a sprint we added an 'isAdmin' flag to the User DTO, but updates are now failing validation. Walk me through how you'd debug the issue with validation groups.
We need to support partial PATCH requests without over‑validating fields. Explain why you might choose validation groups over the pipe's 'skipMissingProperties' option, and how you'd implement it.
Our API uses a global ValidationPipe with whitelist:true. How does that interact with group‑specific constraints, and what would you change if a client reports a field is being stripped on update?
In a microservice architecture, several services share the same DTO definitions but have different validation requirements for create vs sync operations. How would you design a shared validation group strategy to avoid duplication and keep compile‑time safety?
Consider a high‑traffic endpoint that validates large payloads with multiple groups. What are the performance implications of using class-validator's groups, and how would you mitigate any overhead?
If you need to version your API (v1 vs v2) and the validation rules differ, how would you extend the validation group concept to handle version‑specific constraints while keeping the codebase maintainable?
Our organization is moving from NestJS to a polyglot stack, but we want a consistent validation contract across services in different languages. How would you evolve the use of class-validator groups to a language‑agnostic schema, and what migration path would you propose?
Several product teams have added custom decorators that rely on validation groups, leading to conflicting group names. As a staff engineer, how would you establish a governance model for validation groups to prevent such collisions in a large codebase?
Discuss the pros and cons of keeping validation logic in the NestJS layer (using class-validator) versus moving it to a GraphQL schema or OpenAPI spec, especially when groups differentiate create/update. What would you recommend for a company scaling to dozens of microservices?