Class: SaleInquiryCommentValidator

Inherits:
ActiveModel::Validator
  • Object
show all
Defined in:
app/validators/sale_inquiry_comment_validator.rb

Instance Method Summary collapse

Instance Method Details

#validate(record) ⇒ Object



2
3
4
5
6
7
8
# File 'app/validators/sale_inquiry_comment_validator.rb', line 2

def validate(record)
  record.errors.add(:sale_inquiry, :blank)                               and return false if record.sale_inquiry.nil?
  record.errors.add(:author,       :blank)                               and return false if record.author.nil?
  record.errors.add(:text,         :blank)                               and return false unless record.text.present?
  record.errors.add(:text,         :less_than_or_equal_to, count: 1024)  and return false if record.text.size > 1024
  true
end