UNPKG

ltijs

Version:

Easily turn your web application into a LTI 1.3 Learning Tool.

29 lines • 1.01 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ValidationError = void 0; const errors_1 = require("#shared/errors"); class ValidationError extends errors_1.LtijsError { issues; errors; constructor(error) { const details = error.issues .map(issue => { const pathLabel = issue.path.join('.'); return `${pathLabel !== '' ? pathLabel : '(root)'}: ${issue.message}`; }) .join('; '); super(`Validation failed: ${details}`); this.issues = error.issues; this.errors = ValidationError.groupByField(error.issues); } static groupByField(issues) { const errors = {}; for (const issue of issues) { const key = issue.path.length > 0 ? issue.path.join('.') : '(root)'; errors[key] = [...(errors[key] ?? []), issue.message]; } return errors; } } exports.ValidationError = ValidationError; //# sourceMappingURL=errors.js.map