Skip to content

Commit

Permalink
feat(platform): added validation for project ids; closes #3183
Browse files Browse the repository at this point in the history
  • Loading branch information
jonrkarr authored and bilalshaikh42 committed Oct 9, 2021
1 parent dbd12cd commit 01b6178
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions apps/api/src/projects/project.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ export class ProjectModel extends Document {
unique: true,
index: true,
immutable: true,
validate: [
{
validator: (value: any): boolean => {
return (typeof value === 'string' || value instanceof String) && (value.match(/^[a-z0-9_-]{3,}$/i) !== null);
},
message: (props: any): string =>
`'${props.value}' is not a valid project id. Project ids must be a combination of at least three letters, numbers, underscores, and dashes (^[a-zA-Z0-9_-]{3,}$).`,
},
],
})
public id!: string;

Expand Down

0 comments on commit 01b6178

Please sign in to comment.