Skip to content

Commit

Permalink
fix: "0" should be acceptable
Browse files Browse the repository at this point in the history
closes #4
  • Loading branch information
3cp committed Nov 21, 2019
1 parent d38c043 commit c0f4909
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/run-questionnaire.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ async function run(questions, {

async function textPrompt(question, {predefinedProperties, unattended, _debug}) {
const {name} = question;
if (!name.match(/^[a-zA-Z1-9-]+$/)) {
if (!name.match(/^[a-zA-Z0-9-]+$/)) {
throw new SoftError(`Name ${JSON.stringify(name)} is invalid. Only accept letters, numbers, and dash(-).\n` +
'In question:\n' + JSON.stringify(question, null, 2) + '\n\n');
}
Expand Down Expand Up @@ -130,7 +130,7 @@ async function selectPrompt(question, pickedFeatures, {preselectedFeatures, unat
'In question:\n' + JSON.stringify(question, null, 2) + '\n\n');
}

if (c.value && (typeof c.value !== 'string' || !c.value.match(/^[a-zA-Z1-9-]*$/))) {
if (c.value && (typeof c.value !== 'string' || !c.value.match(/^[a-zA-Z0-9-]*$/))) {
throw new SoftError(`Value ${JSON.stringify(c.value)} is invalid. Only accept letters, numbers, and dash(-).\n` +
'In question:\n' + JSON.stringify(question, null, 2) + '\n\n');
}
Expand Down
2 changes: 1 addition & 1 deletion lib/skeleton-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const defaultNamePrompt = {
name: 'name',
message: 'Please name this new project:',
default: 'my-app',
validate: value => value.match(/^[a-zA-Z1-9_-]+$/) ? null :
validate: value => value.match(/^[a-zA-Z0-9_-]+$/) ? null :
'Please only use letters, numbers, dash(-) and underscore(_).'
};

Expand Down

0 comments on commit c0f4909

Please sign in to comment.