UNPKG

coffee-core

Version:

Coffee IT API core library

33 lines 1.12 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.subtractExceptionMessage = void 0; const isObject = (value) => { return typeof value === 'object' && value !== null; }; const isValidationError = (object) => { return 'target' in object; }; const subtractExceptionMessage = (validationErrors) => { const firstError = validationErrors[0]; if (firstError && firstError.constraints) { const { constraints } = validationErrors[0]; if (isObject(constraints)) { const constraintKeys = Object.keys(constraints); if (constraintKeys.length > 0) { return constraints[constraintKeys[0]]; } } } if (!validationErrors?.[0]?.children?.[0]) { return; } const firstChild = validationErrors[0].children[0]; if (!isObject(firstChild)) { return; } if (isValidationError(firstChild)) { return (0, exports.subtractExceptionMessage)([firstChild]); } }; exports.subtractExceptionMessage = subtractExceptionMessage; //# sourceMappingURL=validation-utils.js.map