/*!
 * Built by ShiftSoftware
 * Copyright (c)
 */
import { object, string } from "yup";
export const vehicleQuotationInputsValidation = object({
    vehicle: string()
        .meta({ label: 'Vehicle', placeholder: 'Please select a Vehicle' })
        .required('This field is required.'),
    name: string()
        .meta({ label: 'Full name', placeholder: 'Full name' })
        .required('Full name is required')
        .min(3, 'Full name minimum'),
    dealer: string()
        .meta({ label: 'Dealer', placeholder: 'Select a dealer' })
        .required('Dealer is required'),
    city: string()
        .meta({ label: 'City', placeholder: 'Select a City' })
        .required('This field is required.'),
    paymentType: string()
        .meta({ label: 'Preferred purchasing method', placeholder: 'Select the purchasing method' })
        .when('$paymentTypeRequired', {
        is: true,
        otherwise: schema => schema.optional(),
        then: schema => schema.required('This field is required.'),
    }),
    contactTime: string()
        .meta({ label: 'Preferred contact time', placeholder: 'Please select a time' })
        .when('$contactTimeRequired', {
        is: true,
        otherwise: schema => schema.optional(),
        then: schema => schema.required('This field is required.'),
    }),
    ownVehicle: string()
        .meta({ label: 'Do you own a vehicle?', placeholder: 'Do you own a vehicle?' })
        .when('$ownVehicleRequired', {
        is: true,
        otherwise: schema => schema.optional(),
        then: schema => schema.required('This field is required.'),
    }),
    currentVehicleBrand: string()
        .meta({ label: 'Your current vehicle', placeholder: 'Your current vehicle' })
        .when('ownVehicle', {
        is: (val) => val === 'yes',
        then: schema => schema.required('Please answer this field'),
        otherwise: schema => schema.optional(),
    }),
    currentVehicleModel: string()
        .meta({ label: 'Vehicle Model', placeholder: 'Vehicle Model' })
        .when(['ownVehicle', 'currentVehicleBrand'], {
        is: (ownVehicle, brand) => ownVehicle === 'yes' && brand !== 'Other',
        then: schema => schema.required('Please answer this field'),
        otherwise: schema => schema.optional(),
    }),
});
