Class: ActiveStorageValidations::BaseSizeValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- ActiveStorageValidations::BaseSizeValidator
- Includes:
- Errorable, OptionProcUnfolding, Symbolizable
- Defined in:
- lib/active_storage_validations/base_size_validator.rb
Overview
:nodoc:
Direct Known Subclasses
Constant Summary collapse
- AVAILABLE_CHECKS =
%i[ less_than less_than_or_equal_to greater_than greater_than_or_equal_to between ].freeze
Instance Method Summary collapse
- #check_validity! ⇒ Object
-
#initialize(*args) ⇒ BaseSizeValidator
constructor
A new instance of BaseSizeValidator.
Methods included from Errorable
#add_error, #initialize_error_options
Methods included from OptionProcUnfolding
Constructor Details
#initialize(*args) ⇒ BaseSizeValidator
Returns a new instance of BaseSizeValidator.
22 23 24 25 26 27 |
# File 'lib/active_storage_validations/base_size_validator.rb', line 22 def initialize(*args) if self.class == BaseSizeValidator raise NotImplementedError, 'BaseSizeValidator is an abstract class and cannot be instantiated directly.' end super end |
Instance Method Details
#check_validity! ⇒ Object
29 30 31 32 33 |
# File 'lib/active_storage_validations/base_size_validator.rb', line 29 def check_validity! unless AVAILABLE_CHECKS.one? { |argument| .key?(argument) } raise ArgumentError, 'You must pass either :less_than(_or_equal_to), :greater_than(_or_equal_to), or :between to the validator' end end |