From 6c885f0f421fedeb62f1b8ee172cb333c58ce17a Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Thu, 12 Aug 2021 10:07:40 +0100 Subject: [PATCH] Declare validations together --- app/models/spree/order.rb | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/app/models/spree/order.rb b/app/models/spree/order.rb index 9d7429a42d..a81264f0c4 100644 --- a/app/models/spree/order.rb +++ b/app/models/spree/order.rb @@ -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