module EmailDetected

Constants

MESSAGES
VALID_EMAIL_REGEX
VERSION

Public Class Methods

config(&block) click to toggle source
# File lib/email_detected.rb, line 29
def self.config(&block)
  if block_given?
    block.call(EmailDetected::Config)
  else
    EmailDetected::Config
  end
end
exist?(email) click to toggle source
# File lib/email_detected.rb, line 13
def self.exist?(email)
  return true if config.test_mode
  unless email.match VALID_EMAIL_REGEX
    return { status: false, message: 'The email address invalid.' }
  end

  email_detected = EmailDetected::Checker.run(email)
  if email_detected.invalid?
    resp = { status: false, message: email_detected.errors.first }
  else
    message = email_detected.errors.first || 'The email address has already been registered.'
    resp = { status: true, message: message }
  end
  resp
end