From 3c5a35df271832a513cddef34af61fcf864ea88a Mon Sep 17 00:00:00 2001 From: Luis Ramos Date: Sat, 8 Aug 2020 15:36:21 +0100 Subject: [PATCH] Remove original email validator and keep only previous OFN validator --- app/models/spree/order.rb | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/app/models/spree/order.rb b/app/models/spree/order.rb index 0dbd0c7728..9eb46ae51c 100644 --- a/app/models/spree/order.rb +++ b/app/models/spree/order.rb @@ -88,19 +88,10 @@ module Spree before_create :link_by_email after_create :create_tax_charge! - validates :email, presence: true, if: :require_email - validates :email, email: true, if: :require_email, allow_blank: true validate :has_available_shipment validate :has_available_payment - - # The EmailValidator introduced in Spree 2.1 is not working - # So here we remove it and re-introduce the regexp validation rule from Spree 2.0 - _validate_callbacks.each do |callback| - if callback.raw_filter.respond_to? :attributes - callback.raw_filter.attributes.delete :email - end - end - validates :email, presence: true, format: /\A([\w\.%\+\-']+)@([\w\-]+\.)+([\w]{2,})\z/i, + validates :email, presence: true, + format: /\A([\w\.%\+\-']+)@([\w\-]+\.)+([\w]{2,})\z/i, if: :require_email make_permalink field: :number