Conditional validations no longer accept strings for if/unless (#3124)
This commit is contained in:
parent
d2542dcec0
commit
6e4c7d6211
6 changed files with 13 additions and 9 deletions
|
@ -52,10 +52,10 @@ class Account < ApplicationRecord
|
|||
has_one :user, inverse_of: :account
|
||||
|
||||
validates :username, presence: true
|
||||
validates :username, uniqueness: { scope: :domain, case_sensitive: true }, unless: 'local?'
|
||||
validates :username, uniqueness: { scope: :domain, case_sensitive: true }, unless: :local?
|
||||
|
||||
# Local user validations
|
||||
with_options if: 'local?' do
|
||||
with_options if: :local? do
|
||||
validates :username, format: { with: /\A[a-z0-9_]+\z/i }, uniqueness: { scope: :domain, case_sensitive: false }, length: { maximum: 30 }
|
||||
validates :display_name, length: { maximum: 30 }
|
||||
validates :note, length: { maximum: 160 }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue