Skip to content

Commit 0b2bdf9

Browse files
committedJun 23, 2022
feat: validate user input when use plop
1 parent 9384d9d commit 0b2bdf9

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
 

‎plopfile.js

+14
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ module.exports = (plop) => {
66
type: "input",
77
name: "name",
88
message: "Component name(e.g. Input, InputNumber):",
9+
validate: (name) => {
10+
if (name === "") {
11+
return "Please input component name or press `ctrl-c` to quit"
12+
}
13+
14+
return true;
15+
}
916
},
1017
{
1118
type: "rawlist",
@@ -63,6 +70,13 @@ module.exports = (plop) => {
6370
type: "input",
6471
name: "name",
6572
message: "Icon name(e.g. EmptyState, FileWorld, NextDouble):",
73+
validate: (name) => {
74+
if (name === "") {
75+
return "Please input icon name or press `ctrl-c` to quit"
76+
}
77+
78+
return true;
79+
}
6680
},
6781
],
6882
actions: [

0 commit comments

Comments
 (0)
Please sign in to comment.