Skip to content

Add rules for decorator ordering in DTO and param classes

Choose a tag to compare

@fpolic-profico fpolic-profico released this 17 Oct 07:37
· 17 commits to main since this release
db721fe

For describing and validating requests and responses in the NestJs, we use classes and libraries.

Version v1.2.0 supports decorators from the following libraries:

  • @nestjs/swagger
  • class-validator
  • class-transformer

All other decorators are considered custom. These decorators are used on properties inside DTO, query params and path params classes.

Order enforced by the rule:

  1. @nestjs/swagger
  2. class-transformer
  3. class-validator
  4. IsOptional (class-validator)
  5. custom decorators

If there are more class-validator or custom decorators, they are ordered alphabetically.