Declare validations together

This commit is contained in:
Matt-Yorkley
2021-08-12 10:07:40 +01:00
parent 5d9c4315d8
commit 6c885f0f42

View File

@@ -81,17 +81,16 @@ module Spree
before_validation :associate_customer, unless: :customer_id?
before_validation :ensure_customer, unless: :customer_is_valid?
validates :customer, presence: true, if: :require_customer?
validate :products_available_from_new_distribution, if: lambda {
distributor_id_changed? || order_cycle_id_changed?
}
validate :disallow_guest_order
attr_accessor :use_billing
before_create :link_by_email
after_create :create_tax_charge!
validates :customer, presence: true, if: :require_customer?
validate :products_available_from_new_distribution, if: lambda {
distributor_id_changed? || order_cycle_id_changed?
}
validate :disallow_guest_order
validates :email, presence: true,
format: /\A([\w.%+\-']+)@([\w\-]+\.)+(\w{2,})\z/i,
if: :require_email