Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly validate maxInclusive datatypes #1186

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions arelle/XmlValidate.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,10 +473,10 @@ def validateValue(
and xValue < 0) or
(baseXsdType == "nonPositiveInteger" and xValue > 0) or
(baseXsdType == "positiveInteger" and xValue <= 0) or
(baseXsdType == "byte" and not -128 <= xValue < 127) or
(baseXsdType == "unsignedByte" and not 0 <= xValue < 255) or
(baseXsdType == "short" and not -32768 <= xValue < 32767) or
(baseXsdType == "unsignedShort" and not 0 <= xValue < 65535) or
(baseXsdType == "byte" and not -128 <= xValue <= 127) or
(baseXsdType == "unsignedByte" and not 0 <= xValue <= 255) or
(baseXsdType == "short" and not -32768 <= xValue <= 32767) or
(baseXsdType == "unsignedShort" and not 0 <= xValue <= 65535) or
(baseXsdType == "positiveInteger" and xValue <= 0)):
raise ValueError("{0} is not {1}".format(value, baseXsdType))
if facets:
Expand Down
16 changes: 8 additions & 8 deletions tests/unit_tests/arelle/test_xmlvalidate.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@
{"value": "-129", "expected": ("=", None, INVALID)},
{"value": "-128", "expected": (-128, -128, VALID)},
{"value": "0", "expected": (0, 0, VALID)},
{"value": "126", "expected": (126, 126, VALID)},
{"value": "127", "expected": ("=", None, INVALID)}, # TODO: This and other integer ranges seem to incorrectly exclude the maximum value
{"value": "127", "expected": (127, 127, VALID)},
{"value": "128", "expected": ("=", None, INVALID)},
],
"date": [
{"value": "2025-01-02", "expected": ("=", DateTime(2025, 1, 2), VALID)},
Expand Down Expand Up @@ -339,8 +339,8 @@
{"value": "-32769", "expected": ("=", None, INVALID)},
{"value": "-32768", "expected": (-32768, -32768, VALID)},
{"value": "0", "expected": (0, 0, VALID)},
{"value": "32766", "expected": (32766, 32766, VALID)},
{"value": "32767", "expected": ("=", None, INVALID)},
{"value": "32767", "expected": (32767, 32767, VALID)},
{"value": "32768", "expected": ("=", None, INVALID)},
],
"string": [
{"value": "*", "expected": ("=", "=", VALID)},
Expand All @@ -367,8 +367,8 @@
{"value": "-1", "expected": ("=", None, INVALID)},
{"value": "0", "expected": (0, 0, VALID)},
{"value": "1", "expected": (1, 1, VALID)},
{"value": "254", "expected": (254, 254, VALID)},
{"value": "255", "expected": ("=", None, INVALID)},
{"value": "255", "expected": (255, 255, VALID)},
{"value": "256", "expected": ("=", None, INVALID)},
],
"unsignedInt": [
{"value": "-1", "expected": ("=", None, INVALID)},
Expand All @@ -384,8 +384,8 @@
{"value": "-1", "expected": ("=", None, INVALID)},
{"value": "0", "expected": (0, 0, VALID)},
{"value": "1", "expected": (1, 1, VALID)},
{"value": "65534", "expected": (65534, 65534, VALID)},
{"value": "65535", "expected": ("=", None, INVALID)},
{"value": "65535", "expected": (65535, 65535, VALID)},
{"value": "65536", "expected": ("=", None, INVALID)},
],
"XBRLI_DATEUNION": [
{"value": "2025-01-02", "expected": ("=", DateTime(2025, 1, 2), VALID)},
Expand Down
Loading