OpenSlides/openslides/poll/serializers.py
FinnStutzenstein 9323bdef20 Added config for more verbose errors on reset password
- Added settings.py docs
- Fixed left-overs from #4920
- Reworked all server messages to a new argument formet, so that the
client can translate server messages
2019-09-03 14:47:45 +02:00

20 lines
599 B
Python

from ..utils.rest_api import ValidationError
def default_votes_validator(data):
"""
Use this validator in your poll serializer. It checks that the values
for the default votes (see models.CollectDefaultVotesMixin) are greater
than or equal to -2.
"""
for key in data:
if (
key in ("votesvalid", "votesinvalid", "votescast")
and data[key] is not None
and data[key] < -2
):
raise ValidationError(
{"detail": "Value for {0} must not be less than -2", "args": [key]}
)
return data