Class: Paperclip::Validate::RequiredFieldValidator

Inherits:
DataMapper::Validate::GenericValidator
  • Object
show all
Defined in:
lib/dm-paperclip/validations.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#call(target) ⇒ Object



55
56
57
58
59
60
61
62
63
# File 'lib/dm-paperclip/validations.rb', line 55

def call(target)
  field_value = target.validation_property_value(@field_name)
  if field_value.nil? || field_value.original_filename.blank?
    error_message = @options[:message] || sprintf("%s must be set", @field_name.to_s.humanize)
    add_error(target, error_message , @field_name)
    return false
  end
  return true
end