-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Any way to cast the input? #1383
Comments
Hey, I'm not against re-adding a good number prompt if you want to send a PR! I didn't reimplement as I found the previous UX bad, and didn't care much about it. With the input prompt, for now I would do something: const answer = parseInt(
await input({
message: 'Provide a number:',
validate: (value) => !Number.isNaN(value) || 'You must provide a number',
}),
10,
); |
Yes, workarounds are possible but less nicer than the old number prompt. |
In the old
inquirer
there was a Number input, Im trying to do something similar with the new@inquirer/prompts
and wonder if there is a way to cast the value before it gets to thevalidate
method. Any idea?I know I can do the cast after calling
await input
but:validate
method gets a string and I need to "parse" it there as well.Thx.
The text was updated successfully, but these errors were encountered: