Coder Social home page Coder Social logo

roomorama / validates_email Goto Github PK

View Code? Open in Web Editor NEW

This project forked from spectator/validates_email

0.0 4.0 2.0 50 KB

validates_email is a Rails 3 plugin that validates email addresses against RFC 2822 and RFC 3696

License: MIT License

Ruby 95.56% Logos 4.44%

validates_email's Introduction

Gem Version Build Status Dependency Status

validates_email

validates_email is a Rails gem that validates email addresses against RFC 2822 and RFC 3696

Installation

Add the following to your gemfile

gem 'roomorama-validates_email', :require => 'validates_email'

Usage

class User < ActiveRecord::Base
  validates :primary_email, :email => true
end

As well as any other Rails validation this one has the same triggers, such as :on, :if, :unless, :allow_blank, and :allow_nil.

Also, you can pass your own custom error message.

class User < ActiveRecord::Base
  validates :primary_email, :email => { :message => 'is not an email address' }
end

If you like to check MX Records for email, you can use :mx option.

class User < ActiveRecord::Base
  validates :primary_email, :email => { :mx => true }
end

And if you like to check MX Records with fallback to A record, use :a_fallback option.

class User < ActiveRecord::Base
  validates :primary_email, :email => { :mx => { :a_fallback => true } }
end

I18n

If you don't specify your own error message, then ActiveRecord's :invalid error message will be used to show the error.

If do check MX Records, then you have to specify your own error message or add it to your traslations:

activerecord:
  errors:
    messages:
      mx_invalid: "is not valid"

Credits

Based off the spectagor-validates_email gem. Most of the code were taken from Alex Dunae (dunae.ca) plugin (see http://github.com/alexdunae/validates_email_format_of/) and adopted for Rails 3 playing around with Rails 3 beta, so pass all beers to him.

Contributors

  • Petr Blaho
  • Christian Eichhorn
  • Alexander Zubkov

How to contribute

  • Fork
  • Make changes
  • Write specs
  • Do pull request

Testing

To execute unit tests run rake spec within plugin folder.

The unit tests for this plugin use an in-memory sqlite3 database.

Notes

Compatible with the following ruby versions:

  • Ruby 1.8.7
  • Ruby 1.9.3
  • Ruby 2.0.0

Compatible with the following Rails versions:

  • Rails 3.0.x
  • Rails 3.1.x
  • Rails 3.2.1
  • Rails 4

validates_email's People

Contributors

spectator avatar donaldpiret avatar webhoernchen avatar joshuasiler avatar traf333 avatar

Watchers

Nicolas Gaivironsky avatar  avatar James Cloos avatar  avatar

Forkers

donaldpiret gfish

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.