Ticket #14608: inphone.diff

File inphone.diff, 823 bytes (added by lawgon, 4 years ago)

diff between current forms.py and proposed forms.py

Line 
17c7
2< from django.forms.fields import Field, RegexField, Select, CharField
3---
4> from django.forms.fields import Field, RegexField, Select
510d9
6< from django.utils.translation import ugettext_lazy as _
714d12
8<         
958,74d55
10<         
11< phone_digits_re = re.compile(r'^0\d{2,4}[-\s]{1}[1-9]\d{6}$')
12<
13< class INPhoneNumberField(CharField):
14<     default_error_messages = {
15<         'invalid': _('Phone numbers must be in 0STD-XXXXXXX or 0STD XXXXXXX format.'),
16<     }
17<
18<     def clean(self, value):
19<         super(INPhoneNumberField, self).clean(value)
20<         if value in EMPTY_VALUES:
21<             return u''
22<         value = smart_unicode(value)
23<         m = phone_digits_re.match(value)
24<         if m:
25<             return u'%s' % (value)
26<         raise ValidationError(self.error_messages['invalid'])
Back to Top