Bird
0
0

Given this NestJS controller method:

medium📝 component behavior Q5 of 15
NestJS - Pipes
Given this NestJS controller method:
@Get('status/:flag')
checkStatus(@Param('flag', ParseBoolPipe) flag: boolean) { return flag; }

What will be the response when the client requests /status/true?
AReturns boolean true
BReturns string 'true'
CThrows a 400 Bad Request error
DReturns boolean false
Step-by-Step Solution
Solution:
  1. Step 1: Understand ParseBoolPipe

    It converts 'true' or 'false' strings (case insensitive) to boolean values.
  2. Step 2: Input is 'true'

    So the pipe converts it to boolean true.
  3. Final Answer:

    Returns boolean true -> Option A
  4. Quick Check:

    ParseBoolPipe converts 'true' string to boolean true [OK]
Quick Trick: ParseBoolPipe converts 'true'/'false' strings to booleans [OK]
Common Mistakes:
  • Expecting string output instead of boolean
  • Assuming any string converts without error
  • Confusing ParseBoolPipe with ParseIntPipe

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NestJS Quizzes