Class: ActiveStorageValidations::AspectRatioValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- ActiveStorageValidations::AspectRatioValidator
- Includes:
- ASVActiveStorageable, ASVAnalyzable, ASVAttachable, ASVErrorable, ASVOptionable, ASVSymbolizable
- Defined in:
- lib/active_storage_validations/aspect_ratio_validator.rb
Overview
:nodoc
Constant Summary collapse
- AVAILABLE_CHECKS =
%i[with].freeze
- NAMED_ASPECT_RATIOS =
%i[square portrait landscape].freeze
- ASPECT_RATIO_REGEX =
/is_([1-9]\d*)_([1-9]\d*)/.freeze
- ERROR_TYPES =
%i[ image_metadata_missing aspect_ratio_not_square aspect_ratio_not_portrait aspect_ratio_not_landscape aspect_ratio_is_not ].freeze
- PRECISION =
3.freeze
Constants included from ASVAnalyzable
ActiveStorageValidations::ASVAnalyzable::DEFAULT_IMAGE_PROCESSOR
Instance Method Summary collapse
Methods included from ASVErrorable
#add_error, #initialize_error_options
Instance Method Details
#check_validity! ⇒ Object
31 32 33 34 |
# File 'lib/active_storage_validations/aspect_ratio_validator.rb', line 31 def check_validity! ensure_at_least_one_validator_option ensure_aspect_ratio_validity end |
#validate_each(record, attribute, _value) ⇒ Object
36 37 38 39 40 |
# File 'lib/active_storage_validations/aspect_ratio_validator.rb', line 36 def validate_each(record, attribute, _value) return if (record, attribute) (record, attribute) end |