Skip to content
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

Allow questions can be marked as mandatory #1157

Open
aztack opened this issue Aug 15, 2022 · 2 comments
Open

Allow questions can be marked as mandatory #1157

aztack opened this issue Aug 15, 2022 · 2 comments

Comments

@aztack
Copy link

aztack commented Aug 15, 2022

releated issue: #1091

options = {
  things: {
    message: 'App name?',
    type: 'input',
    required: true
  }
};

If a user does not provide a non-empty app name, keep asking the same question.

@SBoudrias
Copy link
Owner

Today you can use the validate function for this, check the input and make sure there is content; if not return an error message.

I'm leaning towards not augmenting the API with this extra option because:

  1. required would only work on input type prompt
  2. We'd need to decided how to handle getting both required and validate on that prompt
  3. This add an extra internal content that isn't translated; and this has been a recurring issue for international users of the library.

@SBoudrias SBoudrias reopened this Apr 4, 2024
@SBoudrias
Copy link
Owner

I'm revising my opinion in 2024. I'd be happy to add a required property to the new @inquirer/input - with similar implementation to the same option on the checkbox prompt: https://github.com/SBoudrias/Inquirer.js/tree/master/packages/checkbox

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants