fix(dice): parse_dice validates sides >= _MIN_SIDES so d1/1d1 raise DiceParseError instead of leaking the model validator's pydantic ValidationError; drop the dead not-sides_str guard (regex \\d+ already guarantees non-empty) + 3 rejected-notation cases (d1, 1d1, 2D6)
This commit is contained in:
@@ -103,15 +103,13 @@ def parse_dice(text: str) -> DiceExpr:
|
||||
m = _DICE_RE.match(stripped)
|
||||
if m:
|
||||
count_str, sides_str, bonus_str = m.groups()
|
||||
if not sides_str:
|
||||
raise DiceParseError(text)
|
||||
count = int(count_str) if count_str else 1
|
||||
sides = int(sides_str)
|
||||
bonus = int(bonus_str) if bonus_str else 0
|
||||
|
||||
if count == 0:
|
||||
raise DiceParseError(text)
|
||||
if sides < 1:
|
||||
if sides < _MIN_SIDES:
|
||||
raise DiceParseError(text)
|
||||
|
||||
return DiceExpr(count=count, sides=sides, bonus=bonus)
|
||||
|
||||
Reference in New Issue
Block a user