Class: Spree::EmailValidator

Inherits:
ActiveModel::EachValidator
  • Object
show all
Defined in:
lib/spree/core/validators/email.rb

Overview

An ActiveModel Email Validator

Usage

require 'spree/core/validators/email'

class Person < ApplicationRecord
  validates :email_address, 'spree/email' => true
end

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



15
16
17
18
19
# File 'lib/spree/core/validators/email.rb', line 15

def validate_each(record, attribute, value)
  unless Spree::Config.default_email_regexp.match? value
    record.errors.add(attribute, :invalid, **{ value: }.merge!(options))
  end
end