Convert array of ValidationError objects from class-validator to multiline string
npm install class-validator-flat-formatter
import { validationErrorsAsString } from 'class-validator-flat-formatter';
const errors = await validate(user);
const message = validationErrorsAsString(errors);
/**
message(String) =>
name: should not be empty (isNotEmpty),\n
email: must be an email (isEmail).
*/
import { validationErrorsAsArray } from 'class-validator-flat-formatter';
const errors = await validate(user);
const messages = validationErrorsAsArray(errors);
/**
messages => Array<string> {
'name: should not be empty (isNotEmpty)',
'email: must be an email (isEmail)'
}
*/
MIT License (c) 2024