Ajouter la validation dans Strapi

async uploadFiles(ctx) {
    const {
      state: { userAbility, user },
      request: { body, files: { files } = {} },
    } = ctx;

    const uploadService = strapi.plugins.upload.services.upload;
    const pm = strapi.admin.services.permission.createPermissionsManager(
      userAbility,
      ACTIONS.create,
      fileModel
    );

    if (!pm.isAllowed) {
      throw strapi.errors.forbidden();
    }

    const data = await validateUploadBody(body);
    // ----------------------------------------
    // here I do some validation before the upload process.
    // throw strapi.errors.badRequest('');
    let validationFail = true;
    if (validationFail) {
      throw strapi.errors.badRequest('WRONG SIZE!!11');
    }
    // ----------------------------------------
    const uploadedFiles = await uploadService.upload({ data, files }, { user });

    ctx.body = pm.sanitize(uploadedFiles, { action: ACTIONS.read, withPrivate: false });
  },
Cute Capybara