From 3c9d99054ecce9059d330188d7a27c6084f68f6c Mon Sep 17 00:00:00 2001 From: Bruk Habtu Date: Mon, 20 Jan 2014 12:05:36 -0500 Subject: [PATCH] Fixed string formatting in the length validator The length validator would return 'Value must be no more than %(max)d characters long' without substituting min/max. Replacing with new style string formatting has fixed this. --- formalchemy/validators.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/formalchemy/validators.py b/formalchemy/validators.py index 7a91533..c006531 100644 --- a/formalchemy/validators.py +++ b/formalchemy/validators.py @@ -145,9 +145,9 @@ def length(min=0, max=None): max_ = max def f(value, field=None): if len(value) < min_: - raise ValidationError(_('Value must be at least %(min)d characters long') % {'min': min_}) + raise ValidationError(_('Value must be at least {0} characters long').format(min_)) if max_ is not None and len(value) > max_: - raise ValidationError(_('Value must be no more than %(max)d characters long') % {'max': max_}) + raise ValidationError(_('Value must be no more than {0} characters long').format(max_)) return f def maxlength(max):