Back

Televox: Formik custom validation,

Copy Below Code View As A Text File Show Text Only Show API Edit Code
                            

evaluations: Yup.array().required() .min(1, "At least one evaluation entry is required") .test(function (objValue) { if (objValue && objValue.length > 0) { const hasEmpty = objValue.some( (v) => !v.condition || !v.source || !v.value ); if (hasEmpty) { return this.createError({ message: "Please Evaluate all fields", path: "evaluations", }); } return true; } }), Details: you can use .test() method to apply your custom condition on it, In above code, we want to check the inside fields present in an array should also contains value. Array: [{ value:'test', condition:'>' ..// }]