Sha256: 561b9c4fc28435b2ee2ad1b7f084d4872bec49eb18d79d0c50ef1fce8f767f0b

Contents?: true

Size: 626 Bytes

Versions: 6

Compression:

Stored size: 626 Bytes

Contents

require 'active_model'
require 'active_model/validations'
require 'mail'
require 'valid_email/validate_email'
class BanDisposableEmailValidator < ActiveModel::EachValidator
  # A list of disposable email domains
  def self.config=(options)
    @@config = options
  end

  # Required to use config outside
  def self.config
    @@config = [] unless defined? @@config

    @@config
  end

  def validate_each(record, attribute, value)
    r = ValidateEmail.ban_disposable_email?(value)
    record.errors.add attribute, (options[:message] || I18n.t(:invalid, :scope => "valid_email.validations.email")) unless r

    r
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
valid_email-0.0.11 lib/valid_email/ban_disposable_email_validator.rb
valid_email-0.0.10 lib/valid_email/ban_disposable_email_validator.rb
valid_email-0.0.9 lib/valid_email/ban_disposable_email_validator.rb
valid_email-0.0.8 lib/valid_email/ban_disposable_email_validator.rb
valid_email-0.0.6 lib/valid_email/ban_disposable_email_validator.rb
valid_email-0.0.7 lib/valid_email/ban_disposable_email_validator.rb