You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have an artisan command that accepts arguments for when it needs to be called programmatically.
One of the arguments/inputs is of type text. I noted when I supplied the text argument programmatically that prompts validated it and blocked the artisan command from running which is great! It used my custom call back.
I thought this was default behaviour - so later when I added a select prompt I expected it do do the same but noted that it does not and think this might be a bug?
I checked the docs and you can add validation to the select method.
Hoping I spotted something!
Steps To Reproduce
In a Laravel project with the prompts package included
Set up an artisan command
Include these files
use Illuminate\Contracts\Console\PromptsForMissingInput;
use function Laravel\Prompts\text;
use function Laravel\Prompts\select;
implement PromptsForMissingInput in the artisan command class
Ensure that your command can take an arguement for the text property
Add text property
Add validation that would block an invalid text value
Pass invalid text value via CLI argument and watch it get blocked
Repeat above steps but with select prompt
Notice that it does not get blocked when submitting as a CLI argument and that the artisan command continues to run
The text was updated successfully, but these errors were encountered:
JonathanAspeling
changed the title
Select Validation does not handle argument supplied on CLI
Select Validation does not handle argument supplied via CLI
May 10, 2024
I made a reasoning error. Thought it was a cool feature that the validation of the promptForMissingArgumentsUsing bits also got applied/exercised if you pass in arguments programmatically when actually I had a check function in the artisan handle method that was catching the issues when called programmatically!
Really great package - enjoying getting into it! <3
Laravel Prompts Version
v0.1.15
Laravel Version
v10.44.0 ./de
PHP Version
8.2.15
Operating System & Version
Linux Container
Terminal Application
n/a
Description
Good day,
I trust you are doing well!
In short:
I have an artisan command that accepts arguments for when it needs to be called programmatically.
One of the arguments/inputs is of type text. I noted when I supplied the text argument programmatically that prompts validated it and blocked the artisan command from running which is great! It used my custom call back.
I thought this was default behaviour - so later when I added a select prompt I expected it do do the same but noted that it does not and think this might be a bug?
I checked the docs and you can add validation to the select method.
Hoping I spotted something!
Steps To Reproduce
The text was updated successfully, but these errors were encountered: