Skip to content
This repository was archived by the owner on Mar 30, 2021. It is now read-only.

Commit e24bf2e

Browse files
Nikhil-Vatssarthak-sehgal
authored andcommitted
Added validation for toolNameHuman and toolNameComputer (#16)
1 parent 6a6c5fc commit e24bf2e

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

generators/app/index.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,28 @@ module.exports = class extends Generator {
2525
type: "input",
2626
name: "toolNameComputer",
2727
message:
28-
"Computer package name? This is a computer name with no capital letters or special characters apart from the - dash.",
28+
"Computer package name? This is a computer name with NO capital letters or special characters apart from the hyphen ( - ) .",
29+
validate: props => {
30+
if (props.match(/^[a-z0-9-]+$/)) {
31+
return true;
32+
}
33+
34+
return "This is not a valid computer name for the project, you can use only small letters, number and hyphen. Enter again.";
35+
},
2936
default: "biojs-webcomponent-tool-name-here"
3037
},
3138
{
3239
type: "input",
3340
name: "toolNameHuman",
3441
message:
35-
'Thanks! Now, give me a human name for the project with only letters and NO special characters. e.g. "Genome Browser"',
42+
'Thanks! Now, give me a human name for the project with only letters and NO special characters apart from the whitespace (space). e.g. "Genome Browser"',
43+
validate: props => {
44+
if (props.match(/^[A-Za-z ]+$/ || /^[A-Za-z\s]+$/)) {
45+
return true;
46+
}
47+
48+
return "This is not a valid human name for the project, you can use only letters and whitespace. Enter again.";
49+
},
3650
default: "BioJS component"
3751
}
3852
];

0 commit comments

Comments
 (0)