Class: SteelWheel::Query::ExistsValidator

Inherits:
ActiveModel::EachValidator
  • Object
show all
Defined in:
lib/steel_wheel/query/exists_validator.rb

Overview

Presence validation for loaders

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



7
8
9
10
11
12
# File 'lib/steel_wheel/query/exists_validator.rb', line 7

def validate_each(record, attribute, value)
  return unless value.blank?

  error_key = options[:base] ? :base : attribute
  record.errors.add(error_key, :not_found, message: options.fetch(:message, 'not found'))
end