
Security News
Nx npm Packages Compromised in Supply Chain Attack Weaponizing AI CLI Tools
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
activemodel-email_address_validator
Advanced tools
Whenever I have wanted to validate an email address it has been because I wanted to be somewhat certain I can send an email to someone. Usually this happens as part of a signup procedure.
At this point I have pretty much one criteria:
Quite frankly, I don't care about the RFC at this point, neither does the user. I care that my users can enter their email address and get on with using my product. I appreciate it if the application catches any misspellings of their email addresses, though - this is the opportune moment for them to correct it.
"postmaster@localhost"
or "bob@1.2.3.4"
even though they are perfectly valid email addresses.:invalid
.validates :email, :email_address => true
If the default behavior isn't enough for you, you can include a custom rule for email addresses. For example to match the email addresses against a regular expression:
validates :email, :email_address => {:with => /.+@.+\..+/}
Or you could go beyound simple matching and validate that all email adresses belong to the same company:
validates :email, :email_address => {
:with => proc { |address| address.end_with?("@substancelab.com") }
}
You can even match against multiple rules, in which case all rules must pass:
validates :email, :email_address => {
:with => [
proc { |address| address.match(/.+@.+\..+/) },
proc { |address| !address.end_with?("@outlook.com") },
]
}
Do note that supplying your own rules means that the default email address validation isn't run - you're on your own, basically.
This also checks that the domain actually has an MX record. Note this might take a while because of DNS lookups.
validates :email, :email_address => {:mx => true}
Add this line to your application's Gemfile:
gem 'activemodel-email_address_validator'
And then execute:
$ bundle
Or install it yourself as:
$ gem install activemodel-email_address_validator
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)FAQs
Unknown package
We found that activemodel-email_address_validator demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.
Security News
A clarification on our recent research investigating 60 malicious Ruby gems.