Class: ThrowawayValidator

Inherits:
ActiveModel::EachValidator
  • Object
show all
Defined in:
lib/throwaway/throwaway_validator.rb

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



4
5
6
7
8
9
# File 'lib/throwaway/throwaway_validator.rb', line 4

def validate_each(record, attribute, value)
  result = Throwaway.is_throwaway?(value)

  record.errors[attribute] << (options[:message] || "is not from a disposable email provider.") if options[:with].nil? and !result
  record.errors[attribute] << (options[:message] || "is from a disposable email provider.") if !options[:with].nil? and result
end