Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: destination name can't be empty #84

Merged
merged 1 commit into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
}
Loading