From the course: Mastering Nest.js: Build Scalable Applications with Mastery in Nest.js Framework
Unlock this course with a free trial
Join today to access over 25,200 courses taught by industry experts.
Built-in pipes (ParseBooleanPipe) - Nest.js Tutorial
From the course: Mastering Nest.js: Build Scalable Applications with Mastery in Nest.js Framework
Built-in pipes (ParseBooleanPipe)
The parse bool pipe in NestJS is a built-in transformation pipe which transforms incoming string values from request parameters like query strings, body parameters, etc. into Boolean values. This can be useful when dealing with API endpoints that expect Boolean flags or filters. Let's check an example. Inside the controller file, I'll give the get handler and a method getValue. Inside this method's argument, I'll give the query decorator and the parameter value as isActive and the parse boolean py. So this query string will hold a boolean value and if any other value other than boolean is given as a query, it will display an error. Let me give a property isActive of type Boolean and inside the method, I will give an if condition that if the isActive exists, return a welcome admin message else return welcome user message if the value is false. Let's save this and open the postman. I'll give the route path and give the query. Let's first set the query value as a random string value and…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
(Locked)
Introduction to pipes1m 59s
-
(Locked)
Built-in pipes (ParseIntPipe)2m 40s
-
(Locked)
Built-in pipes (ParseFloatPipe)1m 7s
-
(Locked)
Built-in pipes (ParseBooleanPipe)2m 25s
-
(Locked)
Built-in pipes (ParseArrayPipe)2m 59s
-
(Locked)
Built-in pipes (ParseUUIDPipe)4m 12s
-
(Locked)
Built-in pipes (ValidationPipe)5m 52s
-
(Locked)
Validating empty fields3m 34s
-
(Locked)
Validating field length3m 4s
-
(Locked)
Custom validation messages3m 2s
-
(Locked)
Validating field using @IsEnum() validator4m 7s
-
(Locked)
Validating dates in Nest.js2m 31s
-
(Locked)
Validating optional fields2m 33s
-
(Locked)
Validating regex pattern3m 11s
-
(Locked)
Creating a custom pipe6m 39s
-
(Locked)
Understanding ArgumentMetadata (metadata.type)3m 40s
-
(Locked)
Assignment: Custom pipe (handling different "type" arguments)3m 56s
-
(Locked)
Understanding ArgumentMetadata (metadata.metatype)5m
-
(Locked)
Understanding ArgumentMetadata (metadata.data)3m 37s
-
(Locked)
Implementing global pipes2m 30s
-
(Locked)
-
-
-
-
-
-
-
-
-