roomorama-validates_email 0.3 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ddcdbbde2feff111daaaa44a572a75862ed1dfbf
4
- data.tar.gz: 89abaf46306e9a869477b2c112a2b4b4fd295da0
3
+ metadata.gz: b29f15f9211a9ba258a444d4eff61887241aa59e
4
+ data.tar.gz: d3a2a29717552ce7672eae767d7604e81eff08ac
5
5
  SHA512:
6
- metadata.gz: 41f7888a01fda2d35e2586398f0db5d983ebc80c90a9ab8b28eff6d16cb5cb3fbe8baba91a6f6459ab88afb264d3d690e3da4ce4be8afef17ac6106d60408095
7
- data.tar.gz: 2978e739dc792899c5969c6ee3429d0ee2ed829cd4595b47a62afe782e5dbedb18d5e26b209ce0ab0eb114b8331c123cab892fd4a18aa8f2224facd4e75b773d
6
+ metadata.gz: 2fe40360f5ca4d71b98781f5ccab75cb585bcb2b78607772509ba3c5ffa4dfb233b5df4a0baff60bcf86adf990eb39e83969d5b902ae786746c74fdf88654459
7
+ data.tar.gz: 80f447ef1f0c2694288d2b359c0c5f84608760e23df7d4d2b819619b3a9e318579f96dfcec84a7152d4c8505294bea9c78042b63d690d2ebe507237d12aac1fb
@@ -22,10 +22,13 @@ class EmailValidator < ActiveModel::EachValidator
22
22
  #
23
23
  def validate_each(record, attribute, value)
24
24
  if validates_email_format(value)
25
- if options[:mailgun] && ENV['MAILGUN_PUBLIC_KEY'].present? && !validates_email_with_mailgun(value)
25
+ validate_mailgun = options[:mailgun] && options[:mailgun].respond_to?(:call) ? options[:mailgun].call(record) : options[:mailgun]
26
+ if validate_mailgun && ENV['MAILGUN_PUBLIC_KEY'].present? && !validates_email_with_mailgun(value)
26
27
  record.errors.add(attribute, options[:mailgun_message] || :invalid)
27
28
  end
28
- if options[:mx] && !validates_email_domain(value, options[:mx])
29
+ validate_mx_condition = options[:mx] && options[:mx].is_a?(Hash) ? (options[:mx][:if].nil? ? true : options[:mx][:if]) : options[:mx]
30
+ validate_mx = validate_mx_condition && validate_mx_condition.respond_to?(:call) ? validate_mx_condition.call(record) : validate_mx_condition
31
+ if validate_mx && !validates_email_domain(value, options[:mx])
29
32
  record.errors.add(attribute, options[:mx_message] || :mx_invalid)
30
33
  end
31
34
  else
@@ -1,3 +1,3 @@
1
1
  module ValidatesEmail
2
- VERSION = '0.3'
2
+ VERSION = '0.3.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roomorama-validates_email
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.3'
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Donald Piret