Class: CatalogItem::CouponAndSalePriceValidator

Inherits:
ActiveModel::Validator
  • Object
show all
Defined in:
app/validators/catalog_item/coupon_and_sale_price_validator.rb

Overview

Validates that a catalog item's sale price and coupon (current and future)
are specified together when one side requires the other.

Instance Method Summary collapse

Instance Method Details

#validate(record) ⇒ void

This method returns an undefined value.

Runs the sale price/coupon pairing checks on an active record.

Parameters:

  • record (CatalogItem)

    the catalog item being validated



10
11
12
13
14
15
16
# File 'app/validators/catalog_item/coupon_and_sale_price_validator.rb', line 10

def validate(record)
  # Skip validation unless the record is active or active_hidden
  return unless record.active? || record.active_hidden?

  validate_sale_price_and_coupon(record)
  validate_new_sale_price_and_coupon(record)
end