I’m using the following Yup schema:
const schemaSecondStep = object({
title: string(),
firstName: string(),
familyName: string(),
invoiceAddress: object({
title: string(),
firstName: string(),
familyName: string(),
street: string().required(),
postalCode: string().required(),
city: string().required(),
floor: string().required(),
country: string().required(),
phonePrefix: number().required(),
phoneNumber: number().required(),
}).nullable()
});
Basically, I have another ref:
const useDifferentInvoiceAddressSelection = ref("same");
If this is “different”, I would like to apply the invoiceAddress logic below. If its “same”, invoiceAddress can and should be null.
The config above still forces the values to be set, even if its object().nullable()
.