Files
klz-cables.com/.pnpm-store/v10/files/55/b39393c8d61e9f62b1d28a1e3d15fb3171d66de21cc91486cab4850141736579125cb9b21ecafac33b0bac458a50738ff478574e7dd7d745991fb2342a2ab4
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

39 lines
1.6 KiB
Plaintext

import { en } from '@payloadcms/translations/languages/en';
import { status as httpStatus } from 'http-status';
import { APIError } from './APIError.js';
// This gets dynamically reassigned during compilation
export let ValidationErrorName = 'ValidationError';
export class ValidationError extends APIError {
constructor(results, t){
const message = t ? t('error:followingFieldsInvalid', {
count: results.errors.length
}) : results.errors.length === 1 ? en.translations.error.followingFieldsInvalid_one : en.translations.error.followingFieldsInvalid_other;
const req = results.req;
// delete to avoid logging the whole req
delete results['req'];
super(`${message} ${results.errors.map((f)=>{
if (f.label) {
if (typeof f.label === 'function') {
if (!req || !req.i18n || !req.t) {
return f.path;
}
return f.label({
i18n: req.i18n,
t: req.t
});
}
if (typeof f.label === 'object') {
if (req?.i18n?.language) {
return f.label[req.i18n.language];
}
return f.label[Object.keys(f.label)[0]];
}
return f.label;
}
return f.path;
}).join(', ')}`, httpStatus.BAD_REQUEST, results);
ValidationErrorName = this.constructor.name;
}
}
//# sourceMappingURL=ValidationError.js.map