Allow empty strings on select
prompt
#99
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The current
required
validation approach is a "one size fits all" in terms of what is considered invalid when a prompt is required.For a
text
prompt, an empty string from the user shouldn't be accepted when the prompt is required. But with aselect
prompt, it's possible to pass an empty string key as one of the configuredoptions
(potentially as a marker for something), and it seems unreasonable that a configured option would cause a validation error by default.This PR addresses this by allowing each prompt to configure what should be considered invalid when the prompt is required. For now, I don't see a need to configure this for every prompt, so I've kept the current values as the "default" set and just updated the
SelectPrompt
with an override.It's still possible to add a custom validation handler to prevent a configured option from being selected if needed.
It was also pointed out in #98 that setting the
$required
value to an empty string would disable validation due to truthy check, so I've also tightened this up.Fixes #98.