Bird
0
0

You applied ValidationPipe globally with forbidNonWhitelisted: true but no error is thrown for extra properties. What is the likely cause?

medium📝 Debug Q6 of 15
NestJS - Pipes
You applied ValidationPipe globally with forbidNonWhitelisted: true but no error is thrown for extra properties. What is the likely cause?
AGlobal pipes cannot use <code>forbidNonWhitelisted</code>
BValidationPipe does not support <code>forbidNonWhitelisted</code>
CThe DTO class is missing validation decorators
DThe <code>whitelist</code> option was not enabled alongside <code>forbidNonWhitelisted</code>
Step-by-Step Solution
Solution:
  1. Step 1: Understand option dependencies

    forbidNonWhitelisted only works if whitelist is enabled to detect extra properties.
  2. Step 2: Identify missing configuration

    If whitelist is false or missing, extra properties are not filtered, so no error occurs.
  3. Final Answer:

    The whitelist option was not enabled alongside forbidNonWhitelisted -> Option D
  4. Quick Check:

    forbidNonWhitelisted requires whitelist: true [OK]
Quick Trick: Enable whitelist with forbidNonWhitelisted to throw errors [OK]
Common Mistakes:
  • Using forbidNonWhitelisted without whitelist
  • Assuming forbidNonWhitelisted works alone
  • Not checking DTO decorators

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NestJS Quizzes