@@ -230,7 +230,7 @@ def validate_patternProperties(self, patternProperties, instance, schema):
230
230
231
231
for pattern , subschema in iteritems (patternProperties ):
232
232
for k , v in iteritems (instance ):
233
- if re .match (pattern , k ):
233
+ if re .search (pattern , k ):
234
234
for error in self .iter_errors (v , subschema ):
235
235
yield error
236
236
@@ -346,7 +346,7 @@ def validate_uniqueItems(self, uI, instance, schema):
346
346
yield ValidationError ("%r has non-unique elements" % instance )
347
347
348
348
def validate_pattern (self , patrn , instance , schema ):
349
- if self .is_type (instance , "string" ) and not re .match (patrn , instance ):
349
+ if self .is_type (instance , "string" ) and not re .search (patrn , instance ):
350
350
yield ValidationError ("%r does not match %r" % (instance , patrn ))
351
351
352
352
def validate_format (self , format , instance , schema ):
@@ -710,28 +710,29 @@ def is_ip_address(instance):
710
710
return False
711
711
712
712
713
- @FormatChecker .cls_checks ("ipv6" )
714
- def is_ipv6 (instance ):
715
- """
716
- Check whether the instance is a valid IPv6 address.
713
+ if hasattr (socket , "inet_pton" ):
714
+ @FormatChecker .cls_checks ("ipv6" )
715
+ def is_ipv6 (instance ):
716
+ """
717
+ Check whether the instance is a valid IPv6 address.
717
718
718
- :argument str instance: the instance to check
719
- :rtype: bool
719
+ :argument str instance: the instance to check
720
+ :rtype: bool
720
721
721
- >>> is_ipv6("::1")
722
- True
723
- >>> is_ipv6("192.168.0.1")
724
- False
725
- >>> is_ipv6("1:1:1:1:1:1:1:1:1")
726
- False
722
+ >>> is_ipv6("::1")
723
+ True
724
+ >>> is_ipv6("192.168.0.1")
725
+ False
726
+ >>> is_ipv6("1:1:1:1:1:1:1:1:1")
727
+ False
727
728
728
- """
729
+ """
729
730
730
- try :
731
- socket .inet_pton (socket .AF_INET6 , instance )
732
- return True
733
- except socket .error :
734
- return False
731
+ try :
732
+ socket .inet_pton (socket .AF_INET6 , instance )
733
+ return True
734
+ except socket .error :
735
+ return False
735
736
736
737
737
738
@FormatChecker .cls_checks ("host-name" )
0 commit comments