README.md in valid_email2-3.5.0 vs README.md in valid_email2-3.6.0
- old
+ new
@@ -41,14 +41,18 @@
class User < ActiveRecord::Base
validates :email, presence: true, 'valid_email_2/email': true
end
```
-To validate that the domain has a MX record:
+To validate that the domain has an MX record or A record:
```ruby
validates :email, 'valid_email_2/email': { mx: true }
```
+To validate strictly that the domain has an MX record:
+```ruby
+validates :email, 'valid_email_2/email': { strict_mx: true }
+```
To validate that the domain is not a disposable email (checks domain and MX server):
```ruby
validates :email, 'valid_email_2/email': { disposable: true }
```
@@ -107,10 +111,11 @@
```ruby
address = ValidEmail2::Address.new("lisinge@gmail.com")
address.valid? => true
address.disposable? => false
address.valid_mx? => true
+address.valid_strict_mx? => true
address.subaddressed? => false
```
### Test environment
@@ -118,9 +123,10 @@
It is a good idea to stub out that validation in your test environment.
Do so by adding this in your `spec_helper`:
```ruby
config.before(:each) do
allow_any_instance_of(ValidEmail2::Address).to receive(:valid_mx?).and_return(true)
+ allow_any_instance_of(ValidEmail2::Address).to receive(:valid_strict_mx?).and_return(true)
end
```
Validating `disposable` e-mails triggers a `mx` validation alongside checking if
the domain is disposable. The above stub does not apply to the `disposable`