opps forgot files

pull/942/head
Frank Wiles 2015-01-28 10:26:23 -06:00
rodzic 9f12c109be
commit da7b96cca6
2 zmienionych plików z 29 dodań i 0 usunięć

Wyświetl plik

@ -0,0 +1,14 @@
from django.test import TestCase
from django.core.exceptions import ValidationError
from wagtail.wagtailcore.validators import validate_not_whitespace
class TestValidators(TestCase):
def test_not_whitespace(self):
validate_not_whitespace('bar')
for test_value in (' ', '\t', '\r', '\n', '\r\n'):
with self.assertRaises(ValidationError):
validate_not_whitespace(test_value)

Wyświetl plik

@ -0,0 +1,15 @@
import re
from django.core.exceptions import ValidationError
from django.utils.translation import ugettext as _
WHITESPACE_RE = re.compile(r'^\s+$')
def validate_not_whitespace(value):
"""
Validate that a value isn't all whitespace, for example in title and
seo_title
"""
if value and WHITESPACE_RE.match(value):
raise ValidationError(_('Value cannot be entirely whitespace characters'))