Class: ActiveStorageValidations::DimensionValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- ActiveStorageValidations::DimensionValidator
- Includes:
- ASVActiveStorageable, ASVAnalyzable, ASVAttachable, ASVErrorable, ASVOptionable, ASVSymbolizable
- Defined in:
- lib/active_storage_validations/dimension_validator.rb
Overview
:nodoc
Constant Summary collapse
- AVAILABLE_CHECKS =
%i[width height min max].freeze
- ERROR_TYPES =
%i[ image_metadata_missing dimension_min_inclusion dimension_max_inclusion dimension_width_inclusion dimension_height_inclusion dimension_width_greater_than_or_equal_to dimension_height_greater_than_or_equal_to dimension_width_less_than_or_equal_to dimension_height_less_than_or_equal_to dimension_width_equal_to dimension_height_equal_to ].freeze
Constants included from ASVAnalyzable
ASVAnalyzable::DEFAULT_IMAGE_PROCESSOR
Instance Method Summary collapse
Methods included from ASVErrorable
#add_error, #initialize_error_options
Instance Method Details
#check_validity! ⇒ Object
34 35 36 37 38 |
# File 'lib/active_storage_validations/dimension_validator.rb', line 34 def check_validity! unless AVAILABLE_CHECKS.any? { |argument| .key?(argument) } raise ArgumentError, 'You must pass either :width, :height, :min or :max to the validator' end end |
#validate_each(record, attribute, _value) ⇒ Object
40 41 42 43 44 |
# File 'lib/active_storage_validations/dimension_validator.rb', line 40 def validate_each(record, attribute, _value) return if (record, attribute) (record, attribute) end |