Sha256: 645a6225957cb8b28c67c1d8c91b88cb8cda51ffbc94c2c5df7021ddaf0a8eed
Contents?: true
Size: 563 Bytes
Versions: 5
Compression:
Stored size: 563 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
5 entries across 5 versions & 1 rubygems