Ticket #737: validators.py.diff
File validators.py.diff, 1.2 KB (added by , 19 years ago) |
---|
-
validators.py
19 19 ansi_datetime_re = re.compile('^%s %s$' % (_datere, _timere)) 20 20 email_re = re.compile(r'^[-\w.+]+@\w[\w.-]+$') 21 21 integer_re = re.compile(r'^-?\d+$') 22 ip4_re = re.compile(r'^ \d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$')22 ip4_re = re.compile(r'^(25[0-5]|2[0-4]\d|[0-1]?\d?\d)(\.(25[0-5]|2[0-4]\d|[0-1]?\d?\d)){3}$') 23 23 phone_re = re.compile(r'^[A-PR-Y0-9]{3}-[A-PR-Y0-9]{3}-[A-PR-Y0-9]{4}$', re.IGNORECASE) 24 24 slug_re = re.compile(r'^[-\w]+$') 25 25 url_re = re.compile(r'^http://\S+$') … … 93 93 raise ValidationError, _("Enter valid e-mail addresses separated by commas.") 94 94 95 95 def isValidIPAddress4(field_data, all_data): 96 if ip4_re.search(field_data): 97 valid_parts = [el for el in field_data.split('.') if 0 <= int(el) <= 255] 98 if len(valid_parts) == 4: 99 return 100 raise ValidationError, _("Please enter a valid IP address.") 96 if not ip4_re.search(field_data): 97 raise ValidationError, _("Please enter a valid IP address.") 101 98 102 99 def isNotEmpty(field_data, all_data): 103 100 if field_data.strip() == '':