Fixed #24636 -- Added model field validation for decimal places and max digits.

This commit is contained in:
Iulia Chiriac 2015-04-14 18:11:12 -04:00 committed by Simon Charette
parent 6f1b09bb5c
commit 75ed590032
6 changed files with 134 additions and 49 deletions

View file

@ -281,3 +281,19 @@ to, or in lieu of custom ``field.clean()`` methods.
.. versionchanged:: 1.8
The ``message`` parameter was added.
``DecimalValidator``
--------------------
.. class:: DecimalValidator(max_digits, decimal_places)
.. versionadded:: 1.9
Raises :exc:`~django.core.exceptions.ValidationError` with the following
codes:
- ``'max_digits'`` if the number of digits is larger than ``max_digits``.
- ``'max_decimal_places'`` if the number of decimals is larger than
``decimal_places``.
- ``'max_whole_digits'`` if the number of whole digits is larger than
the difference between ``max_digits`` and ``decimal_places``.