-
Notifications
You must be signed in to change notification settings - Fork 278
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
Prompt validation does not visualize the output (errors) #69
Comments
throw the error instead of returning it validate: function (val) {
if (val != 'test') {
throw "Please answer with the word test";
}
} |
@jackyjieliu will try, however I doubt that's going to be the issue, I'm positive that it is vorpal who surpresses the errors, since inquirer.js (used by vorpal) tells us to do it by returning an errorMessage. see the third input in their examples. https://github.com/SBoudrias/Inquirer.js/blob/master/examples/input.js // ...
{
type: "input",
name: "phone",
message: "What's your phone number",
validate: function( value ) {
var pass = value.match(/^([01]{1})?[\-\.\s]?\(?(\d{3})\)?[\-\.\s]?(\d{3})[\-\.\s]?(\d{4})\s?((?:#|ext\.?\s?|x\.?\s?){1}(?:\d+)?)?$/i);
if (pass) {
return true;
} else {
return "Please enter a valid phone number";
}
}
}
// ... |
Got it. Will check out as soon as I can! |
I've got the same problem here, |
This is a tough one since Vorpal has completely taken over rendering, so it'll probably also have to take over looking for the validate parameter, calling it, and rendering the output. |
Yes, that's correct. |
I've just created a PR that hopefully fix the issue. I've tested in one project I'm working and it fixes the issue on the 3 instances I'm validating. |
using inquirer a prompt with validate function should show the validate output, but with vorpal it is somehow omitted.
in Inquirer you can see this work perfectly in the
examples/input.js
example. however the error gets lost somewhere in the process within vorpal I assume.The text was updated successfully, but these errors were encountered: