Class: C80News::FactValidator

Inherits:
ActiveModel::Validator
  • Object
show all
Defined in:
app/models/c80_news/fact_validator.rb

Instance Method Summary collapse

Instance Method Details

#validate(record) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/models/c80_news/fact_validator.rb', line 3

def validate(record)

  unless record.title.present?
    record.errors[:title] = 'Название новости не может быть пустым'
  end

  unless record.short.present?
    record.errors[:short] = 'Заполните краткое описание новости'
  end

  unless record.full.present?
    record.errors[:full] = 'Текст новости не может быть пустым'
  end

end