Class: ActiveStorageValidations::AttachedValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- ActiveStorageValidations::AttachedValidator
- Includes:
- ASVActiveStorageable, ASVErrorable, ASVSymbolizable
- Defined in:
- lib/active_storage_validations/attached_validator.rb
Overview
:nodoc:
Constant Summary collapse
- ERROR_TYPES =
%i[blank].freeze
Instance Method Summary collapse
Methods included from ASVErrorable
#add_error, #initialize_error_options
Instance Method Details
#check_validity! ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/active_storage_validations/attached_validator.rb', line 15 def check_validity! %i[allow_nil allow_blank].each do || if .include?() raise ArgumentError, "You cannot pass the :#{} option to the #{self.class.to_sym} validator" end end end |
#validate_each(record, attribute, _value) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/active_storage_validations/attached_validator.rb', line 23 def validate_each(record, attribute, _value) return if (record, attribute) && (record, attribute) = () add_error(record, attribute, ERROR_TYPES.first, **) end |