forked from Yara724/api
Error handling on empty damaged parts
This commit is contained in:
@@ -4655,7 +4655,7 @@ export class ExpertClaimService {
|
|||||||
previousNorm,
|
previousNorm,
|
||||||
);
|
);
|
||||||
|
|
||||||
const nextNorm = body.selectedParts.map((p) =>
|
const nextNormRaw = body.selectedParts.map((p) =>
|
||||||
sanitizeDamageSelectedPartV2(
|
sanitizeDamageSelectedPartV2(
|
||||||
{
|
{
|
||||||
id: p.id ?? null,
|
id: p.id ?? null,
|
||||||
@@ -4669,6 +4669,20 @@ export class ExpertClaimService {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Drop ghost entries: internal parts with neither a catalog id nor a name
|
||||||
|
// (these are frontend artifacts from uninitialised form rows).
|
||||||
|
const nextNorm = nextNormRaw.filter((p) => {
|
||||||
|
if (p.id != null) return true;
|
||||||
|
return String(p.name ?? "").trim().length > 0;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (nextNorm.length === 0) {
|
||||||
|
throw new BadRequestException(
|
||||||
|
"selectedParts must contain at least one identifiable part. " +
|
||||||
|
"Each entry must have a numeric catalog id or a non-empty name.",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const matchPreviousIndex = (
|
const matchPreviousIndex = (
|
||||||
next: (typeof nextNorm)[0],
|
next: (typeof nextNorm)[0],
|
||||||
previous: typeof previousNorm,
|
previous: typeof previousNorm,
|
||||||
|
|||||||
Reference in New Issue
Block a user