Class: CatalogItem::CouponAndSalePriceValidator
- Inherits:
-
ActiveModel::Validator
- Object
- ActiveModel::Validator
- CatalogItem::CouponAndSalePriceValidator
- 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
-
#validate(record) ⇒ void
Runs the sale price/coupon pairing checks on an active record.
Instance Method Details
#validate(record) ⇒ void
This method returns an undefined value.
Runs the sale price/coupon pairing checks on an active record.
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 |