ljlm0402 / typescript-express-starter

📘 Quick and Easy TypeScript Express Starter
http://npm.im/typescript-express-starter
MIT License
2.73k stars 420 forks source link

Difference between dto and interface #192

Closed cuongnv-dev closed 1 year ago

cuongnv-dev commented 2 years ago

Summary (요약)

  1. Could you explain the difference between dto and interface, and when we should use which?
  2. Do you have a channel or group where all members who follow this template can discuss?
ljlm0402 commented 2 years ago

@cuongnv-dev

Interfaces can not compute properties or use decorators, whereas classes can. NestJS recommends to use classes because you can add decorators from class-validator to properties such as @IsString() or @Max(20). With interfaces such a validation would only be possible outside of the interface context.

https://github.com/nestjs/nest/issues/1228


There are no channels or groups for discussion. However, if you have any questions, please leave an issue and we will answer them. thank you

cuongnv-dev commented 2 years ago

thanks for clarifications