Module: Shrine::Plugins::Validation::AttacherClassMethods

Defined in:
lib/shrine/plugins/validation.rb

Instance Method Summary collapse

Instance Method Details

#validate(&block) ⇒ Object

Block that is executed in context of Shrine::Attacher during validation. Example:

Shrine::Attacher.validate do
  if file.size > 5*1024*1024
    errors << "is too big (max is 5 MB)"
  end
end

16
17
18
# File 'lib/shrine/plugins/validation.rb', line 16

def validate(&block)
  private define_method(:validate_block, &block)
end