Skip to content

Commit

Permalink
added validation for project id and project name
Browse files Browse the repository at this point in the history
  • Loading branch information
aalej committed Dec 12, 2024
1 parent f98ffe4 commit 26ef2ab
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
- CF3 callables can now be annotate with a genkit action they are serving (#8039)
- HTTPS functions can now be upgraded to HTTPS Callable functions (#8039)
- Update default tsconfig to support more modern defaults (#8039)
- Added validation for project ID and project name during `firebase init` (#2514)
20 changes: 19 additions & 1 deletion src/management/projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,30 @@ export const PROJECTS_CREATE_QUESTIONS: Question[] = [
message:
"Please specify a unique project id " +
`(${clc.yellow("warning")}: cannot be modified afterward) [6-30 characters]:\n`,
validate: (projectId: string) => {
if (projectId.length < 6) {
return "Project ID must be at least 6 characters long";
} else if (projectId.length > 30) {
return "Project ID cannot be longer than 30 characters";
} else {
return true;
}
},
},
{
type: "input",
name: "displayName",
default: "",
default: (answers: any) => answers.projectId,

Check warning on line 49 in src/management/projects.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type

Check warning on line 49 in src/management/projects.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access .projectId on an `any` value

Check warning on line 49 in src/management/projects.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe return of an `any` typed value
message: "What would you like to call your project? (defaults to your project ID)",
validate: (displayName: string) => {
if (displayName.length < 4) {
return "Project name must be at least 4 characters long";
} else if (displayName.length > 30) {
return "Project name cannot be longer than 30 characters";
} else {
return true;
}
},
},
];

Expand Down

0 comments on commit 26ef2ab

Please sign in to comment.