mokkabonna / inquirer-autocomplete-prompt

Autocomplete prompt for inquirer
ISC License
354 stars 82 forks source link

validate value is empty #40

Closed andykais closed 4 years ago

andykais commented 7 years ago
{
    type: 'autocomplete',
    name: 'name',
    message: 'which do you choose?',
    source: (answersSoFar, input) => search(input),
    suggestOnly: true,
    validate: value => console.log(value)
}

using

    "inquirer-autocomplete-prompt": "^0.11.0",

value passed to validate is empty, search is async.

It would also be nice if I could validate an input even when suggestOnly is false. There are times when I want to check async things and the validate step is the most appropriate place to do it.

mokkabonna commented 7 years ago

This seems to be working fine in the example.js, what OS/node combo do you have? Does the example also not work for you?

As for introducing validate when suggestOnly false I don't think I want to introduce that. I want to mimic as much as possible the list input in inquirer. It does not have the validate method. You should rather make sure in "search" that only valid options are provided.