109 | | if self.max_length is not None and len(value) > self.max_length: |
110 | | raise ValidationError(gettext(u'Ensure this value has at most %d characters.') % self.max_length) |
111 | | if self.min_length is not None and len(value) < self.min_length: |
112 | | raise ValidationError(gettext(u'Ensure this value has at least %d characters.') % self.min_length) |
| 109 | value_length = len(value) |
| 110 | if self.max_length is not None and value_length > self.max_length: |
| 111 | raise ValidationError(gettext(u'Ensure this value has at most %d characters (it has %d).') % (self.max_length, value_length)) |
| 112 | if self.min_length is not None and value_length < self.min_length: |
| 113 | raise ValidationError(gettext(u'Ensure this value has at least %d characters (it has %d).') % (self.min_length, value_length)) |