Class: StrongerParameters::FileConstraint

Inherits:
Constraint
  • Object
show all
Defined in:
lib/stronger_parameters/constraints/file_constraint.rb

Constant Summary collapse

VALID_FILE_TYPES =
[
  File,
  StringIO,
  Rack::Test::UploadedFile,
  ActionDispatch::Http::UploadedFile
].freeze

Instance Method Summary collapse

Methods inherited from Constraint

#&, #==, #required, #required?, #|

Instance Method Details

#value(v) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/stronger_parameters/constraints/file_constraint.rb', line 13

def value(v)
  if VALID_FILE_TYPES.any? { |valid_file_type| v.is_a?(valid_file_type) }
    return v
  end

  InvalidValue.new(v, "must be an file object")
end