New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

email_format_validator

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

email_format_validator

  • 1.0.4
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Installation

Add this line to your Gemfile:

gem 'email_format_validator'

Then run:

bundle install

Usage

Add the following to one of your models:

validates :email, email_format: true

You can turn on RFC 822 compliant email verification by passing on:

validates :email, email_format: { rfc: true }

Be aware that this is disabled by default as websites will often need a less permissive email check than the RFC one (check out tests for more details).

You can also modify the default message ("is improperly formatted") if validation fails:

validates :email, email_format: { message: "is not well formatted" }

I18n

If you use I18n, the default key to translate is :improperly_formatted. So if you add to your User model:

validates :email, email_format: true

You can translate (or overload) the default message via for e.g. (in english): "en.activerecord.errors.models.user.attributes.email.improperly_formatted"

Tests

cd test
ruby email_format_validator_test.rb

Compatibility

Ruby 1.8 is not supported.

Credits

Regular Expression tests based on Comparing E-mail Address Validating Regular Expressions

FAQs

Package last updated on 15 Nov 2011

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc