Skip to content

Fix: Add runtime validation for _correctRange values (fixes #231)#232

Open
swashbuck wants to merge 1 commit intomasterfrom
issue/231
Open

Fix: Add runtime validation for _correctRange values (fixes #231)#232
swashbuck wants to merge 1 commit intomasterfrom
issue/231

Conversation

@swashbuck
Copy link
Copy Markdown
Contributor

Fixes #231

Fix

  • Add validateCorrectRange() method to SliderModel that runs during init(), before setupModelItems()
  • Detect and correct invalid _correctRange configurations with console warnings:
    • Inverted range (_bottom > _top) - values are swapped
    • Out-of-bounds values - clamped to _scaleStart/_scaleEnd
    • Misaligned step values - snapped to nearest valid _scaleStep increment

Testing

  1. Configure a Slider with an inverted range (e.g. _bottom: 9, _top: 4) - verify console warning and correct scoring
  2. Configure with out-of-bounds values (e.g. _bottom: 50 on a scale ending at 10) - verify clamping and warning
  3. Configure with step-misaligned values (e.g. _bottom: 3 with _scaleStep: 2 starting at 1) - verify snapping to nearest step
  4. Verify normal valid ranges still work without warnings
  5. Verify _correctAnswer mode is unaffected (validation skips when _correctAnswer is set)

Performance Impact

None - validation runs once during init() with O(1) operations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Needs Reviewing

Development

Successfully merging this pull request may close these issues.

No runtime validation of _correctRange values

2 participants