Opened 6 months ago
Closed 6 months ago
#35445 closed Bug (invalid)
Adding model field validators to FloatField and IntegerField is not possible.
Reported by: | AjmalPonneth | Owned by: | AjmalPonneth |
---|---|---|---|
Component: | Core (Other) | Version: | 5.0 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Adding validators like MinLengthValidator, and MaxLengthValidator to the float field causes a TypeError "object of type 'float' has no len()" when saving the instance from admin.
Change History (1)
comment:1 by , 6 months ago
Component: | Database layer (models, ORM) → Core (Other) |
---|---|
Resolution: | → invalid |
Status: | assigned → closed |
Note:
See TracTickets
for help on using tickets.
Hi AjmalPonneth,
MinLengthValidator and MaxLengthValidator are not meant to be used for floats as it is checking the length. You may want to use MinValueValidator and MaxValueValidator.
If you want to make some tweaks to the docs around which types the validators can be used for, feel free 👍