Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

228
Visualizações
Celebrate request validation failed?

I'm getting this weird error whenever I try to post something on my site. It is a field where the user can enter text or enter a media file such as photo or video. But when I try to enter text this error is returned.So I just can't post anything text or image.

{statusCode: 400, error: "Bad Request", message: "celebrate request validation failed",…}
error: "Bad Request"
message: "celebrate request validation failed"
statusCode: 400
validation: {body: {source: "body", keys: ["file"], message: ""file" is not allowed"}}
body: {source: "body", keys: ["file"], message: ""file" is not allowed"}
keys: ["file"]
message: "\"file\" is not allowed"
source: "body"

My Front End is built with React.

const handleStoryCreate = useCallback(async () => {
    try {
      setLoading(true);

      const data = {
        text: inputValue,
      };

      const schema = Yup.object().shape({
        text: Yup.string().required('Texto obrigatório'),
      });

      await schema.validate(data, { abortEarly: false });

      const formData = new FormData();

      formData.append('text', data.text);
      formData.append('file', fileImage);

      await api.post('stories', formData, {
        headers: {
          'content-type': 'multipart/form-data',
          Authorization: `Bearer ${session.accessToken}`,
        },
      });

Here the route:

router.post(
  '/',
  ensureAuthorization('user'),
  ensureFiles('file', false),
  resize,
  celebrate({
    [Segments.BODY]: {
      text: Joi.string().required(),
    },
  }),
  storiesController.create,
);
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda