validate_syntax
Verify dice expression syntax before rolling. Perfect for user input validation and catching errors without dice rolls.
Instructions
Validate a dice expression's syntax without actually rolling any dice.
PURPOSE: Use this tool to check if a dice expression is syntactically correct and can be evaluated before actually rolling it. Perfect for validating user input, testing complex expressions, or checking syntax in application development. This is a read-only operation that doesn't generate random results.
WHEN TO USE:
User input validation: Check if user-provided expression is valid
Testing complex expressions: Verify syntax before committing to a roll
Application development: Validate dice notation in forms/configs
Error prevention: Catch syntax errors before attempting a roll
Teaching: Show users why an expression is invalid
API integration: Validate before passing to game systems
WHEN NOT TO USE:
If you want to actually roll dice (use roll, roll_detailed, or roll_batch)
If the expression is simple and you're confident in its syntax
When immediate rolling is acceptable even if it fails
VALIDATION SCOPE: This tool checks: ✓ Basic dice notation (NdN format) ✓ Arithmetic operators and precedence ✓ Keep/drop/reroll/explode operations ✓ Parentheses matching and nesting ✓ Valid operator combinations ✓ Number format and ranges
This tool does NOT check: ✗ Logical sense (e.g., "1d0" may pass but isn't useful) ✗ Performance implications (e.g., "99999d99999" is valid but slow) ✗ Statistical properties of the roll
COMMON EXAMPLES:
Valid Expressions:
"1d20+5" → ✓ Valid
"4d6kh3" → ✓ Valid
"2d20kh1+5" → ✓ Valid (advantage)
"(1d4+1)*2" → ✓ Valid (parentheses)
"3d6e6" → ✓ Valid (exploding)
Invalid Expressions:
"1d" → ✗ Invalid (missing die size)
"d20+" → ✗ Invalid (incomplete expression)
"1d20kh" → ✗ Invalid (missing keep count)
"roll 1d20" → ✗ Invalid (text instead of pure notation)
"1d20 +" → ✗ Invalid (trailing operator)
USE CASES:
Form Validation: Before saving a custom dice formula in a character sheet, validate it first.
Complex Expression Testing: Testing: "(2d6+3)*1d4kh1" before using in game Validate → If valid, then roll
User Input: User types: "3d8+5" Validate → Show ✓ or explain error → Then allow roll
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| expression | Yes | Dice expression to validate |