# Error is not correct

**URL:** <https://community.forestadmin.com/t/error-is-not-correct/7460>\
**Category:** Help me!\
**Created:** [September 18, 2024, 1:20pm UTC](https://community.forestadmin.com/t/error-is-not-correct/7460 "2024-09-18T13:20:59Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Soufiane](https://avatars.discourse-cdn.com/v4/letter/s/8edcca/32.png) [@Soufiane](https://community.forestadmin.com/u/Soufiane)\
**Post date:** [September 18, 2024, 1:20pm UTC](https://community.forestadmin.com/t/error-is-not-correct/7460/1 "2024-09-18T13:20:59Z")

</div>

I want just this error : Pour modifier un sinistre, merci de bien renseigner le champ “Autre type de sinistre”. but I have this error :

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/b/bf0802424711fe8d3936ae5f6c7b72a9f67c00b6.png)

## Observed behavior

router.put(‘/damages/:id’, permissionMiddlewareCreator.update(), (request, response, next) =\> {  
// Learn what this route does here: [https://docs.forestadmin.com/documentation/v/v6/reference-guide/routes/default-routes#update-a-record](https://docs.forestadmin.com/documentation/v/v6/reference-guide/routes/default-routes#update-a-record)  
const { query, user } = request;  
const recordUpdater = new RecordUpdater(models.damages,user, query);  
const id = request.params.id;  
const data = request.body.data.attributes;  
let body = { damage: {} };

if (data.description) { body.damage.description = data.description; }  
if (data.kind) { body.damage.kind = data.kind; }  
// if (data.declarant\_id) { body.damage. = data. ;}  
if (data.damageDescription) { body.damage.damage\_description = data.damageDescription; }  
if (data.cause) { body.damage.cause = data.cause === ‘’ ? null : data.cause; }  
//if (data.kind) { body.place.kind = data.kind === ‘’ ? null : data.kind; }  
if (data.insuranceReference) { body.damage.insurance\_reference = data.insuranceReference; }  
if (data.repairing) { body.damage.repairing = data.repairing; }  
if (data.step) { body.damage.step = data.step; }  
//if (data.otherType) { body.damage.other\_type = data.otherType; }

if (data.kind===‘other’) {  
body.damage.other\_type= data.otherType;  
}

if (data.kind === ‘other’ && !(data.otherType)) {

```
response.status(400).send(
'Pour modifier un sinistre, merci de bien renseigner le champ "Autre type de sinistre".'
); 

```

}  
else {  
axios.put(`${API_URL}/forest_admin/damages/${id}`, body, {  
headers: {  
‘Authorization’: `Bearer ${process.env.ACCESS_TOKEN}`,  
‘X-CURRENT-USER-EMAIL’: request.user.email  
}  
}).then(async res =\> {  
response.send(await recordUpdater.serialize(res.data));  
}).catch(err =\> {  
console.log(“🚀 ~ err:”, err)  
if (err.response?.data?.error?.message) {  
response.status(400).send(err.response.data.error.message);  
} else {  
response.status(400).send(‘Erreur inattendue, veuillez contacter votre administrateur.’);  
}  
});  
}

});

## Context

Project name: .Sergic  
Team name: gestion  
Environment name: Développement  
Agent (forest package) name & version: 9  
Database type: Postgres  
Recent changes made on your end if any: upgrade to v9

---

<div class="post-metadata">

**Author:** ![Alban\_Bertolini](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/alban_bertolini/32/1077_2.png) [@Alban\_Bertolini](https://community.forestadmin.com/u/Alban_Bertolini)\
**Post date:** [September 18, 2024, 2:14pm UTC](https://community.forestadmin.com/t/error-is-not-correct/7460/2 "2024-09-18T14:14:19Z")

</div>

Hello,  
Can you tell us more details about your bugs. In your description, you ask to have this error: “Pour modifier un sinistre, merci de bien renseigner le champ “Autre type de sinistre”” but in the screenshot it’s the same error.  
Also, can you format your code when you share it please 🙏 It help us a lot.

---

<div class="post-metadata">

**Author:** ![Soufiane](https://avatars.discourse-cdn.com/v4/letter/s/8edcca/32.png) [@Soufiane](https://community.forestadmin.com/u/Soufiane)\
**Post date:** [September 18, 2024, 2:18pm UTC](https://community.forestadmin.com/t/error-is-not-correct/7460/3 "2024-09-18T14:18:10Z")

</div>

I don’have the first message "Ann error occured when trying to edit sinistre "  
I want just this message:  
if (data.kind === ‘other’ && !(data.otherType)) {

```javascript
response.status(400).send(
'Pour modifier un sinistre, merci de bien renseigner le champ "Autre type de sinistre".'
);

```

---

<div class="post-metadata">

**Author:** ![Soufiane](https://avatars.discourse-cdn.com/v4/letter/s/8edcca/32.png) [@Soufiane](https://community.forestadmin.com/u/Soufiane)\
**Post date:** [September 18, 2024, 2:19pm UTC](https://community.forestadmin.com/t/error-is-not-correct/7460/4 "2024-09-18T14:19:13Z")

</div>

```javascript
router.put('/damages/:id', permissionMiddlewareCreator.update(), (request, response, next) => {
  // Learn what this route does here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/routes/default-routes#update-a-record
  const { query, user } = request;
  const recordUpdater = new RecordUpdater(models.damages,user, query);
  const id = request.params.id;
  const data = request.body.data.attributes;
  let body = { damage: {} };

  if (data.description) { body.damage.description = data.description; }
  if (data.kind) { body.damage.kind = data.kind; }
  // if (data.declarant_id) { body.damage. = data. ;}
  if (data.damageDescription) { body.damage.damage_description = data.damageDescription; }
  if (data.cause) { body.damage.cause = data.cause === '' ? null : data.cause; }
  //if (data.kind) { body.place.kind = data.kind === '' ? null : data.kind; }
  if (data.insuranceReference) { body.damage.insurance_reference = data.insuranceReference; }
  if (data.repairing) { body.damage.repairing = data.repairing; }
  if (data.step) { body.damage.step = data.step; }
  //if (data.otherType) { body.damage.other_type = data.otherType; }
  
  
  if (data.kind==='other') {
      body.damage.other_type= data.otherType;
  }

  if (data.kind === 'other' && !(data.otherType)) {
   
    response.status(400).send(
    'Pour modifier un sinistre, merci de bien renseigner le champ "Autre type de sinistre".'
    ); 
    
   
  } 
  else {
    axios.put(`${API_URL}/forest_admin/damages/${id}`, body, {
      headers: {
        'Authorization': `Bearer ${process.env.ACCESS_TOKEN}`,
        'X-CURRENT-USER-EMAIL': request.user.email
      }
    }).then(async res => {
      response.send(await recordUpdater.serialize(res.data));
    }).catch(err => {
      console.log("🚀 ~ err:", err)
      if (err.response?.data?.error?.message) {
        response.status(400).send(err.response.data.error.message);
      } else {
        response.status(400).send('Erreur inattendue, veuillez contacter votre administrateur.');
      }
    });
  }

});

```

---

<div class="post-metadata">

**Author:** ![Alban\_Bertolini](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/alban_bertolini/32/1077_2.png) [@Alban\_Bertolini](https://community.forestadmin.com/u/Alban_Bertolini)\
**Post date:** [September 18, 2024, 2:29pm UTC](https://community.forestadmin.com/t/error-is-not-correct/7460/5 "2024-09-18T14:29:32Z")

</div>

I understand your needs but it’s not possible unfortunately. If you want to custom all the message validation It’s preferable to use smart action with form. In your case, when you overriding a route, it’s not possible 😕

I will push your feedback to our product board 🙂
