6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/nondisposable/email_validator.rb', line 6
def validate_each(record, attribute, value)
return if value.blank?
begin
domain = value.to_s.split('@').last&.downcase
return if domain.nil?
if Nondisposable::DisposableDomain.disposable?(domain)
record.errors.add(attribute, options[:message] || Nondisposable.configuration.error_message)
end
rescue StandardError => e
Rails.logger.error "Nondisposable validation error: #{e.message}"
record.errors.add(attribute, "is an invalid email address, cannot check if it's disposable")
end
end
|