# Domain validation error customization

**URL:** https://discuss.tryton.org/t/domain-validation-error-customization/4623
**Category:** Developer
**Created:** [September 15, 2021, 10:03am UTC](https://discuss.tryton.org/t/domain-validation-error-customization/4623 "2021-09-15T10:03:30Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![taiheui0114](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/t/35a633/32.png) [@taiheui0114](https://discuss.tryton.org/u/taiheui0114)
#### Post date: [September 15, 2021, 10:03am UTC](https://discuss.tryton.org/t/domain-validation-error-customization/4623/1 "2021-09-15T10:03:30Z")

</div>

Hi,

I would like to ask if there is any way to customize/improve the domain validation error? To make it more concise and human readable.

Thank you.

 ![image](https://discuss-cdn.tryton.org/uploads/default/original/2X/3/3da825fe9272d4b3c305059dede12f24bc1fc539.png)

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [September 15, 2021, 10:07am UTC](https://discuss.tryton.org/t/domain-validation-error-customization/4623/2 "2021-09-15T10:07:07Z")

</div>

It is using the same syntax as the search bar (aka the domain parser).  
If you can find a better way to express some domain, fill free to [propose it](https://www.tryton.org/contribute#develop).

---

<div class="post-metadata">

### Author: ![JCavallo](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/j/48db29/32.png) [@JCavallo](https://discuss.tryton.org/u/JCavallo)
#### Post date: [September 15, 2021, 11:52am UTC](https://discuss.tryton.org/t/domain-validation-error-customization/4623/3 "2021-09-15T11:52:33Z")

</div>

@ced I once thought of defining a “per field” error message for domain errors, which would then be used in place of the auto-generated one. This would require a way to make it extensible (when a module modifies the domain of an existing field), and having a way to access the current records field values, but I do not see why it would not be possible.

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [September 15, 2021, 3:05pm UTC](https://discuss.tryton.org/t/domain-validation-error-customization/4623/4 "2021-09-15T15:05:31Z")

</div>

The big issue with such proposal feature is that it will be impossible to guarantee that the error message is providing the correct information that are actually in the domain.

---

<div class="post-metadata">

### Author: ![JCavallo](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/j/48db29/32.png) [@JCavallo](https://discuss.tryton.org/u/JCavallo)
#### Post date: [September 15, 2021, 3:12pm UTC](https://discuss.tryton.org/t/domain-validation-error-customization/4623/5 "2021-09-15T15:12:47Z")

</div>

Yes, I agree that this may prove difficult to ensure, that is why I never spent any time on this.

However, I agree with @taiheui0114 that even for some simple domains (like the one he provided as an example), the current approach can be frustrating.

Maybe it could be possible to still provide a “technical explanation” (the current message) by clicking the original, maybe innaccurate message ?

My favorite idea was to add an optionnal entry on each clause, however this risks breaking every searcher… Something like:

```python
clause = ('account.company', '=', Eval('company'), lazy_gettext('msg_account_company_must_match'))

domain = ['OR', clause1, clause2, lazy_gettext('msg_full_domain')]

```

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [September 15, 2021, 4:48pm UTC](https://discuss.tryton.org/t/domain-validation-error-customization/4623/6 "2021-09-15T16:48:21Z")

</div>

I really do not see what is not clear in the current message. The Quantity must be greater than 0 and less or equals to 8338.  
One possible improvement would be to display: “Quantity: between 0 and 8338”. But then we loose the clarity of the mathematical symbol which define if borders are included or exclude.  
Another option would be to use the mathematical segment notation: “Quantity: ]0,8338]”. But I’m not sure it will be clearer to user.

So finally I do not see what extra message could really improve the existing one.
