Skip to content

Commit 73d8df7

Browse files
committed
Added ValidationLessThanError/ValidationGreaterThanError
1 parent 104f311 commit 73d8df7

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

kaitaistruct.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,3 +418,21 @@ def __init__(self, expected, actual, io, src_path):
418418
super(ValidationNotEqualError, self).__init__("not equal, expected %s, but got %s" % (repr(expected), repr(actual)), io, src_path)
419419
self.expected = expected
420420
self.actual = actual
421+
422+
class ValidationLessThanError(ValidationFailedError):
423+
"""Signals validation failure: we required "actual" value to be
424+
greater than or equal to "min", but it turned out that it's not.
425+
"""
426+
def __init__(self, min, actual, io, src_path):
427+
super(ValidationLessThanError, self).__init__("not in range, min %s, but got %s" % (repr(min), repr(actual)), io, src_path)
428+
self.min = min
429+
self.actual = actual
430+
431+
class ValidationGreaterThanError(ValidationFailedError):
432+
"""Signals validation failure: we required "actual" value to be
433+
less than or equal to "max", but it turned out that it's not.
434+
"""
435+
def __init__(self, max, actual, io, src_path):
436+
super(ValidationGreaterThanError, self).__init__("not in range, max %s, but got %s" % (repr(max), repr(actual)), io, src_path)
437+
self.max = max
438+
self.actual = actual

0 commit comments

Comments
 (0)