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

Version Path
effective_resources-2.17.2 app/validators/email_cc_validator.rb
effective_resources-2.17.1 app/validators/email_cc_validator.rb
effective_resources-2.17.0 app/validators/email_cc_validator.rb
effective_resources-2.16.1 app/validators/email_cc_validator.rb
effective_resources-2.16.0 app/validators/email_cc_validator.rb
effective_resources-2.15.0 app/validators/email_cc_validator.rb
effective_resources-2.14.0 app/validators/email_cc_validator.rb
effective_resources-2.13.0 app/validators/email_cc_validator.rb
effective_resources-2.12.0 app/validators/email_cc_validator.rb
effective_resources-2.11.6 app/validators/email_cc_validator.rb
effective_resources-2.11.5 app/validators/email_cc_validator.rb
effective_resources-2.11.4 lib/validators/email_cc_validator.rb
effective_resources-2.11.3 lib/validators/email_cc_validator.rb
effective_resources-2.11.2 lib/validators/email_cc_validator.rb
effective_resources-2.11.1 lib/validators/email_cc_validator.rb
effective_resources-2.11.0 lib/validators/email_cc_validator.rb
effective_resources-2.10.1 lib/validators/email_cc_validator.rb
effective_resources-2.10.0 lib/validators/email_cc_validator.rb
effective_resources-2.9.7 lib/validators/email_cc_validator.rb
effective_resources-2.9.6 lib/validators/email_cc_validator.rb