diff --git a/app/models/user.rb b/app/models/user.rb index 3bd5ee87..a30c3da3 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -11,9 +11,12 @@ class User < ApplicationRecord include HasContent include Authority::UserAbilities - validates_uniqueness_of :username, allow_nil: true, allow_blank: true - validates_format_of :username, with: /\A[A-Za-z0-9\-_\$\+\!\*]+\z/, message: 'must be between 1 and 40 alphanumeric characters (-, _, $, +, !, and * also accepted)' - validates :username, length: { in: 0..40, message: 'must be between 1 and 40 alphanumeric characters (-, _, $, +, !, and * also accepted)' } + validates :username, + uniqueness: true, + allow_nil: true, + allow_blank: true, + length: { maximum: 40 }, + format: /\A[A-Za-z0-9\-_\$\+\!\*]+\z/ has_many :subscriptions, dependent: :destroy has_many :billing_plans, through: :subscriptions