0
0
NestJSframework~10 mins

ValidationPipe setup in NestJS - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the ValidationPipe from NestJS.

NestJS
import { [1] } from '@nestjs/common';
Drag options to blanks, or click blank then click option'
APipeTransform
BValidationPipe
CController
DInjectable
Attempts:
3 left
💡 Hint
Common Mistakes
Importing unrelated classes like Controller or Injectable.
Confusing ValidationPipe with PipeTransform interface.
2fill in blank
medium

Complete the code to apply ValidationPipe globally in the main.ts file.

NestJS
app.useGlobalPipes(new [1]());
Drag options to blanks, or click blank then click option'
AValidationPipe
BLogger
CAuthGuard
DParseIntPipe
Attempts:
3 left
💡 Hint
Common Mistakes
Using pipes unrelated to validation like ParseIntPipe.
Forgetting to instantiate the pipe with new.
3fill in blank
hard

Fix the error in the ValidationPipe options to enable automatic transformation.

NestJS
app.useGlobalPipes(new ValidationPipe({ transform: [1] }));
Drag options to blanks, or click blank then click option'
Afalse
B'true'
Ctrue
DTrue
Attempts:
3 left
💡 Hint
Common Mistakes
Using string 'true' instead of boolean true.
Using capitalized True which is invalid in JavaScript/TypeScript.
4fill in blank
hard

Fill both blanks to configure ValidationPipe to whitelist and forbid non-whitelisted properties.

NestJS
app.useGlobalPipes(new ValidationPipe({ whitelist: [1], forbidNonWhitelisted: [2] }));
Drag options to blanks, or click blank then click option'
Atrue
Bfalse
Cundefined
Dnull
Attempts:
3 left
💡 Hint
Common Mistakes
Setting these options to false disables the security benefits.
Using undefined or null instead of boolean values.
5fill in blank
hard

Fill all three blanks to create a ValidationPipe with transform, whitelist, and forbidNonWhitelisted enabled.

NestJS
app.useGlobalPipes(new ValidationPipe({ transform: [1], whitelist: [2], forbidNonWhitelisted: [3] }));
Drag options to blanks, or click blank then click option'
Afalse
Btrue
Cundefined
Dnull
Attempts:
3 left
💡 Hint
Common Mistakes
Leaving any option false disables part of validation.
Using undefined or null instead of boolean true.