import { PipeTransform , Injectable , ArgumentMetadata , BadRequestException } from '@nestjs/common' ; @ Injectable ( ) export class ParseIntPipe implements PipeTransform < string > { async transform ( value , metadata ) { const val = parseInt ( value , 10 ) ; if ( isNaN ( val ) ) { throw new BadRequestException ( 'Validation failed' ) ; } return val ; } }