Ticket #2746: validators.py.diff

File validators.py.diff, 953 bytes (added by henrik_kroeger@…, 18 years ago)
Line 
1*** validators.py 2006-09-16 15:39:36.000000000 +0200
2--- validators.py.new 2006-09-16 15:38:30.000000000 +0200
3***************
4*** 29,34 ****
5--- 29,35 ----
6 phone_re = re.compile(r'^[A-PR-Y0-9]{3}-[A-PR-Y0-9]{3}-[A-PR-Y0-9]{4}$', re.IGNORECASE)
7 slug_re = re.compile(r'^[-\w]+$')
8 url_re = re.compile(r'^https?://\S+$')
9+ mac_re = re.compile(r'^([0-9a-fA-F][0-9a-fA-F]:){5}([0-9a-fA-F][0-9a-fA-F])$')
10
11 lazy_inter = lazy(lambda a,b: str(a) % b, str)
12
13***************
14*** 101,106 ****
15--- 102,111 ----
16 if not ip4_re.search(field_data):
17 raise ValidationError, gettext("Please enter a valid IP address.")
18
19+ def isValidMACAddress(field_data, all_data):
20+ if not mac_re.search(field_data):
21+ raise ValidationError, gettext("Please enter a valid MAC address.")
22+
23 def isNotEmpty(field_data, all_data):
24 if field_data.strip() == '':
25 raise ValidationError, gettext("Empty values are not allowed here.")
Back to Top