Sha256: 759626279360543a3f6164b2d251f207720fc2aafc50c2219371c300ac9cd6cc

Contents?: true

Size: 365 Bytes

Versions: 6

Compression:

Stored size: 365 Bytes

Contents

module Spree
  module Stock
    class InventoryValidator < ActiveModel::Validator
      def validate(line_item)
        if line_item.inventory_units.count != line_item.quantity
          line_item.errors[:inventory] << I18n.t(
            'spree.inventory_not_available',
            item: line_item.variant.name
          )
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
solidus_core-2.5.2 app/models/spree/stock/inventory_validator.rb
solidus_core-2.5.1 app/models/spree/stock/inventory_validator.rb
solidus_core-2.5.0 app/models/spree/stock/inventory_validator.rb
solidus_core-2.5.0.rc1 app/models/spree/stock/inventory_validator.rb
solidus_core-2.5.0.beta2 app/models/spree/stock/inventory_validator.rb
solidus_core-2.5.0.beta1 app/models/spree/stock/inventory_validator.rb