Class: ActiveStorageValidations::DimensionValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- ActiveStorageValidations::DimensionValidator
- 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
Instance Method Summary collapse
Methods included from ASVErrorable
#add_error, #initialize_error_options
Instance Method Details
#check_validity! ⇒ Object
32 33 34 35 36 |
# File 'lib/active_storage_validations/dimension_validator.rb', line 32 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
38 39 40 41 42 |
# File 'lib/active_storage_validations/dimension_validator.rb', line 38 def validate_each(record, attribute, _value) return if (record, attribute) (record, attribute) end |