Sha256: aa2b96c27f3d0f2833bb3d8efdf7740a51df126ae56a33b095bedaac1d281530
Contents?: true
Size: 433 Bytes
Versions: 272
Compression:
Stored size: 433 Bytes
Contents
# An ActiveRecord validator for any email field that you would use with effective_email or otherwise # # validates :cc, email_cc: true class EmailCcValidator < ActiveModel::EachValidator PATTERN = /\A.+@.+\..+\Z/ def validate_each(record, attribute, value) if value.present? unless value.to_s.split(',').all? { |email| PATTERN =~ email } record.errors.add(attribute, 'is invalid') end end end end
Version data entries
272 entries across 272 versions & 1 rubygems