diff --git a/apps/web/process/configurator/validation.ts b/apps/web/process/configurator/validation.ts index 5572c06..2cbd57f 100644 --- a/apps/web/process/configurator/validation.ts +++ b/apps/web/process/configurator/validation.ts @@ -1,3 +1,4 @@ +/* eslint-disable sonarjs/cognitive-complexity */ import type { ValidationContext } from '../types'; import elementsProps from '@/Components/Calculation/config/elements-props'; import { getElementName } from '@/Components/Calculation/config/map/values'; @@ -24,6 +25,7 @@ const Schema = ValuesSchema.pick({ finDepartmentRewardSumm: true, firstPaymentPerc: true, firstPaymentRub: true, + floatingRate: true, importProgramSum: true, importerRewardPerc: true, importerRewardRub: true, @@ -38,6 +40,7 @@ const Schema = ValuesSchema.pick({ leaseObjectPriceWthtVAT: true, leaseObjectYear: true, leasingPeriod: true, + leasingWithoutKasko: true, maxMass: true, maxPriceChange: true, maxSpeed: true, @@ -93,6 +96,19 @@ export function createValidationSchema({ apolloClient }: ValidationContext) { } } + /** + * Если Плавающая ставка = Да и Лизинг без КАСКО содержит данные, + * то выводить сообщение "При плавающей ставке нельзя оформлять Лизинг без КАСКО" + */ + const { floatingRate, leasingWithoutKasko } = values; + if (floatingRate && leasingWithoutKasko) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: 'При плавающей ставке нельзя оформлять Лизинг без КАСКО', + path: ['selectLeasingWithoutKasko'], + }); + } + (Object.keys(values) as Values[]).forEach((valueName) => { const elementName = getElementName(valueName); if (elementName) {