Skip to content

Commit

Permalink
Merge pull request #84 from nicoschoenteich/main
Browse files Browse the repository at this point in the history
fix: destination name can't be empty
  • Loading branch information
nicoschoenteich authored Sep 6, 2024
2 parents b993204 + 17cd523 commit e425346
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
10 changes: 10 additions & 0 deletions generators/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,16 @@ export function validateAlphaNumeric(string) {
return "Please use alpha numeric characters only."
}

export function validateAlphaNumericNonEmpty(string) {
if (/^[a-zA-Z0-9_-]*$/g.test(string)) {
if (string !== "") {
return true
}
}
return "Please use a non-empty value with alpha numeric characters only."
}


export function validateUrl(string) {
if (new URL(string) instanceof Error) {
return // no error message required, yeoman will forward an error to the user
Expand Down
5 changes: 3 additions & 2 deletions generators/model/prompts.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
validateAlphaNumeric,
validateUrl
validateUrl,
validateAlphaNumericNonEmpty
} from "../helpers.js"

export default async function prompts() {
Expand Down Expand Up @@ -57,7 +58,7 @@ export default async function prompts() {
type: "input",
name: "destName",
message: "How do you want to name your new destination?",
validate: validateAlphaNumeric
validate: validateAlphaNumericNonEmpty
})).destName
}
}

0 comments on commit e425346

Please sign in to comment.