2 # -*- coding: utf-8 -*-
7 def is_enum(attribute, value):
8 return isinstance(value, str) and value in attribute.allowed
10 def is_bool(attribute, value):
11 return isinstance(value, bool)
13 def is_double(attribute, value):
14 return isinstance(value, float)
16 def is_integer(attribute, value):
17 return isinstance(value, int)
19 def is_string(attribute, value):
20 return isinstance(value, str)
22 def is_time(attribute, value):
23 return isinstance(value, str) # TODO: Missing validation!
25 # TODO: Allow netrefs!
26 def is_ip4_address(attribute, value):
28 ipaddr.IPv4Address(value)
29 except ipaddr.AddressValueError:
33 # TODO: Allow netrefs!
34 def is_ip6_address(attribute, value):
36 ipaddr.IPv6Address(value)
37 except ipaddr.AddressValueError:
41 def is_mac_address(attribute, value):
42 regex = r'^([0-9a-zA-Z]{0,2}:)*[0-9a-zA-Z]{0,2}'
43 found = re.search(regex, value)
44 if not found or value.count(':') != 5: