Skip to content

hixdevs/email-validator-rubygem

Repository files navigation

Gem validatemail, by hix.dev

Gem Version Build Status

The validatemail gem is used to make sure that provided email addresses are valid. Providing all ENV variables, you can validate 1.4k email addresses monthly, for free.

Every time it runs, it hits the randomly selected API and returns the normalized data. If the HTTP response code is other than 200, it hits the next one, and so on.

Usage

  1. Update to the latest Ruby 3.2.1, using any of the Ruby version managers.
  2. Do one of the following:
  • Run gem install validatemail
  • Run bundle add validatemail
  1. In your runtime, add following ENV variables:
  1. Use the following code
$ validatemail = Validatemail::API.new("valid@example.com")
$ validatemail.ok?
> true | false
$ validatemail.data
> Validatemail::Struct(
  email: string
  valid: boolean
  validated_by: enum("Abstract" | "Apilayer" | "Hunter" | "Reacher" | "Whoisxml" | "Zerobounce")
  autocorrect: string | null
  score: float | null
  first_name: string | null
  last_name: string | null
  free: boolean | null
)

Development

Clone the repository and run bundle install. An example script to play around with the development gem version would be:

Gemfile

source "https://rubygems.org"

gem "validatemail", path: "/path/to/email-validator-rubygem"

validatemail.rb

require "bundler/setup"
require "validatemail"

ENV['VALIDATEMAIL_ABSTRACT_API_KEY'] = "YOUR_KEY"
ENV['VALIDATEMAIL_APILAYER_API_KEY'] = "YOUR_KEY"
ENV['VALIDATEMAIL_HUNTER_API_KEY'] = "YOUR_KEY"
ENV['VALIDATEMAIL_REACHER_API_KEY'] = "YOUR_KEY"
ENV['VALIDATEMAIL_ZEROBOUNCE_API_KEY'] = "YOUR_KEY"
ENV['VALIDATEMAIL_WHOISXML_API_KEY'] = "YOUR_KEY"

validatemail = Validatemail::API.new("valid@example.com")
binding.pry

with those 2 files in place, you can

bundle install
ruby validatemail.rb

Tests

Run bundle exec rspec.

Code Quality

  1. Run bundle exec rubocop -a.
  2. Run bundle exec fasterer.