Skip to content

Instantly share code, notes, and snippets.

@misaelabanto
misaelabanto / validation.exception.ts
Last active October 21, 2021 06:38
Custom exception for nestjs validation errors. It uses default error message transform from nest.js. You can also configure this.
import { BadRequestException } from '@nestjs/common';
import { ValidationError } from 'class-validator';
import { iterate } from 'iterare';
const VALIDATION_ERROR = () => 'There are validation errors';
export class ValidationException extends BadRequestException {
code: string;
errors: string[];
constructor(errors: ValidationError[]) {