Skip to content

Commit ec637d8

Browse files
committed
fix(db): cleanup database name
1 parent 7ddbfe0 commit ec637d8

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/prompts.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@ export const Prompts: Record<string, PromptQuestion> = {
8888
name: 'dbName',
8989
when: (answers) => answers.features.includes('db'),
9090
message: 'What will be the name of the database?',
91-
default: (answers: OtiAnswers) => removeType(answers.name),
91+
validate(input) {
92+
if (!/^[a-zA-Z_][a-zA-Z0-9_]{0,62}$/.test(input)) {
93+
return 'That database name is not a valid postgres identifier';
94+
}
95+
return true;
96+
},
97+
default: (answers: OtiAnswers) => removeType(answers.name).replace('-', '_'),
9298
},
9399
};

0 commit comments

Comments
 (0)