leaseObjectUsed improvements

This commit is contained in:
vchikalkin 2023-05-29 11:59:02 +03:00
parent 6a95fbb3f2
commit 8e3fb86169
2 changed files with 30 additions and 15 deletions

View File

@ -16,15 +16,18 @@ export function createValidationSchema({ apolloClient }: ValidationContext) {
leaseObjectPrice: true,
leaseObjectType: true,
leaseObjectUseFor: true,
leaseObjectUsed: true,
leaseObjectYear: true,
leasingPeriod: true,
leasingWithoutKasko: true,
legalClientRegion: true,
maxMass: true,
mileage: true,
model: true,
objectRegistration: true,
opportunity: true,
townRegistration: true,
vin: true,
withTrailer: true,
}).superRefine(
async (
@ -45,6 +48,9 @@ export function createValidationSchema({ apolloClient }: ValidationContext) {
leaseObjectPrice,
leaseObjectYear,
leasingPeriod,
vin,
mileage,
leaseObjectUsed,
},
ctx
) => {
@ -198,6 +204,24 @@ export function createValidationSchema({ apolloClient }: ValidationContext) {
}
}
if (leaseObjectUsed) {
if (!vin) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: 'Не указан ' + titles.tbxVIN,
path: ['eltKasko'],
});
}
if (!mileage) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: 'Не указан ' + titles.tbxMileage,
path: ['eltKasko'],
});
}
}
if (insDecentral) {
ctx.addIssue({
code: z.ZodIssueCode.custom,

View File

@ -48,21 +48,12 @@ export function createValidationSchema({ apolloClient }: ValidationContext) {
}
}
if (leaseObjectUsed) {
if (!mileage) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: 'Не заполнено поле',
path: ['tbxMileage'],
});
}
if (!vin) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: 'Не заполнено поле',
path: ['tbxVIN'],
});
}
if (leaseObjectUsed && !mileage) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: 'Не заполнено поле',
path: ['tbxMileage'],
});
}
/**