Sha256: 4362fd7f97d42504e2c6d2b08c078f6d7d700b19a32af486e99e9200ceefbaaf

Contents?: true

Size: 366 Bytes

Versions: 5

Compression:

Stored size: 366 Bytes

Contents

module Spree
  module Stock
    class AvailabilityValidator < ActiveModel::Validator

      def validate(line_item)
        quantifier = Stock::Quantifier.new(line_item.variant_id)

        unless quantifier.can_supply? line_item.quantity
          line_item.errors[:quantity] << I18n.t('validation.exceeds_available_stock')
        end

      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
spree_core-2.0.3 app/models/spree/stock/availability_validator.rb
spree_core-2.0.2 app/models/spree/stock/availability_validator.rb
spree_core-2.0.1 app/models/spree/stock/availability_validator.rb
spree_core-2.0.0 app/models/spree/stock/availability_validator.rb
spree_core-2.0.0.rc1 app/models/spree/stock/availability_validator.rb