Class: Spree::Stock::AvailabilityValidator Private
- Inherits:
-
ActiveModel::Validator
- Object
- ActiveModel::Validator
- Spree::Stock::AvailabilityValidator
- Defined in:
- app/models/spree/stock/availability_validator.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Method Summary collapse
- #validate(line_item) ⇒ Object private
Instance Method Details
#validate(line_item) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'app/models/spree/stock/availability_validator.rb', line 4 def validate(line_item) if is_valid?(line_item) true else variant = line_item.variant display_name = variant.name.to_s display_name += %{ (#{variant.})} unless variant..blank? line_item.errors[:quantity] << Spree.t( :selected_quantity_not_available, item: display_name.inspect ) false end end |