Class: ActiveStorageValidations::AspectRatioValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- ActiveStorageValidations::AspectRatioValidator
- 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
Instance Method Summary collapse
Methods included from ASVErrorable
#add_error, #initialize_error_options
Instance Method Details
#check_validity! ⇒ Object
29 30 31 32 |
# File 'lib/active_storage_validations/aspect_ratio_validator.rb', line 29 def check_validity! ensure_at_least_one_validator_option ensure_aspect_ratio_validity end |
#validate_each(record, attribute, _value) ⇒ Object
34 35 36 37 38 |
# File 'lib/active_storage_validations/aspect_ratio_validator.rb', line 34 def validate_each(record, attribute, _value) return if (record, attribute) (record, attribute) end |