text: import * as Yup from 'yup';
  
  export default async (req, res, next) => {
    try {
      const schema = Yup.object().shape({
        name: Yup.string().required(),
        email: Yup.string()
          .email()
          .required(),
      });
  
      await schema.validate(req.body, {
        abortEarly: false,
      });
      return next();
    } catch (error) {
      return res.status(400).json({
        error: 'Falha na validação!',
        messages: error.inner,
      });
    }
  };
  