sixarm_ruby_email_address_validation
SixArm.com » Ruby » Email address validation using RFC 822
https://github.com/sixarm/sixarm_ruby_email_address_validation
Science Score: 44.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (7.9%) to scientific vocabulary
Keywords
Repository
SixArm.com » Ruby » Email address validation using RFC 822
Basic Info
- Host: GitHub
- Owner: SixArm
- License: other
- Language: Ruby
- Default Branch: main
- Homepage: http://sixarm.com
- Size: 433 KB
Statistics
- Stars: 10
- Watchers: 2
- Forks: 0
- Open Issues: 1
- Releases: 0
Topics
Metadata Files
README.md
SixArm.com → Ruby →
Email address validation using RFC 822
- Git: https://github.com/SixArm/sixarm_ruby_email_address_validation
- Doc: http://sixarm.com/sixarm_ruby_email_address_validation/doc
- Gem: https://rubygems.org/gems/sixarm_ruby_email_address_validation
- Contact: Joel Parker Henderson, joel@sixarm.com
- Project: changes, license, contributing.
w
Introduction
Email address regular expression to validate an email address using RFC 822.
The original PHP code is by Cal Henderson, see http://iamcal.com/publish/articles/php/parsing_email/
Translated to Ruby by Tim Fletcher, with changes suggested by Dan Kubb, see http://tfletcher.com/lib/rfc822.rb
For docs go to http://sixarm.com/sixarm_ruby_email_address_validation/doc
Want to help? We're happy to get pull requests.
Related links:
- RFC 2822: http://tools.ietf.org/html/rfc2822
- Dominic Sayers is_email: http://isemail.info/
- Wikipedia email address: http://en.wikipedia.org/wiki/Email_address
- Email address validator with parsing expression grammar: https://github.com/larb/emailaddressvalidator
- ActiveModel gem to delegate to Mail gem: https://github.com/codyrobbins/active-model-email-validator
Install
Gem
To install this gem in your shell or terminal:
gem install sixarm_ruby_email_address_validation
Gemfile
To add this gem to your Gemfile:
gem 'sixarm_ruby_email_address_validation'
Require
To require the gem in your code:
require 'sixarm_ruby_email_address_validation'
Pattern
To find an email address, anywhere in a string, use the Pattern constant.
- If a match is anywhere in the string, then return the character position index.
- If there's no match, then return nil.
Example:
EmailAddressValidation::Pattern =~ "alice@example.com"
=> 0
EmailAddressValidation::Pattern =~ "--- alice@example.com ---"
=> 4
Pattern Exact
To find an email address, and ensure that it is the entire string, use the PatternExact constant.
- If a match is the entire string, then return the character position index, which is always 0.
- Otherwise return nil.
Example:
EmailAddressValidation::PatternExact =~ "alice@example.com'
#=> 0
EmailAddressValidation::PatternExact =~ "--- alice@example.com ---"
#=> nil
Examples
The patterns are easy to use in your own code.
Example of a condition:
text = "alice@example.com"
if EmailAddressValidation::PatternExact =~ text
puts "valid"
else
puts "invalid"
end
Example of a method:
def valid?(text)
EmailAddressValidation::PatternExact =~ text ? true : false
end
valid?("alice@example.com") #=> true
valid?("alice") #=> false
Example of a scan which gets all the email adddresses:
text = "To alice@example.com and bob@example.org and others"
text.scan(EmailAddressValidation::Pattern)
#=> ["alice@example.com", "bob@example.org"]
Example of a scan which iterates on each email address:
text = "To alice@example.com and bob@example.org and others"
text.scan(EmailAddressValidation::Pattern) do |match|
puts match
end
#=>
alice@example.com
bob@example.org
Example of a Rails user class:
class User
include EmailAddressValidation
validates :email_address, :format => { :with => EmailAddressValidation::PatternExact }
end
Frequently Asked Questions
Q. Does this handle unusual email addresses, like foo+bar@my.com?
A. Yes. It handles all RFC email addresses. If you find an RFC email address that fails, please let us know.
Q. Why use this in a Rails app?
A. We use it to detect a potential typo during user registration, so we can prompt the user to correct it before we send a typical welcome email with a registration link. If we didn't validate the email address format, then we would have sent the welcome email to the wrong user, or into the void.
Q. Why use this to get more than one email address?
A. We use it to find typos in large databases of email addresses where it's not a business option to send the user an email. For example, proofing an existing report of 10 million users in a CSV file. We need to contact anyone with a malformed email address, so we actually call them if we have their phone number. We can't send these people an email, because the address is invalid.
Owner
- Name: SixArm
- Login: SixArm
- Kind: organization
- Email: sixarm@sixarm.com
- Location: San Francisco
- Website: http://sixarm.com
- Twitter: sixarm
- Repositories: 580
- Profile: https://github.com/SixArm
SixArm Software
Citation (CITATION.cff)
cff-version: 1.2.0
title: SixArm.com → Ruby → <br> Email address validation using RFC 822
message: >-
If you use this work and you want to cite it,
then you can use the metadata from this file.
type: software
authors:
- given-names: Joel Parker
family-names: Henderson
email: joel@joelparkerhenderson.com
affiliation: joelparkerhenderson.com
orcid: 'https://orcid.org/0009-0000-4681-282X'
identifiers:
- type: url
value: 'https://github.com/SixArm/sixarm_ruby_email_address_validation/'
description: SixArm.com → Ruby → <br> Email address validation using RFC 822
repository-code: 'https://github.com/SixArm/sixarm_ruby_email_address_validation/'
abstract: >-
SixArm.com → Ruby → <br> Email address validation using RFC 822
license: See license file
GitHub Events
Total
Last Year
Committers
Last synced: 5 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Joel Parker Henderson | j****l@j****m | 102 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 5 months ago
All Time
- Total issues: 3
- Total pull requests: 0
- Average time to close issues: 5 days
- Average time to close pull requests: N/A
- Total issue authors: 3
- Total pull request authors: 0
- Average comments per issue: 5.0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- masterkain (1)
- josevalim (1)
- tigris (1)
