Show More
@@ -1,26 +1,25 b'' | |||
|
1 | 1 | import os |
|
2 | 2 | import re |
|
3 | 3 | |
|
4 | 4 | import ipaddress |
|
5 | 5 | import colander |
|
6 | 6 | |
|
7 | 7 | from rhodecode.translation import _ |
|
8 | 8 | from rhodecode.lib.utils2 import glob2re |
|
9 | 9 | |
|
10 | 10 | |
|
11 | 11 | def ip_addr_validator(node, value): |
|
12 | 12 | try: |
|
13 | 13 | # this raises an ValueError if address is not IpV4 or IpV6 |
|
14 | 14 | ipaddress.ip_network(value, strict=False) |
|
15 | 15 | except ValueError: |
|
16 | 16 | msg = _(u'Please enter a valid IPv4 or IpV6 address') |
|
17 | 17 | raise colander.Invalid(node, msg) |
|
18 | 18 | |
|
19 | 19 | |
|
20 | 20 | def glob_validator(node, value): |
|
21 | 21 | try: |
|
22 | 22 | re.compile('^' + glob2re(value) + '$') |
|
23 | 23 | except Exception: |
|
24 | raise | |
|
25 | 24 | msg = _(u'Invalid glob pattern') |
|
26 | 25 | raise colander.Invalid(node, msg) |
General Comments 0
You need to be logged in to leave comments.
Login now