| 487 | |
| 488 | @deconstructible |
| 489 | class MaxLengthValidator(BaseValidator): |
| 490 | message = ngettext_lazy( |
| 491 | "Ensure this value has at most %(limit_value)d character (it has " |
| 492 | "%(show_value)d).", |
| 493 | "Ensure this value has at most %(limit_value)d characters (it has " |
| 494 | "%(show_value)d).", |
| 495 | "limit_value", |
| 496 | ) |
| 497 | code = "max_length" |
| 498 | |
| 499 | def compare(self, a, b): |
| 500 | return a > b |
| 501 | |
| 502 | def clean(self, x): |
| 503 | return len(x) |
| 504 | |
| 505 | |
| 506 | @deconstructible |