import { ValidationPipe , ValidationPipeOptions , UnprocessableEntityException } from "@nestjs/common" ; import { ValidationError } from "class-validator" ; export class UnprocessibleEntityValidationPipe extends ValidationPipe { constructor ( options = { } ) { options . exceptionFactory = ( originalErrors ) => { const errors = originalErrors . map ( ( error ) => error . children . map ( ( child ) => [ child . property , Object . values ( child . constraints ) ] ) ) . reduce ( ( acc , errors ) => acc . concat ( errors ) , [ ] ) ; return new UnprocessableEntityException ( { errors : Object . fromEntries ( errors ) } ) ; } ; super ( options ) ; } }