class Dis::Validations::DataPresence

Dis Data Presence Validation

Public Class Methods

empty_hash() click to toggle source
# File lib/dis/validations/data_presence.rb, line 17
def empty_hash
  @empty_hash ||= Dis::Storage.file_digest("")
end

Public Instance Methods

validate(record) click to toggle source

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

# File lib/dis/validations/data_presence.rb, line 10
def validate(record)
  return if record.data? && record.content_hash != self.class.empty_hash

  record.errors.add(:data, :blank)
end