README.md in valid_email2-2.2.1 vs README.md in valid_email2-2.2.2
- old
+ new
@@ -3,12 +3,12 @@
[](http://badge.fury.io/rb/valid_email2)
Validate emails with the help of the `mail` gem instead of some clunky regexp.
Aditionally validate that the domain has a MX record.
Optionally validate against a static [list of disposable email services](vendor/disposable_emails.yml).
+Optionally validate that the email is not subaddressed ([RFC5233](https://tools.ietf.org/html/rfc5233)).
-
### Why?
There are lots of other gems and libraries that validates email addresses but most of them use some clunky regexp.
I also saw a need to be able to validate that the email address is not coming from a "disposable email" provider.
@@ -56,13 +56,18 @@
To validate that the domain is not blacklisted (under vendor/blacklist.yml):
```ruby
validates :email, 'valid_email_2/email': { blacklist: true }
```
+To validate that email is not subaddressed:
+```ruby
+validates :email, 'valid_email_2/email': { disallow_subaddressing: true }
+```
+
All together:
```ruby
-validates :email, 'valid_email_2/email': { mx: true, disposable: true }
+validates :email, 'valid_email_2/email': { mx: true, disposable: true, disallow_subaddressing: true}
```
> Note that this gem will let an empty email pass through so you will need to
> add `presence: true` if you require an email
@@ -71,9 +76,10 @@
```ruby
address = ValidEmail2::Address.new("lisinge@gmail.com")
address.valid? => true
address.disposable? => false
address.valid_mx? => true
+address.subaddressed? => false
```
### Test environment
If you are validating `mx` then your specs will fail without an internet connection.