parent
80f576a29b
commit
3c4f32a760
2 changed files with 7 additions and 0 deletions
|
@ -104,6 +104,8 @@ class User < ApplicationRecord
|
|||
validates :preferred_editor, :inclusion => Editors::ALL_EDITORS, :allow_nil => true
|
||||
validates :auth_uid, :unless => proc { |u| u.auth_provider.nil? },
|
||||
:uniqueness => { :scope => :auth_provider }
|
||||
validates :avatar, :if => proc { |u| u.attachment_changes["avatar"] },
|
||||
:image => true
|
||||
|
||||
validates_email_format_of :email, :if => proc { |u| u.email_changed? }
|
||||
validates_email_format_of :new_email, :allow_blank => true, :if => proc { |u| u.new_email_changed? }
|
||||
|
|
5
app/validators/image_validator.rb
Normal file
5
app/validators/image_validator.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
class ImageValidator < ActiveModel::EachValidator
|
||||
def validate_each(record, attribute, value)
|
||||
record.errors.add(attribute, " must be an image") unless value.image?
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue