Class: Dis::Validations::DataPresence

Inherits:
ActiveModel::Validator
  • Object
show all
Defined in:
lib/dis/validations/data_presence.rb

Overview

Dis Data Presence Validation

Instance Method Summary collapse

Instance Method Details

#validate(record) ⇒ Object

Validates that a record has data, either freshly assigned or persisted in the storage. Adds a ‘:blank` error on `:data`if not.



10
11
12
# File 'lib/dis/validations/data_presence.rb', line 10

def validate(record)
  record.errors.add(:data, :blank) if !record.data? || record.data.blank?
end