Skip to content

Commit b57e787

Browse files
committed
Enforce organization name validation in generator
1 parent c432380 commit b57e787

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

packages/generator-widget/generators/app/lib/prompttexts.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,15 @@ function promptWidgetProperties(mxProjectDir, widgetName) {
2323
{
2424
type: "input",
2525
name: "organization",
26+
validate: input => {
27+
if (/[^a-zA-Z0-9_.-]/.test(input)) {
28+
return "Your organization name can only contain alphanumeric characters, '_', '-', and '.'. Please provide a valid name";
29+
}
30+
if (!/^([a-zA-Z0-9_-]+.)*[a-zA-Z0-9_-]+$/.test(input)) {
31+
return "Your organization name must follow the structure [namespace.]org-name, for example 'mendix' or 'com.mendix.widgets'. Please provide a valid name";
32+
}
33+
return true;
34+
},
2635
message: "Organization name",
2736
default: "Mendix",
2837
store: true

0 commit comments

Comments
 (0)