Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

230
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!