truemail 2.7.5 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1e06a06a5475f233ad747c59b77d50aac4465e231aaf9fef7cd40bed66fb4282
4
- data.tar.gz: d5ebb376ee5b00dc9100373f733afd8af5c5bdcaf0a11c1c467b6b996320950a
3
+ metadata.gz: 5aaf968788710bfc570f154269d75830058841b3936b542246de4557be3b4727
4
+ data.tar.gz: 3ebe69aa575bc2eb84e277c7ee77bdf055ff112597926e167db84903fb4a7ad4
5
5
  SHA512:
6
- metadata.gz: '0696f4165309a5a9b82e337c3c1efd813de5da1c136c2015dae539e30e2a3e3f4aabd46920eab38051fa093be6c1af8845412545f8a7ab91e5b5ee233f639390'
7
- data.tar.gz: 958d4e6999f596d056cfe8a75fc058ce417e14f7cc0de500848d9f0ed7e8a250fad435f62f546282dd196a136c30a04556bef7c884933dcc375e4bb4f95a87af
6
+ metadata.gz: f6e6941d7990f128258308bcf24205162fc968c3c03a74f451c765059b53a3ded73ea0ef7a545edd36456d93f0318f66b016640b2c02986f8c0b117ed8ab28b1
7
+ data.tar.gz: 516f7151529e111845044c8c3c238b549d4fc989d460f6568e9a2f1586d083f4d355b53d0dc939a3f2d714dc4834fe920eab1bba31d287abd57a43d8fc223f80
data/.circleci/config.yml CHANGED
@@ -122,7 +122,7 @@ jobs:
122
122
  - checkout
123
123
  - <<: *use_compatible_gemspec
124
124
  - ruby/install-deps:
125
- bundler-version: "2.3.23"
125
+ bundler-version: "2.3.24"
126
126
  with-cache: false
127
127
  path: './vendor/custom_bundle'
128
128
  - <<: *install_system_dependencies
@@ -42,7 +42,7 @@ Gem::Specification.new do |spec|
42
42
  spec.add_development_dependency 'rake', '~> 13.0', '>= 13.0.6'
43
43
  spec.add_development_dependency 'reek', '~> 6.1', '>= 6.1.1'
44
44
  spec.add_development_dependency 'rspec', '~> 3.11'
45
- spec.add_development_dependency 'rubocop', '~> 1.36'
45
+ spec.add_development_dependency 'rubocop', '~> 1.37'
46
46
  spec.add_development_dependency 'rubocop-performance', '~> 1.15'
47
47
  spec.add_development_dependency 'rubocop-rspec', '~> 2.13', '>= 2.13.2'
48
48
  spec.add_development_dependency 'simplecov', '~> 0.21.2'
data/.codeclimate.yml CHANGED
@@ -7,7 +7,7 @@ checks:
7
7
  plugins:
8
8
  rubocop:
9
9
  enabled: true
10
- channel: rubocop-1-36
10
+ channel: rubocop-1-37
11
11
 
12
12
  reek:
13
13
  enabled: true
data/.reek.yml CHANGED
@@ -15,6 +15,7 @@ detectors:
15
15
  - Truemail::Configuration#logger=
16
16
  - Truemail::Validate::Smtp::Request#initialize
17
17
  - Truemail::Validate::Smtp::Request::Session#initialize
18
+ - Truemail::RSpec::ValidatorHelper::ValidatorFactory#process_validator_params
18
19
 
19
20
  TooManyInstanceVariables:
20
21
  exclude:
data/CHANGELOG.md CHANGED
@@ -2,6 +2,37 @@
2
2
 
3
3
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
4
4
 
