Module: CarrierWaveDirect::Validations::ActiveModel::HelperMethods

Defined in:
lib/carrierwave_direct/validations/active_model.rb

Instance Method Summary collapse

Instance Method Details

#validates_filename_format_of(*attr_names) ⇒ Object



99
100
101
# File 'lib/carrierwave_direct/validations/active_model.rb', line 99

def validates_filename_format_of(*attr_names)
  validates_with FilenameFormatValidator, _merge_attributes(attr_names)
end

#validates_filename_uniqueness_of(*attr_names) ⇒ Object

Makes the record invalid if the filename already exists

Accepts the usual parameters for validations in Rails (:if, :unless, etc…)

Note

Set this key in your translations file for I18n:

carrierwave_direct:
  errors:
    filename_taken: 'Here be an error message'


95
96
97
# File 'lib/carrierwave_direct/validations/active_model.rb', line 95

def validates_filename_uniqueness_of(*attr_names)
  validates_with UniqueFilenameValidator, _merge_attributes(attr_names)
end

#validates_is_attached(*attr_names) ⇒ Object



111
112
113
# File 'lib/carrierwave_direct/validations/active_model.rb', line 111

def validates_is_attached(*attr_names)
  validates_with IsAttachedValidator, _merge_attributes(attr_names)
end

#validates_is_uploaded(*attr_names) ⇒ Object



107
108
109
# File 'lib/carrierwave_direct/validations/active_model.rb', line 107

def validates_is_uploaded(*attr_names)
  validates_with IsUploadedValidator, _merge_attributes(attr_names)
end

#validates_remote_net_url_format_of(*attr_names) ⇒ Object



103
104
105
# File 'lib/carrierwave_direct/validations/active_model.rb', line 103

def validates_remote_net_url_format_of(*attr_names)
  validates_with RemoteNetUrlFormatValidator, _merge_attributes(attr_names)
end