Skip to content

Commit e425346

Browse files
Merge pull request #84 from nicoschoenteich/main
fix: destination name can't be empty
2 parents b993204 + 17cd523 commit e425346

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

generators/helpers.js

+10
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,16 @@ export function validateAlphaNumeric(string) {
104104
return "Please use alpha numeric characters only."
105105
}
106106

107+
export function validateAlphaNumericNonEmpty(string) {
108+
if (/^[a-zA-Z0-9_-]*$/g.test(string)) {
109+
if (string !== "") {
110+
return true
111+
}
112+
}
113+
return "Please use a non-empty value with alpha numeric characters only."
114+
}
115+
116+
107117
export function validateUrl(string) {
108118
if (new URL(string) instanceof Error) {
109119
return // no error message required, yeoman will forward an error to the user

generators/model/prompts.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {
22
validateAlphaNumeric,
3-
validateUrl
3+
validateUrl,
4+
validateAlphaNumericNonEmpty
45
} from "../helpers.js"
56

67
export default async function prompts() {
@@ -57,7 +58,7 @@ export default async function prompts() {
5758
type: "input",
5859
name: "destName",
5960
message: "How do you want to name your new destination?",
60-
validate: validateAlphaNumeric
61+
validate: validateAlphaNumericNonEmpty
6162
})).destName
6263
}
6364
}

0 commit comments

Comments
 (0)