diff --git a/apps/web/process/gibdd/reactions.ts b/apps/web/process/gibdd/reactions.ts index 87b3bac..23b3e03 100644 --- a/apps/web/process/gibdd/reactions.ts +++ b/apps/web/process/gibdd/reactions.ts @@ -528,8 +528,14 @@ export function validation(context: ProcessContext) { 'objectCategoryTax', 'insNSIB', 'vehicleTaxInYear', + 'vehicleTaxInLeasingPeriod', + 'objectRegionRegistration', + 'regionRegistration', + 'townRegistration', + 'registration', ]), async (values) => { + validationHelper.removeErrors(); const validationResult = await validationSchema.safeParseAsync(values); if (validationResult.success === false) { diff --git a/apps/web/process/gibdd/validation.ts b/apps/web/process/gibdd/validation.ts index b1fb526..d7681df 100644 --- a/apps/web/process/gibdd/validation.ts +++ b/apps/web/process/gibdd/validation.ts @@ -1,3 +1,5 @@ +/* eslint-disable sonarjs/cognitive-complexity */ +/* eslint-disable complexity */ import type { ValidationContext } from '../types'; import ValuesSchema from '@/config/schema/values'; import { MAX_MASS } from '@/constants/values'; @@ -11,8 +13,13 @@ export function createValidationSchema({ apolloClient }: ValidationContext) { leaseObjectType: true, maxMass: true, objectCategoryTax: true, + objectRegionRegistration: true, objectRegistration: true, + regionRegistration: true, + registration: true, + townRegistration: true, typePTS: true, + vehicleTaxInLeasingPeriod: true, vehicleTaxInYear: true, }).superRefine( async ( @@ -25,6 +32,11 @@ export function createValidationSchema({ apolloClient }: ValidationContext) { objectCategoryTax, insNSIB, vehicleTaxInYear, + vehicleTaxInLeasingPeriod, + objectRegionRegistration, + regionRegistration, + townRegistration, + registration, }, ctx ) => { @@ -74,21 +86,57 @@ export function createValidationSchema({ apolloClient }: ValidationContext) { } } - if (objectRegistration === 100_000_001 && !(vehicleTaxInYear > 0)) { - ctx.addIssue({ - code: z.ZodIssueCode.custom, - message: 'Значение должно быть больше 0', - path: ['tbxVehicleTaxInYear'], - }); + if (objectRegistration === 100_000_001) { + if (!(vehicleTaxInYear > 0)) + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: 'Значение должно быть больше 0', + path: ['tbxVehicleTaxInYear'], + }); + + if (!(vehicleTaxInLeasingPeriod > 0)) + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: 'Значение должно быть больше 0', + path: ['tbxVehicleTaxInLeasingPeriod'], + }); + + if (!objectRegionRegistration) + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: 'Не заполнено поле', + path: ['selectObjectRegionRegistration'], + }); + + if (!typePTS) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: 'Не заполнено поле', + path: ['radioTypePTS'], + }); + } } - if (objectRegistration === 100_000_001 && !typePTS) { + if (objectRegistration === 100_000_000 && !townRegistration) ctx.addIssue({ code: z.ZodIssueCode.custom, message: 'Не заполнено поле', - path: ['radioTypePTS'], + path: ['selectTownRegistration'], + }); + + if (!regionRegistration) + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: 'Не заполнено поле', + path: ['selectRegionRegistration'], + }); + + if (!registration) + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: 'Не заполнено поле', + path: ['selectRegistration'], }); - } } ); }