diff --git a/app/models/avis.rb b/app/models/avis.rb index 51da59ce1..62d89b8ad 100644 --- a/app/models/avis.rb +++ b/app/models/avis.rb @@ -24,6 +24,14 @@ class Avis < ApplicationRecord has_one_attached :piece_justificative_file has_one_attached :introduction_file + validates :piece_justificative_file, + content_type: AUTHORIZED_CONTENT_TYPES, + size: { less_than: 20.megabytes } + + validates :introduction_file, + content_type: AUTHORIZED_CONTENT_TYPES, + size: { less_than: 20.megabytes } + validates :email, format: { with: Devise.email_regexp, message: "n'est pas valide" }, allow_nil: true validates :claimant, presence: true validates :piece_justificative_file, size: { less_than: 20.megabytes } diff --git a/app/models/commentaire.rb b/app/models/commentaire.rb index de8988d47..d55a5ce69 100644 --- a/app/models/commentaire.rb +++ b/app/models/commentaire.rb @@ -22,7 +22,10 @@ class Commentaire < ApplicationRecord has_one_attached :piece_jointe validates :body, presence: { message: "ne peut ĂȘtre vide" } - validates :piece_jointe, size: { less_than: 20.megabytes } + + validates :piece_jointe, + content_type: AUTHORIZED_CONTENT_TYPES, + size: { less_than: 20.megabytes } default_scope { order(created_at: :asc) } scope :updated_since?, -> (date) { where('commentaires.updated_at > ?', date) }