vendor/plugins/rust-file_column/lib/validations.rb
# This validates the file size of one or more file_columns.  A list of file columns
# should be given followed by an options hash.
#
# Required options:
# * <tt>:in</tt> => A size range.  Note that you can use ActiveSupport's
#   numeric extensions for kilobytes, etc.
#
# Examples:
#    validates_filesize_of :field, :in => 0..100.megabytes
#    validates_filesize_of :field, :in => 15.kilobytes..1.megabyte
This validates the file size of one or more file_columns.  A list of file columns
should be given followed by an options hash.

Required options:
:in => A size range.  Note that you can use ActiveSupport's
numeric extensions for kilobytes, etc.


This validates the file size of one or more file_columns . A list of file columns should be given followed by an options hash . Required options : : in = > A size range . Note that you can use ActiveSupport ' s numeric extensions for kilobytes etc .
def validates_filesize_of(*attrs)  
        options = attrs.pop if attrs.last.is_a?Hash
        raise ArgumentError, "Please include the :in option." if !options || !options[:in]
        raise ArgumentError, "Invalid value for option :in" unless options[:in].is_a?Range
        validates_each(attrs, options) do |record, attr, value|
          unless value.blank?
            size = File.size(value)
            record.errors.add attr, "is smaller than the allowed size range." if size < options[:in].first
            record.errors.add attr, "is larger than the allowed size range." if size > options[:in].last
          end
        end
      end
def validates_filesize_of ( * attrs ) options = attrs . pop if attrs . last . is_a? Hash raise ArgumentError , "Please include the :in option." if ! options || ! options [ :in ] raise ArgumentError , "Invalid value for option :in" unless options [ :in ] . is_a? Range validates_each ( attrs , options ) do | record , attr , value | unless value . blank? size = File . size ( value ) record . errors . add attr , "is smaller than the allowed size range." if size < options [ :in ] . first record . errors . add attr , "is larger than the allowed size range." if size > options [ :in ] . last end end end
This validates the file size of one or more file_columns.
This validates the file size of one or more file_columns .
attrs
<not_specific>