AlecAivazis / survey

A golang library for building interactive and accessible prompts with full support for windows and posix terminals.
MIT License
4.08k stars 350 forks source link

survey.Select accepts invalid response, returns empty string #205

Closed ahmetb closed 5 years ago

ahmetb commented 5 years ago

If I filter down options in survey.Select.Options by typing random stuff like asdfafdafsa and hit return, I get no error from the survey.AskOne.

It feels like when a choice is not made and the code exits, it should be returning an error so that I don't have to check for empty string.

Is this a valid assessment?

AlecAivazis commented 5 years ago

Hm I definitely agree that's not the right behavior. I think a better experience is not to accept the return if there are no options that are visible when the filter is applied. I don't think AskOne should check if there's a response unless you passed the survey.Required validator

ahmetb commented 5 years ago

This makes sense. Thanks.