Fix #4874. Checking restrictions of the wrong data type will now returned a failed result instead of an exception.

This commit is contained in:
Dion Moult
2024-06-20 13:22:16 +10:00
parent fbefe8c555
commit b87a6bc15c
+3
View File
@@ -1025,6 +1025,7 @@ class Restriction:
if other is None: if other is None:
return False return False
for constraint, value in self.options.items(): for constraint, value in self.options.items():
try:
if constraint == "enumeration": if constraint == "enumeration":
if other not in [cast_to_value(v, other) for v in value]: if other not in [cast_to_value(v, other) for v in value]:
return False return False
@@ -1056,6 +1057,8 @@ class Restriction:
elif constraint == "minInclusive": elif constraint == "minInclusive":
if float(other) < float(value): if float(other) < float(value):
return False return False
except ValueError:
return False
return True return True
def __str__(self): def __str__(self):