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

Add username validation for names #41

Merged
merged 1 commit into from
Nov 30, 2023
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
7 changes: 5 additions & 2 deletions buf/registry/owner/v1beta1/organization.proto
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ message Organization {
// A name uniquely identifies an Organization, however name is mutable.
string name = 4 [
(buf.validate.field).required = true,
(buf.validate.field).string.max_len = 32
(buf.validate.field).string.min_len = 2,
(buf.validate.field).string.max_len = 32,
(buf.validate.field).string.pattern = "^[a-z][a-z0-9-]*[a-z0-9]$"
];
// The configurable description of the Organization.
string description = 5 [(buf.validate.field).string.max_len = 350];
Expand Down Expand Up @@ -82,8 +84,9 @@ message OrganizationRef {
string id = 1 [(buf.validate.field).string.uuid = true];
// The name of the Organization.
string name = 2 [(buf.validate.field).string = {
min_len: 1;
min_len: 2;
max_len: 32;
pattern: "^[a-z][a-z0-9-]*[a-z0-9]$";
}];
}
}
4 changes: 3 additions & 1 deletion buf/registry/owner/v1beta1/organization_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ message CreateOrganizationsRequest {
// The name of the Organization.
string name = 1 [
(buf.validate.field).required = true,
(buf.validate.field).string.max_len = 32
(buf.validate.field).string.min_len = 2,
(buf.validate.field).string.max_len = 32,
(buf.validate.field).string.pattern = "^[a-z][a-z0-9-]*[a-z0-9]$"
];
// The configurable description of the Organization.
string description = 2 [(buf.validate.field).string.max_len = 350];
Expand Down
3 changes: 2 additions & 1 deletion buf/registry/owner/v1beta1/owner.proto
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ message OwnerRef {
string id = 1 [(buf.validate.field).string.uuid = true];
// The name of the User or Organization.
string name = 2 [(buf.validate.field).string = {
min_len: 1;
min_len: 2;
max_len: 32;
pattern: "^[a-z][a-z0-9-]*[a-z0-9]$";
}];
}
}
7 changes: 5 additions & 2 deletions buf/registry/owner/v1beta1/user.proto
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ message User {
// A name uniquely identifies a User, however name is mutable.
string name = 4 [
(buf.validate.field).required = true,
(buf.validate.field).string.max_len = 32
(buf.validate.field).string.min_len = 2,
(buf.validate.field).string.max_len = 32,
(buf.validate.field).string.pattern = "^[a-z][a-z0-9-]*[a-z0-9]$"
];
// The type of the User.
UserType type = 5 [
Expand Down Expand Up @@ -111,8 +113,9 @@ message UserRef {
string id = 1 [(buf.validate.field).string.uuid = true];
// The name of the User.
string name = 2 [(buf.validate.field).string = {
min_len: 1;
min_len: 2;
max_len: 32;
pattern: "^[a-z][a-z0-9-]*[a-z0-9]$";
}];
}
}
4 changes: 3 additions & 1 deletion buf/registry/owner/v1beta1/user_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ message CreateUsersRequest {
// The name of the User.
string name = 1 [
(buf.validate.field).required = true,
(buf.validate.field).string.max_len = 32
(buf.validate.field).string.min_len = 2,
(buf.validate.field).string.max_len = 32,
(buf.validate.field).string.pattern = "^[a-z][a-z0-9-]*[a-z0-9]$"
];
// The type of the User.
//
Expand Down
Loading