5
+ ## [3.0.0] - 2022.10.24
6
+
7
+ ### Added
8
+
9
+ - Added ability to specify whitelisted/blacklisted emails by complete match
10
+
11
+ ```ruby
12
+ Truemail.configure do |config|
13
+ # Optional parameter. Validation of email which contains whitelisted emails always will
14
+ # return true. Other validations will not processed even if it was defined in validation_type_for
15
+ # It is equal to empty array by default.
16
+ config.whitelisted_emails = %w[user@somedomain1.com user@somedomain2.com]
17
+
18
+ # Optional parameter. Validation of email which contains blacklisted emails always will
19
+ # return false. Other validations will not processed even if it was defined in validation_type_for
20
+ # It is equal to empty array by default.
21
+ config.blacklisted_emails = %w[user@somedomain3.com user@somedomain4.com]
22
+ end
23
+ ```
24
+
25
+ ### Updated
26
+
27
+ - Updated `Truemail::Configuration`, tests
28
+ - Updated namespace from `Truemail::Validate::DomainListMatch` to `Truemail::Validate::ListMatch`
29
+ - Updated `Truemail::Validator#run, tests
30
+ - Updated `Truemail::Log::Serializer::ValidatorJson`, tests
31
+ - Updated `Truemail::Log::Serializer::ValidatorText`, tests
32
+ - Updated `Truemail::Log::Serializer::AuditorJson`, tests
33
+ - Updated schemas, gemspecs, circleci/codeclimate config
34
+ - Updated docs, gem version
35
+
5
36
  ## [2.7.5] - 2022.10.10
6
37
 
7
38
  ### Updated
data/README.md CHANGED
@@ -130,9 +130,11 @@ You can use global gem configuration or custom independent configuration. Availa
130
130
  - connection attempts
131
131
  - default validation type
132
132
  - validation type for domains
133
+ - whitelisted emails
134
+ - blacklisted emails
133
135
  - whitelisted domains
134
- - whitelist validation
135
136
  - blacklisted domains
137
+ - whitelist validation
136
138
  - blacklisted mx ip-addresses
137
139
  - custom DNS gateway(s)
138
140
  - RFC MX lookup flow
@@ -190,22 +192,32 @@ Truemail.configure do |config|
190
192
  # It is equal to empty hash by default.
191
193
  config.validation_type_for = { 'somedomain.com' => :regex, 'otherdomain.com' => :mx }
192
194
 
195
+ # Optional parameter. Validation of email which contains whitelisted emails always will
196
+ # return true. Other validations will not processed even if it was defined in validation_type_for
197
+ # It is equal to empty array by default.
198
+ config.whitelisted_emails = %w[user@somedomain1.com user@somedomain2.com]
199
+
200
+ # Optional parameter. Validation of email which contains blacklisted emails always will
201
+ # return false. Other validations will not processed even if it was defined in validation_type_for
202
+ # It is equal to empty array by default.
203
+ config.blacklisted_emails = %w[user@somedomain3.com user@somedomain4.com]
204
+
193
205
  # Optional parameter. Validation of email which contains whitelisted domain always will
194
206
  # return true. Other validations will not processed even if it was defined in validation_type_for
195
207
  # It is equal to empty array by default.
196
208
  config.whitelisted_domains = %w[somedomain1.com somedomain2.com]
197
209
 
210
+ # Optional parameter. Validation of email which contains blacklisted domain always will
211
+ # return false. Other validations will not processed even if it was defined in validation_type_for
212
+ # It is equal to empty array by default.
213
+ config.blacklisted_domains = %w[somedomain3.com somedomain4.com]
214
+
198
215
  # Optional parameter. With this option Truemail will validate email which contains whitelisted
199
216
  # domain only, i.e. if domain whitelisted, validation will passed to Regex, MX or SMTP validators.
200
217
  # Validation of email which not contains whitelisted domain always will return false.
201
218
  # It is equal false by default.
202
219
  config.whitelist_validation = true
203
220
 
204
- # Optional parameter. Validation of email which contains blacklisted domain always will
205
- # return false. Other validations will not processed even if it was defined in validation_type_for
206
- # It is equal to empty array by default.
207
- config.blacklisted_domains = %w[somedomain3.com somedomain4.com]
208
-
209
221
  # Optional parameter. With this option Truemail will filter out unwanted mx servers via
210
222
  # predefined list of ip addresses. It can be used as a part of DEA (disposable email
211
223
  # address) validations. It is equal to empty array by default.
@@ -259,9 +271,11 @@ Truemail.configuration
259
271
  @connection_attempts=3,
260
272
  @default_validation_type=:mx,
261
273
  @validation_type_by_domain={"somedomain.com" => :regex, "otherdomain.com" => :mx},
274
+ @whitelisted_emails=["user@somedomain1.com", "user@somedomain2.com"],
275
+ @blacklisted_emails=["user@somedomain3.com", "user@somedomain4.com"],
262
276
  @whitelisted_domains=["somedomain1.com", "somedomain2.com"],
263
- @whitelist_validation=true,
264
277
  @blacklisted_domains=["somedomain3.com", "somedomain4.com"],
278
+ @whitelist_validation=true,
265
279
  @blacklisted_mx_ip_addresses=["1.1.1.1", "2.2.2.2"],
266
280
  @dns=["10.0.0.1", "10.0.0.2:54"],
267
281
  @verifier_domain="somedomain.com",
@@ -293,9 +307,11 @@ Truemail.configuration
293
307
  @connection_attempts=1,
294
308
  @default_validation_type=:mx,
295
309
  @validation_type_by_domain={"somedomain.com" => :regex, "otherdomain.com" => :mx},
310
+ @whitelisted_emails=["user@somedomain1.com", "user@somedomain2.com"],
311
+ @blacklisted_emails=["user@somedomain3.com", "user@somedomain4.com"],
296
312
  @whitelisted_domains=["somedomain1.com", "somedomain2.com"],
297
- @whitelist_validation=true,
298
313
  @blacklisted_domains=["somedomain3.com", "somedomain4.com"],
314
+ @whitelist_validation=true,
299
315
  @blacklisted_mx_ip_addresses=["1.1.1.1", "2.2.2.2"],
300
316
  @dns=["10.0.0.1", "10.0.0.2:54"],
301
317
  @verifier_domain="somedomain.com",
@@ -339,7 +355,7 @@ Please note, you should have global or custom configuration for use Truemail gem
339
355
 
340
356
  #### Whitelist/Blacklist check
341
357
 
342
- Whitelist/Blacklist check is zero validation level. You can define white and black list domains. It means that validation of email which contains whitelisted domain always will return `true`, and for blacklisted domain will return `false`.
358
+ Whitelist/Blacklist check is zero validation level. You can define white and black emails/domains lists. It means that validation of email which contains whitelisted email or domain always will return `true`, and for blacklisted email or domain will return `false`.
343
359
 
344
360
  Please note, other validations will not processed even if it was defined in `validation_type_for`.
345
361
 
@@ -356,6 +372,8 @@ require 'truemail'
356
372
 
357
373
  Truemail.configure do |config|
358
374
  config.verifier_email = 'verifier@example.com'
375
+ config.whitelisted_emails = %w[user@somedomain1.com user@somedomain2.com]
376
+ config.blacklisted_emails = %w[user@somedomain3.com user@somedomain4.com]
359
377
  config.whitelisted_domains = %w[white-domain.com somedomain.com]
360
378
  config.blacklisted_domains = %w[black-domain.com somedomain.com]
361
379
  config.validation_type_for = { 'somedomain.com' => :mx }
@@ -378,6 +396,8 @@ Truemail.validate('email@white-domain.com')
378
396
  errors={},
379
397
  smtp_debug=nil>,
380
398
  configuration=#<Truemail::Configuration:0x00005629f801bd28
399
+ @whitelisted_emails=["user@somedomain1.com", "user@somedomain2.com"],
400
+ @blacklisted_emails=["user@somedomain3.com", "user@somedomain4.com"],
381
401
  @blacklisted_domains=["black-domain.com", "somedomain.com"],
382
402
  @blacklisted_mx_ip_addresses=[],
383
403
  @dns=[],
@@ -428,6 +448,8 @@ Truemail.validate('email@white-domain.com', with: :regex)
428
448
  smtp_debug=nil>,
429
449
  configuration=
430
450
  #<Truemail::Configuration:0x0000563f0d2605c8
451
+ @whitelisted_emails=[],
452
+ @blacklisted_emails=[],
431
453
  @blacklisted_domains=[],
432
454
  @blacklisted_mx_ip_addresses=[],
433
455
  @dns=[],
@@ -464,6 +486,8 @@ Truemail.validate('email@domain.com', with: :regex)
464
486
  smtp_debug=nil>,
465
487
  configuration=
466
488
  #<Truemail::Configuration:0x0000563f0cd82ab0
489
+ @whitelisted_emails=[],
490
+ @blacklisted_emails=[],
467
491
  @blacklisted_domains=[],
468
492
  @blacklisted_mx_ip_addresses=[],
469
493
  @dns=[],
@@ -502,6 +526,8 @@ Truemail.validate('email@black-domain.com')
502
526
  smtp_debug=nil>,
503
527
  configuration=
504
528
  #<Truemail::Configuration:0x0000563f0d36f4f0
529
+ @whitelisted_emails=[],
530
+ @blacklisted_emails=[],
505
531
  @blacklisted_domains=[],
506
532
  @blacklisted_mx_ip_addresses=[],
507
533
  @dns=[],
@@ -540,6 +566,8 @@ Truemail.validate('email@somedomain.com')
540
566
  smtp_debug=nil>,
541
567
  configuration=
542
568
  #<Truemail::Configuration:0x0000563f0d3f8fc0
569
+ @whitelisted_emails=[],
570
+ @blacklisted_emails=[],
543
571
  @blacklisted_domains=[],
544
572
  @blacklisted_mx_ip_addresses=[],
545
573
  @dns=[],
@@ -595,6 +623,8 @@ Truemail.validate('email@example.com', with: :regex)
595
623
  smtp_debug=nil>,
596
624
  configuration=
597
625
  #<Truemail::Configuration:0x000055aa56a54d48
626
+ @whitelisted_emails=[],
627
+ @blacklisted_emails=[],
598
628
  @blacklisted_domains=[],
599
629
  @blacklisted_mx_ip_addresses=[],
600
630
  @dns=[],
@@ -641,6 +671,8 @@ Truemail.validate('email@example.com', with: :regex)
641
671
  smtp_debug=nil>,
642
672
  configuration=
643
673
  #<Truemail::Configuration:0x0000560e58d80830
674
+ @whitelisted_emails=[],
675
+ @blacklisted_emails=[],
644
676
  @blacklisted_domains=[],
645
677
  @blacklisted_mx_ip_addresses=[],
646
678
  @dns=[],
@@ -698,6 +730,8 @@ Truemail.validate('email@example.com', with: :mx)
698
730
  smtp_debug=nil>,
699
731
  configuration=
700
732
  #<Truemail::Configuration:0x0000559b6e44af70
733
+ @whitelisted_emails=[],
734
+ @blacklisted_emails=[],
701
735
  @blacklisted_domains=[],
702
736
  @blacklisted_mx_ip_addresses=[],
703
737
  @dns=[],
@@ -746,6 +780,8 @@ Truemail.validate('email@example.com', with: :mx)
746
780
  smtp_debug=nil>,
747
781
  configuration=
748
782
  #<Truemail::Configuration:0x0000559b6e44af70
783
+ @whitelisted_emails=[],
784
+ @blacklisted_emails=[],
749
785
  @blacklisted_domains=[],
750
786
  @blacklisted_mx_ip_addresses=[],
751
787
  @dns=[],
@@ -798,6 +834,8 @@ Truemail.validate('email@example.com', with: :mx_blacklist)
798
834
  smtp_debug=nil,
799
835
  configuration=
800
836
  #<Truemail::Configuration:0x00007fca0c8aeb38
837
+ @whitelisted_emails=[],
838
+ @blacklisted_emails=[],
801
839
  @blacklisted_domains=[],
802
840
  @blacklisted_mx_ip_addresses=["127.0.1.2"],
803
841
  @connection_attempts=2,
@@ -875,6 +913,8 @@ Truemail.validate('email@example.com')
875
913
  errors={}>>],
876
914
  configuration=
877
915
  #<Truemail::Configuration:0x00007fdc4504f5c8
916
+ @whitelisted_emails=[],
917
+ @blacklisted_emails=[],
878
918
  @blacklisted_domains=[],
879
919
  @blacklisted_mx_ip_addresses=[],
880
920
  @dns=[],
@@ -921,6 +961,8 @@ Truemail.validate('email@example.com')
921
961
  smtp_debug=nil>,
922
962
  configuration=
923
963
  #<Truemail::Configuration:0x00005615e87b9298
964
+ @whitelisted_emails=[],
965
+ @blacklisted_emails=[],
924
966
  @blacklisted_domains=[],
925
967
  @blacklisted_mx_ip_addresses=[],
926
968
  @dns=[],
@@ -973,6 +1015,8 @@ Truemail.validate('email@example.com')
973
1015
  errors={:rcptto=>"550 User not found\n"}>>]>,
974
1016
  configuration=
975
1017
  #<Truemail::Configuration:0x00005615e87b9298
1018
+ @whitelisted_emails=[],
1019
+ @blacklisted_emails=[],
976
1020
  @blacklisted_domains=[],
977
1021
  @blacklisted_mx_ip_addresses=[],
978
1022
  @dns=[],
@@ -1038,6 +1082,8 @@ Truemail.validate('email@example.com')
1038
1082
  errors={:mailfrom=>"554 5.7.1 Client host blocked\n", :connection=>"server dropped connection after response"}>>,]>,
1039
1083
  configuration=
1040
1084
  #<Truemail::Configuration:0x00005615e87b9298
1085
+ @whitelisted_emails=[],
1086
+ @blacklisted_emails=[],
1041
1087
  @blacklisted_domains=[],
1042
1088
  @blacklisted_mx_ip_addresses=[],
1043
1089
  @dns=[],
@@ -1087,6 +1133,8 @@ Truemail.validate('email@example.com')
1087
1133
  errors={:rcptto=>"550 User not found\n"}>>]>,
1088
1134
  configuration=
1089
1135
  #<Truemail::Configuration:0x00005615e87b9298
1136
+ @whitelisted_emails=[],
1137
+ @blacklisted_emails=[],
1090
1138
  @blacklisted_domains=[],
1091
1139
  @blacklisted_mx_ip_addresses=[],
1092
1140
  @dns=[],
@@ -1138,6 +1186,8 @@ Truemail.host_audit
1138
1186
  warnings={}>,
1139
1187
  configuration=
1140
1188
  #<Truemail::Configuration:0x00005615e86327a8
1189
+ @whitelisted_emails=[],
1190
+ @blacklisted_emails=[],
1141
1191
  @blacklisted_domains=[],
1142
1192
  @blacklisted_mx_ip_addresses=[],
1143
1193
  @dns=[],
@@ -1168,6 +1218,8 @@ Truemail.host_audit
1168
1218
  },
1169
1219
  configuration=
1170
1220
  #<Truemail::Configuration:0x00005615e86327a8
1221
+ @whitelisted_emails=[],
1222
+ @blacklisted_emails=[],
1171
1223
  @blacklisted_domains=[],
1172
1224
  @blacklisted_mx_ip_addresses=[],
1173
1225
  @dns=[],
@@ -1223,6 +1275,8 @@ Truemail::Log::Serializer::AuditorJson.call(Truemail.host_audit)
1223
1275
  "dns": "A-record of verifier domain not refers to current host ip address", "ptr": "PTR-record does not reference to current verifier domain"
1224
1276
  },
1225
1277
  "configuration": {
1278
+ "whitelisted_emails": null,
1279
+ "blacklisted_emails": null,
1226
1280
  "blacklisted_domains": null,
1227
1281
  "blacklisted_mx_ip_addresses": null,
1228
1282
  "dns": null,
@@ -1264,6 +1318,8 @@ Truemail::Log::Serializer::ValidatorJson.call(Truemail.validate('nonexistent_ema
1264
1318
  }
1265
1319
  ],
1266
1320
  "configuration": {
1321
+ "whitelisted_emails": null,
1322
+ "blacklisted_emails": null,
1267
1323
  "blacklisted_domains": null,
1268
1324
  "blacklisted_mx_ip_addresses": null,
1269
1325
  "dns": null,
@@ -1307,6 +1363,8 @@ Truemail.host_audit.as_json
1307
1363
  "dns": "A-record of verifier domain not refers to current host ip address", "ptr": "PTR-record does not reference to current verifier domain"
1308
1364
  },
1309
1365
  "configuration": {
1366
+ "whitelisted_emails": null,
1367
+ "blacklisted_emails": null,
1310
1368
  "blacklisted_domains": null,
1311
1369
  "blacklisted_mx_ip_addresses": null,
1312
1370
  "dns": null,
@@ -1345,6 +1403,8 @@ Truemail.validate('nonexistent_email@bestweb.com.ua').as_json
1345
1403
  }
1346
1404
  ],
1347
1405
  "configuration": {
1406
+ "whitelisted_emails": null,
1407
+ "blacklisted_emails": null,
1348
1408
  "blacklisted_domains": null,
1349
1409
  "blacklisted_mx_ip_addresses": null,
1350
1410
  "dns": null,
@@ -14,6 +14,8 @@ module Truemail
14
14
  connection_timeout
15
15
  response_timeout
16
16
  connection_attempts
17
+ whitelisted_emails
18
+ blacklisted_emails
17
19
  whitelisted_domains
18
20
  blacklisted_domains
19
21
  blacklisted_mx_ip_addresses
@@ -100,6 +102,8 @@ module Truemail
100
102
  default_validation_type: Truemail::Configuration::DEFAULT_VALIDATION_TYPE,
101
103
  smtp_port: Truemail::Configuration::DEFAULT_SMTP_PORT,
102
104
  validation_type_by_domain: {},
105
+ whitelisted_emails: [],
106
+ blacklisted_emails: [],
103
107
  whitelisted_domains: [],
104
108
  whitelist_validation: false,
105
109
  blacklisted_domains: [],
@@ -131,6 +135,7 @@ module Truemail
131
135
  def regex_by_method(method)
132
136
  return Truemail::RegexConstant::REGEX_IP_ADDRESS_PATTERN if method.eql?(:blacklisted_mx_ip_addresses)
133
137
  return Truemail::RegexConstant::REGEX_DNS_SERVER_ADDRESS_PATTERN if method.eql?(:dns)
138
+ return Truemail::RegexConstant::REGEX_SIMPLE_EMAIL_PATTERN if method[/email/]
134
139
  Truemail::RegexConstant::REGEX_DOMAIN_PATTERN
135
140
  end
136
141
 
data/lib/truemail/core.rb CHANGED
@@ -20,6 +20,7 @@ module Truemail
20
20
 
21
21
  module RegexConstant
22
22
  REGEX_DOMAIN = /[\p{L}0-9]+([\-.]{1}[\p{L}0-9]+)*\.\p{L}{2,63}/i.freeze
23
+ REGEX_SIMPLE_EMAIL_PATTERN = /\w+@\w+/.freeze
23
24
  REGEX_EMAIL_PATTERN = %r{(?=\A.{6,255}\z)(\A([\p{L}0-9]+[\w\p{L}.+!~,'&%#*^`{}|\-/?=$]*)@(#{REGEX_DOMAIN})\z)}.freeze
24
25
  REGEX_DOMAIN_PATTERN = /(?=\A.{4,255}\z)(\A#{REGEX_DOMAIN}\z)/.freeze
25
26
  REGEX_DOMAIN_FROM_EMAIL = /\A.+@(.+)\z/.freeze
@@ -45,7 +46,7 @@ module Truemail
45
46
 
46
47
  module Validate
47
48
  require_relative '../truemail/validate/base'
48
- require_relative '../truemail/validate/domain_list_match'
49
+ require_relative '../truemail/validate/list_match'
49
50
  require_relative '../truemail/validate/regex'
50
51
  require_relative '../truemail/validate/mx'
51
52
  require_relative '../truemail/validate/mx_blacklist'
@@ -8,6 +8,8 @@ module Truemail
8
8
 
9
9
  CONFIGURATION_ARRAY_ATTRS = %i[
10
10
  validation_type_by_domain
11
+ whitelisted_emails
12
+ blacklisted_emails
11
13
  whitelisted_domains
12
14
  blacklisted_domains
13
15
  blacklisted_mx_ip_addresses
@@ -61,6 +63,8 @@ module Truemail
61
63
  {
62
64
  validation_type_by_domain: validation_type_by_domain,
63
65
  whitelist_validation: executor_configuration.whitelist_validation,
66
+ whitelisted_emails: whitelisted_emails,
67
+ blacklisted_emails: blacklisted_emails,
64
68
  whitelisted_domains: whitelisted_domains,
65
69
  blacklisted_domains: blacklisted_domains,
66
70
  blacklisted_mx_ip_addresses: blacklisted_mx_ip_addresses,
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Truemail
4
+ module Validate
5
+ class ListMatch < Truemail::Validate::Base
6
+ ERROR = 'blacklisted email'
7
+
8
+ def run
9
+ return success(true) if whitelisted? && !whitelist_validation?
10
+ return unless whitelist_validation_case? || blacklisted?
11
+ success(false)
12
+ add_error(Truemail::Validate::ListMatch::ERROR)
13
+ end
14
+
15
+ private
16
+
17
+ def email
18
+ @email ||= result.email
19
+ end
20
+
21
+ def email_domain
22
+ @email_domain ||=
23
+ result.domain = email[Truemail::RegexConstant::REGEX_DOMAIN_FROM_EMAIL, 1]
24
+ end
25
+
26
+ def whitelisted?
27
+ configuration.whitelisted_emails.include?(email) ||
28
+ configuration.whitelisted_domains.include?(email_domain)
29
+ end
30
+
31
+ def whitelist_validation?
32
+ configuration.whitelist_validation
33
+ end
34
+
35
+ def whitelist_validation_case?
36
+ whitelist_validation? && !whitelisted?
37
+ end
38
+
39
+ def blacklisted?
40
+ configuration.blacklisted_emails.include?(email) ||
41
+ configuration.blacklisted_domains.include?(email_domain)
42
+ end
43
+ end
44
+ end
45
+ end
@@ -26,7 +26,7 @@ module Truemail
26
26
  end
27
27
 
28
28
  def run
29
- Truemail::Validate::DomainListMatch.check(result)
29
+ Truemail::Validate::ListMatch.check(result)
30
30
  result_not_changed? ? Truemail::Validate.const_get(constantize(validation_type)).check(result) : update_validation_type
31
31
  logger&.push(self)
32
32
  self
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Truemail
4
- VERSION = '2.7.5'
4
+ VERSION = '3.0.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: truemail
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.5
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vladislav Trotsenko
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-10-10 00:00:00.000000000 Z
11
+ date: 2022-10-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: simpleidn
@@ -216,7 +216,7 @@ files:
216
216
  - lib/truemail/log/serializer/validator_text.rb
217
217
  - lib/truemail/logger.rb
218
218
  - lib/truemail/validate/base.rb
219
- - lib/truemail/validate/domain_list_match.rb
219
+ - lib/truemail/validate/list_match.rb
220
220
  - lib/truemail/validate/mx.rb
221
221
  - lib/truemail/validate/mx_blacklist.rb
222
222
  - lib/truemail/validate/regex.rb
@@ -1,39 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Truemail
4
- module Validate
5
- class DomainListMatch < Truemail::Validate::Base
6
- ERROR = 'blacklisted email'
7
-
8
- def run
9
- return success(true) if whitelisted_domain? && !whitelist_validation?
10
- return unless whitelist_validation_case? || blacklisted_domain?
11
- success(false)
12
- add_error(Truemail::Validate::DomainListMatch::ERROR)
13
- end
14
-
15
- private
16
-
17
- def email_domain
18
- @email_domain ||=
19
- result.domain = result.email[Truemail::RegexConstant::REGEX_DOMAIN_FROM_EMAIL, 1]
20
- end
21
-
22
- def whitelisted_domain?
23
- configuration.whitelisted_domains.include?(email_domain)
24
- end
25
-
26
- def whitelist_validation?
27
- configuration.whitelist_validation
28
- end
29
-
30
- def whitelist_validation_case?
31
- whitelist_validation? && !whitelisted_domain?
32
- end
33
-
34
- def blacklisted_domain?
35
- configuration.blacklisted_domains.include?(email_domain)
36
- end
37
- end
38
- end
39
- end