Add content validation for avis and messages
This commit is contained in:
parent
d72f0c6dd2
commit
685534e827
2 changed files with 12 additions and 1 deletions
|
@ -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 }
|
||||
|
|
|
@ -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) }
|
||||
|
|
Loading…
Reference in a new issue