Skip to content

Commit

Permalink
Merge pull request #3731 from manyfold3d/short-usernames
Browse files Browse the repository at this point in the history
Allow one and two character usernames
  • Loading branch information
Floppy authored Mar 5, 2025
2 parents 4b57b26 + 64f26c2 commit 725ab8b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class User < ApplicationRecord
validates :username,
presence: true,
uniqueness: {case_sensitive: false},
format: {with: /\A[[:alnum:]]{3,}\z/}
format: {with: /\A[[:alnum:]]+\z/}

validates :email,
presence: true,
Expand Down
8 changes: 4 additions & 4 deletions spec/models/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
expect(build(:user, username: nil)).not_to be_valid
end

it "doesn't allow single-character usernames" do
expect(build(:user, username: "a")).not_to be_valid
it "allows single-character usernames" do
expect(build(:user, username: "a")).to be_valid
end

it "doesn't allow two-character usernames" do
expect(build(:user, username: "ab")).not_to be_valid
it "allows two-character usernames" do
expect(build(:user, username: "ab")).to be_valid
end

it "allow three-character usernames" do
Expand Down

0 comments on commit 725ab8b

Please sign in to comment.