data-transfer-object
Version:
Data Transfer Object class built on `class-validator`.
15 lines (14 loc) • 669 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getValidationErrorMap = void 0;
/**
* Receives an array of `ValidationError`, and generates an object with key-value pairs where
* the keys represent a property name, and the values are an array of all validation error
* messages for that property.
* @param errors The array of `ValidationError` to generate a validation error map from.
*/
function getValidationErrorMap(errors) {
const entries = errors.map(e => [e.property, Object.values(e.constraints ?? {})]);
return Object.fromEntries(entries);
}
exports.getValidationErrorMap = getValidationErrorMap;