# How to give limit for entering values in Integer, Numeric

**URL:** https://discuss.tryton.org/t/how-to-give-limit-for-entering-values-in-integer-numeric/3065
**Category:** Developer
**Created:** [July 24, 2020, 5:35am UTC](https://discuss.tryton.org/t/how-to-give-limit-for-entering-values-in-integer-numeric/3065 "2020-07-24T05:35:40Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Rajasekhar](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/rajasekhar/32/544_2.png) [@Rajasekhar](https://discuss.tryton.org/u/Rajasekhar)
#### Post date: [July 24, 2020, 5:35am UTC](https://discuss.tryton.org/t/how-to-give-limit-for-entering-values-in-integer-numeric/3065/1 "2020-07-24T05:35:40Z")

</div>

How can I give the limit for Integer field rather than giving validations for the same.  
For example in case of Char field we give “size”. shown below is the example for Char field` `my\_field\_name = fields.Char(‘my\_string’, size=10)  
How can I do the same for Integer, Numeric field.  
Any help regarding the same will be helpful!!!

---

<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: [July 24, 2020, 8:36am UTC](https://discuss.tryton.org/t/how-to-give-limit-for-entering-values-in-integer-numeric/3065/2 "2020-07-24T08:36:01Z")

</div>

You can set a [domain](https://docs.tryton.org/projects/server/en/latest/ref/models/fields.html#trytond.model.fields.Field.domain) on the field using the field name as field name.  
Eg:

```auto
value = fields.Float("Value", domain=[('value', '>=', 0), ('value', '<', 100)])

```

---

<div class="post-metadata">

### Author: ![Rajasekhar](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/rajasekhar/32/544_2.png) [@Rajasekhar](https://discuss.tryton.org/u/Rajasekhar)
#### Post date: [July 24, 2020, 8:43am UTC](https://discuss.tryton.org/t/how-to-give-limit-for-entering-values-in-integer-numeric/3065/3 "2020-07-24T08:43:43Z")

</div>

@ced The above code worked thanks for the same!!!  
But on saving the record there comes an issue which is that this field after not being given “required” too it needs to be filled or else the record remains unsaved.

---

<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: [July 24, 2020, 8:45am UTC](https://discuss.tryton.org/t/how-to-give-limit-for-entering-values-in-integer-numeric/3065/4 "2020-07-24T08:45:35Z")

</div>

Indeed if you want to allow `None` value, you must make the domain allow it like:

```auto
['OR', ('value', '=', None), [('value', '>=', 0), ('value', '<', 100)]]

```

---

<div class="post-metadata">

### Author: ![system](https://discuss-cdn.tryton.org/uploads/default/original/1X/c6f8ec0a40525cdcd50058c734283450a4b3d38b.png) [@system](https://discuss.tryton.org/u/system)
#### Post date: [August 23, 2020, 8:53am UTC](https://discuss.tryton.org/t/how-to-give-limit-for-entering-values-in-integer-numeric/3065/5 "2020-08-23T08:53:57Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
