-
-
Notifications
You must be signed in to change notification settings - Fork 302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat: validate
function should provide values
as 2nd argument
#273
Comments
I just wanted to confirm that I really badly need this too. I tried to look into the code, and got a little lost (although I am drowning in my own code right now) My solution (hopefully temporary, to be fixed once this issue is addressed) was to do this:
Not ideal but it does the job... |
I too need this badly - I took a stab at it and have tested it on my current project. Please provide some feedback as I'd love to get this in (see auto-linked message above). |
Problem
Prompts chain of Start/End dates, End date should not be before Start date.
Solution
Describe alternatives you've considered
Multiple prompts or
onSubmit
hacks as mentioned in #2.If we already have
validate
, makes sense to allow access to previous answers.I was also thinking about
min
andmax
values that could make sense (additionally)...e.g. Once
startDate
is selected,endDate
could havemin: (prev, values) => values.startDate
and then the user can't select a date before that date.Additional context
Maybe it makes sense, for consistency, to add
prompt
as the 3rd argument, just like some of the other props https://github.com/terkelg/prompts#-prompt-objects. Though I'm not sure what would be the use case for that.Btw,
format
doesn't getprompt
as a 3rd argument but the docs in the same section say:The text was updated successfully, but these errors were encountered: