Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

chore: add validation for numeric input and handle out of range values #2030

Merged
merged 3 commits into from
Mar 4, 2025

Conversation

github-roushan
Copy link
Contributor

@github-roushan github-roushan commented Feb 25, 2025

Describe Your Changes

  1. Numeric Validation: Added a check to ensure user input contains only numeric characters using std::all_of and ::isdigit.
  2. Error Handling: Created getNumericValue to convert the input string to an integer with std::stoi, returning std::optional<int> to handle invalid or out-of-range values.
  3. Range Check: Validates that the numeric value is within the acceptable range (1 to options.size()), returning std::nullopt if out of bounds.

Fixes Issues

  • Closes #
  • Closes #

Self Checklist

  • Added relevant comments, esp in complex areas

  • Updated docs (for bug fixes / features)

  • Created issues for follow-up changes or refactoring needed

  • Before
    Screenshot from 2025-02-25 14-58-58

  • After
    Screenshot from 2025-02-25 15-03-41

@github-roushan
Copy link
Contributor Author

@vansangpfiev
can you look at this Pr for input validation.

Copy link
Contributor

@vansangpfiev vansangpfiev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Just some nitpick.

@vansangpfiev vansangpfiev changed the title Add validation for Numeric Input and handle out of range values chore: Add validation for Numeric Input and handle out of range values Mar 4, 2025
@vansangpfiev vansangpfiev changed the title chore: Add validation for Numeric Input and handle out of range values chore: add validation for numeric input and handle out of range values Mar 4, 2025
@vansangpfiev vansangpfiev merged commit 8b36837 into menloresearch:dev Mar 4, 2025
8 checks passed
@github-roushan github-roushan deleted the patch-2 branch March 4, 2025 07:15
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants