I am trying to perform data validation using ValidationError from yup library so that I can show a custom validation error. But when I go through the inner error, it says the path type is undefined.
What can I do to get it right?
import { ValidationError } from 'yup';
interface Errors {
[key: string]: string;
}
export default function getValidationErrors(err: ValidationError): Errors {
const validationErrors: Errors = {};
err.inner.forEach(error => {
validationErrors[error.path] = error.message;
});
return validationErrors;
}