Skip to content

fix: prevent invalid input in builder mode numeric fields#10

Merged
mustalk merged 1 commit intomainfrom
bugfix/builder-mode-validation
Jun 1, 2025
Merged

fix: prevent invalid input in builder mode numeric fields#10
mustalk merged 1 commit intomainfrom
bugfix/builder-mode-validation

Conversation

@mustalk
Copy link
Copy Markdown
Owner

@mustalk mustalk commented Jun 1, 2025

Resolves input validation issues in Builder mode where users could input invalid characters in numeric fields. On real devices, users could type minus signs despite coordinates being non-negative. On emulators, users could type any characters including letters and symbols. Implements real-time input filtering and enhanced validation logic.

Issues Fixed

Changes Made

Input Filtering (Prevention)

  • Real-time character filtering in FieldUpdateHandler
  • Numeric fields only accept digits: Plateau Width/Height, Rover Start X/Y
  • No minus signs allowed for coordinate fields (coordinates are non-negative by design)
  • Works consistently across real devices and emulators

Enhanced Validation (Detection)

  • Improved validation logic in ValidationHandler
  • Clear error message differentiation:
    • "Must be a valid number" for invalid format (letters, symbols)
    • "Must be a positive number" for zero values (plateau dimensions)
    • "Must be a non-negative number" for negative values (coordinates)

Comprehensive Testing

  • Input filtering test coverage: Verify invalid characters are filtered
  • Validation test updates: Account for new filtering behavior
  • Edge case handling: Empty strings, mixed input, etc.

User Experience Improvements

Before Fix

  • Real devices: Users could type "-" in coordinate fields
  • Emulators: Users could type "ads" or any characters in numeric fields
  • No immediate feedback
  • Confusing error messages
  • Errors only appeared after focus loss or execution

After Fix

  • Real-time filtering - Invalid characters can't be entered
  • Immediate visual feedback - Only valid digits appear
  • Clear error messages - Distinguish between format and value errors
  • Consistent behavior across device types

Testing

  • Unit Tests: All existing tests pass
  • New Tests: Input filtering behavior coverage
  • Edge Cases: Empty input, mixed characters, boundary values
  • Cross-platform: Works on both real devices and emulators

Manual Testing

  • Try typing minus signs on real device numeric fields > Filtered out in real-time
  • Try typing letters on emulator > Filtered out in real-time
  • Try typing special characters > Filtered out in real-time
  • Valid numeric input > Works as expected
  • Mission execution with valid input > Successful
  • Error messages > Clear and contextual

Impact

  • User Experience: Improved input consistency across devices
  • Data Integrity: Guaranteed valid numeric input
  • Performance: No impact - filtering is lightweight

- Add real-time input filtering for numeric fields:
  * Plateau width/height - digits only
  * Rover start X/Y coordinates - digits only
  * Filters out minus signs on real devices and letters/symbols on emulators

- Enhance validation logic with clearer error messages:
  * "Must be a valid number" for invalid format
  * "Must be a positive number" for zero values
  * "Must be a non-negative number" for negative values

- Add comprehensive test coverage:
  * Input filtering behavior tests
  * Updated validation tests for filtered inputs
  * Edge case handling (empty after filtering)

- UX improvements:
  * Consistent behavior across real devices and emulators
  * Proactive prevention vs reactive error handling
  * Immediate visual feedback during typing
  * Eliminates user frustration from invalid input

- Fixes builder mode input validation issue #9
- All tests passing
@mustalk mustalk merged commit 9622b3f into main Jun 1, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: builder mode accepts invalid characters in numeric input fields

1 participant