
Validation & DTO
class-validator, class-transformer, DTOs, ValidationPipe, custom validators, sanitization
1What is a DTO (Data Transfer Object) in NestJS?
What is a DTO (Data Transfer Object) in NestJS?
คำตอบ
A DTO is a TypeScript class that defines the structure of data transferred between client and server. It acts as a data contract and enables automatic input validation using decorators like @IsString or @IsNumber. DTOs improve security by filtering unauthorized properties and make code maintenance easier.
2Which package allows adding validation constraints to DTOs?
Which package allows adding validation constraints to DTOs?
คำตอบ
The class-validator package provides validation decorators like @IsString, @IsEmail, @Min, @Max that allow defining validation rules on DTO properties. It works in tandem with ValidationPipe to automatically validate incoming data. This package is widely used in the NestJS ecosystem to ensure data integrity.
3Which decorator validates that a property is a string?
Which decorator validates that a property is a string?
คำตอบ
The @IsString decorator verifies that a property is of type string. It applies directly to the DTO property and automatically rejects any value that is not a string. This decorator is one of the most commonly used as it covers a very common validation case in REST APIs.
Where should ValidationPipe be configured to validate all application routes?
Which decorator validates that a field is not empty?
+17 คำถามสัมภาษณ์
หัวข้อสัมภาษณ์ Node.js / NestJS อื่นๆ
Node.js Fundamentals
Node.js Core APIs
Asynchronous Programming
Express.js Basics
NestJS Fundamentals
REST API Design
API Documentation & Contracts
Error Handling
Unit Testing
Task Scheduling
NestJS Modules & DI
Configuration & Environment Management
JWT Authentication
Authorization & RBAC
Database with TypeORM
Prisma ORM
Middleware & Interceptors
File Upload
WebSockets
GraphQL with NestJS
End-to-End Testing
Caching with Redis
Queues with Bull
DevOps, Logging & CI/CD
Docker & Containerization
Microservices
Security Best Practices
Performance & Cloud Deployment
เชี่ยวชาญ Node.js / NestJS สำหรับการสัมภาษณ์ครั้งถัดไป
เข้าถึงคำถามทั้งหมด flashcards แบบทดสอบเทคนิค แบบฝึกหัด code review และตัวจำลองสัมภาษณ์
เริ่มใช้ฟรี