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
13
14
# File 'lib/dis/validations/data_presence.rb', line 10

def validate(record)
  unless record.data?
    record.errors.add(:data, :blank)
  end
end