validation: add create-kp required fields
This commit is contained in:
parent
99d7af4ac6
commit
870a9b5d75
@ -1,3 +1,5 @@
|
||||
/* eslint-disable sonarjs/cognitive-complexity */
|
||||
/* eslint-disable complexity */
|
||||
import type { ValidationContext } from '../types';
|
||||
import ValuesSchema from '@/config/schema/values';
|
||||
import * as CRMTypes from '@/graphql/crm.types';
|
||||
@ -5,13 +7,16 @@ import { z } from 'zod';
|
||||
|
||||
export function createValidationSchema({ apolloClient }: ValidationContext) {
|
||||
return ValuesSchema.pick({
|
||||
brand: true,
|
||||
countSeats: true,
|
||||
engineType: true,
|
||||
engineVolume: true,
|
||||
leaseObjectCategory: true,
|
||||
leaseObjectMotorPower: true,
|
||||
leaseObjectType: true,
|
||||
leaseObjectUseFor: true,
|
||||
maxMass: true,
|
||||
model: true,
|
||||
}).superRefine(
|
||||
async (
|
||||
{
|
||||
@ -22,9 +27,44 @@ export function createValidationSchema({ apolloClient }: ValidationContext) {
|
||||
countSeats,
|
||||
maxMass,
|
||||
leaseObjectCategory,
|
||||
brand,
|
||||
model,
|
||||
leaseObjectUseFor,
|
||||
},
|
||||
ctx
|
||||
) => {
|
||||
if (!leaseObjectTypeId) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
message: 'Не заполнено поле',
|
||||
path: ['selectLeaseObjectType'],
|
||||
});
|
||||
}
|
||||
|
||||
if (!brand) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
message: 'Не заполнено поле',
|
||||
path: ['selectBrand'],
|
||||
});
|
||||
}
|
||||
|
||||
if (!model) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
message: 'Не заполнено поле',
|
||||
path: ['selectModel'],
|
||||
});
|
||||
}
|
||||
|
||||
if (!leaseObjectUseFor) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
message: 'Не заполнено поле',
|
||||
path: ['selectLeaseObjectUseFor'],
|
||||
});
|
||||
}
|
||||
|
||||
if (leaseObjectTypeId) {
|
||||
const {
|
||||
data: { evo_leasingobject_type },
|
||||
|
||||
@ -369,6 +369,12 @@ export function createValidationSchema(context: ValidationContext) {
|
||||
message: 'Не заполнено поле',
|
||||
path: ['selectDealerPerson'],
|
||||
});
|
||||
} else {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
message: 'Не заполнено поле',
|
||||
path: ['selectDealer'],
|
||||
});
|
||||
}
|
||||
|
||||
const { validateRewardSum, validateRewardWithoutOtherAgent } = helper({ ...context, ctx });
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user