Class: HasOneTitleValidator
- Inherits:
-
ActiveModel::Validator
- Object
- ActiveModel::Validator
- HasOneTitleValidator
- Defined in:
- app/validators/has_one_title_validator.rb
Overview
validates that the title has at least one title
Instance Method Summary collapse
Instance Method Details
#validate(record) ⇒ Object
3 4 5 6 7 |
# File 'app/validators/has_one_title_validator.rb', line 3 def validate(record) if record.title.reject(&:empty?).empty? record.errors[:title] << "You must provide a title" end end |