Skip to content

Conversation

@leandroradusky
Copy link
Contributor

@leandroradusky leandroradusky commented Feb 10, 2023

Close #2173.

In Elixir,

iex(2)> Integer.parse("22.1")
{22, ".1"}
iex(3)> Float.parse("22.1")  
{22.1, ""}

Then, the methods is_numeric_permissive & is_numeric were accepting float values and passed them through.

While before it was continuing with the survey, now:

image

Note: is easy to round the integer part and get it: I moved forward accepting integers strictly, and returning false otherwise (and not the number rounded to an integer).

Note 2: this was happening only in SMS mode (it couldn't happen in phone channels ─an error is thrown upon responses containing # or *─, neither in the mobile web mode, where ─at least in the simulator─ the validation is performed well.

@leandroradusky leandroradusky self-assigned this Feb 10, 2023
Copy link
Contributor

@ysbaddaden ysbaddaden left a comment

Choose a reason for hiding this comment

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

Well found! Could you add tests in test/ask/runtime/flow_test.exs? There are a number of examples under describe "numeric steps", but having a few tests around floats would help.

@leandroradusky leandroradusky merged commit 4983c24 into main Feb 15, 2023
@ysbaddaden ysbaddaden deleted the fix/2173-only-accept-int-numeric-answers branch February 15, 2023 16:16
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.

Only accept integers for numeric answers

3 participants