-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
SelectPrompt $required is not allowed to be false #98
Comments
Hey @code-distortion,
Before the change, It wasn't intended for users to ever get a required validation error when running the I'm curious how you were able to set I think the real issue is that the validation check should allow empty-strings for the I'll work up a PR to fix this.
Agreed. It's a bit of a hack that relies on a falsy check. |
Hi Jess. Thank you, that's great. I understand now. Sorry for the confusion. In the first example I showed Your proposed solution of allowing the empty-string option to be chosen for select inputs seems like the right idea to me too. |
Great! #99 should solve this. Thanks for your help! |
Yes, that's fixed it up for me. Thank you. |
Laravel Prompts Version
v0.1.12
Laravel Version
v10.29.0
PHP Version
8.2.11
Operating System & Version
Debian GNU/Linux 12 (bookworm) (php:8.2.11-fpm docker image)
Terminal Application
GNOME Terminal
Description
Hi Jess and Co. Prompts is a useful package and I appreciate the effort put in to it.
The relatively recent change f48bc94 forces SelectPrompt's
$required bool|string
to not be false anymore.This broke the prompts for me because of the way I use the SelectPrompt.
In my project, I give the user a number of options to choose from. The last option is sometimes called "Back" and sometimes called "Quit", and has a key of
''
(an empty string). For me an empty string is a consistent way of checking that the user wants to return from the current prompt / go back / exit / quit etc without having to worry about the wording. e.g.(My actual code is abstracted and the $options are passed in, so it's less hard-coded than this).
I can get around it by setting $required to
''
, but it seems odd to solve it that way.The commit explicitly checks to make sure that $required is not false, so I thought I'd ask about the reason behind that? Or am I simply not using it as intended?
Steps To Reproduce
The Quit option can't be picked.
The text was updated successfully, but these errors were encountered: