Sha256: 2b7bb97d67c70832ae6e760d19eb1ab8b973079aa2cab93b6a012ef2b818bed3
Contents?: true
Size: 565 Bytes
Versions: 11
Compression:
Stored size: 565 Bytes
Contents
# frozen_string_literal: true module Spree # == An ActiveModel Email Validator # # === Usage # # require 'spree/core/validators/email' # # class Person < ApplicationRecord # validates :email_address, 'spree/email' => true # end # class EmailValidator < ActiveModel::EachValidator EMAIL_REGEXP = URI::MailTo::EMAIL_REGEXP def validate_each(record, attribute, value) unless EMAIL_REGEXP.match? value record.errors.add(attribute, :invalid, **{ value: value }.merge!(options)) end end end end
Version data entries
11 entries across 11 versions & 1 rubygems