Module: CarrierWaveDirect::Validations::ActiveModel::HelperMethods
- Defined in:
- lib/carrierwave_direct/validations/active_model.rb
Instance Method Summary collapse
- #validates_filename_format_of(*attr_names) ⇒ Object
-
#validates_filename_uniqueness_of(*attr_names) ⇒ Object
Makes the record invalid if the filename already exists.
- #validates_is_attached(*attr_names) ⇒ Object
- #validates_is_uploaded(*attr_names) ⇒ Object
- #validates_remote_net_url_format_of(*attr_names) ⇒ Object
Instance Method Details
#validates_filename_format_of(*attr_names) ⇒ Object
111 112 113 |
# File 'lib/carrierwave_direct/validations/active_model.rb', line 111 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'
107 108 109 |
# File 'lib/carrierwave_direct/validations/active_model.rb', line 107 def validates_filename_uniqueness_of(*attr_names) validates_with UniqueFilenameValidator, _merge_attributes(attr_names) end |
#validates_is_attached(*attr_names) ⇒ Object
123 124 125 |
# File 'lib/carrierwave_direct/validations/active_model.rb', line 123 def validates_is_attached(*attr_names) validates_with IsAttachedValidator, _merge_attributes(attr_names) end |
#validates_is_uploaded(*attr_names) ⇒ Object
119 120 121 |
# File 'lib/carrierwave_direct/validations/active_model.rb', line 119 def validates_is_uploaded(*attr_names) validates_with IsUploadedValidator, _merge_attributes(attr_names) end |
#validates_remote_net_url_format_of(*attr_names) ⇒ Object
115 116 117 |
# File 'lib/carrierwave_direct/validations/active_model.rb', line 115 def validates_remote_net_url_format_of(*attr_names) validates_with RemoteNetUrlFormatValidator, _merge_attributes(attr_names) end |