forked from Yara724/api
fix(validation): normalize Persian accident condition labels
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { WeatherCondition, RoadCondition, LightCondition } from "src/Types&Enums/blame-request-management/accident-conditions.enum";
|
||||
import { normalizeAccidentConditions } from "./accident-conditions";
|
||||
import { UserClaimBranchService, userClaimBranchContext, usesUserClaimBranch } from "src/client/user-claim-branch.service";
|
||||
import { normalizeAccidentLocation } from "./accident-location";
|
||||
import {
|
||||
@@ -215,12 +215,13 @@ export class RequestManagementService {
|
||||
};
|
||||
}
|
||||
|
||||
/** Keep eligibility rejections distinct from an unavailable CAR_BODY provider. */
|
||||
private assertAccidentConditions(body: {weatherCondition?: unknown; roadCondition?: unknown; lightCondition?: unknown}): void {
|
||||
for (const [value, choices] of [[body.weatherCondition, WeatherCondition], [body.roadCondition, RoadCondition], [body.lightCondition, LightCondition]] as const) {
|
||||
if (value != null && !Object.values(choices).includes(value as never))
|
||||
throw new BadRequestException("شرایط آبوهوا، راه یا روشنایی حادثه معتبر نیست. گزینههای فرم را دوباره انتخاب کنید.");
|
||||
}
|
||||
/** Normalize existing UI labels before validation and persistence in every flow. */
|
||||
private assertAccidentConditions(body: {
|
||||
weatherCondition?: unknown;
|
||||
roadCondition?: unknown;
|
||||
lightCondition?: unknown;
|
||||
}): void {
|
||||
Object.assign(body, normalizeAccidentConditions(body));
|
||||
}
|
||||
|
||||
private assertCarBodyDescriptionMinimum(
|
||||
|
||||
Reference in New Issue
Block a user