lite-validators 1.1.1 → 1.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.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +6 -1
  3. data/CHANGELOG.md +16 -0
  4. data/Gemfile.lock +71 -67
  5. data/docs/NAME.md +1 -1
  6. data/lib/lite/validators.rb +2 -2
  7. data/lib/lite/validators/alpha_validator.rb +1 -1
  8. data/lib/lite/validators/base64_validator.rb +1 -3
  9. data/lib/lite/validators/boolean_validator.rb +1 -1
  10. data/lib/lite/validators/compare_validator.rb +1 -1
  11. data/lib/lite/validators/coordinate_validator.rb +1 -1
  12. data/lib/lite/validators/credit_card_validator.rb +1 -1
  13. data/lib/lite/validators/csv_validator.rb +1 -1
  14. data/lib/lite/validators/currency_validator.rb +1 -1
  15. data/lib/lite/validators/cusip_validator.rb +1 -1
  16. data/lib/lite/validators/ein_validator.rb +1 -1
  17. data/lib/lite/validators/email_validator.rb +2 -2
  18. data/lib/lite/validators/file_size_validator.rb +1 -1
  19. data/lib/lite/validators/hex_validator.rb +1 -1
  20. data/lib/lite/validators/imei_validator.rb +1 -1
  21. data/lib/lite/validators/ip_address_validator.rb +1 -1
  22. data/lib/lite/validators/isbn_validator.rb +1 -1
  23. data/lib/lite/validators/isin_validator.rb +1 -1
  24. data/{config → lib/lite/validators}/locales/en.yml +0 -0
  25. data/lib/lite/validators/mac_address_validator.rb +1 -1
  26. data/lib/lite/validators/name_validator.rb +1 -1
  27. data/lib/lite/validators/password_validator.rb +1 -1
  28. data/lib/lite/validators/phone_number_validator.rb +1 -1
  29. data/lib/lite/validators/railtie.rb +8 -10
  30. data/lib/lite/validators/sedol_validator.rb +2 -2
  31. data/lib/lite/validators/slug_validator.rb +1 -1
  32. data/lib/lite/validators/ssn_validator.rb +1 -1
  33. data/lib/lite/validators/url_validator.rb +1 -1
  34. data/lib/lite/validators/username_validator.rb +1 -1
  35. data/lib/lite/validators/uuid_validator.rb +1 -1
  36. data/lib/lite/validators/version.rb +1 -1
  37. data/lite-validators.gemspec +2 -1
  38. metadata +18 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1be3cd4946e7ee9b2cd3f5990eb9fd3198bb259f6a445f9210d1ad6a6b1faaa3
4
- data.tar.gz: d001d6846a211a1c012728bc079fdd8c826f084d10b7615f65a356a7f9bf73bd
3
+ metadata.gz: a90c7a1e51d3e078c5cf5e36cdf44b251c187c002af41c5f76a9a83674a6a3bd
4
+ data.tar.gz: dce78538eeddaeb62a4d78c9e81572418aab767e57861deacaad758272c702dc
5
5
  SHA512:
6
- metadata.gz: de257879224b9b795f092e274343b3144f313bbdd78ea35eb5137b8158a2cae711f61156179d10cc597932db348897346ca8bf5238ca973bc6dbcce9d11577ac
7
- data.tar.gz: 36ed0841dca53ee8570afdcdd76e12d793b8a9e797a06b73379307978294ae4a0ff3a5f292fa52d5f73fe9ddb14254a1289236f23d669e9b08bf8c777ea43936
6
+ metadata.gz: 37ea1dd1ac042173502ea911c11d3eb56ffe597f988da8cbd03399823c484b5af729e8216f27918f9b390656ef2537dc9c53ef9122b840ac670f79d0066fab97
7
+ data.tar.gz: 8989d9ae3268a43769ac5aacea226da3b4617a46e060bc708dab898d74b091106fb35a54c20acbaf057d279b893415a3073851bbd9832967919531297451773d
data/.rubocop.yml CHANGED
@@ -1,8 +1,9 @@
1
1
  require:
2
2
  - rubocop-performance
3
+ - rubocop-rake
3
4
  - rubocop-rspec
4
5
  AllCops:
5
- TargetRubyVersion: 2.7
6
+ TargetRubyVersion: 3.0
6
7
  NewCops: enable
7
8
  DisplayCopNames: true
8
9
  DisplayStyleGuide: true
@@ -23,6 +24,8 @@ Layout/SpaceAroundMethodCallOperator:
23
24
  Enabled: true
24
25
  Lint/ConstantDefinitionInBlock:
25
26
  Enabled: false
27
+ Lint/EmptyClass:
28
+ Enabled: false
26
29
  Lint/RaiseException:
27
30
  Enabled: true
28
31
  Lint/StructNewOverride:
@@ -40,6 +43,8 @@ RSpec/LeakyConstantDeclaration:
40
43
  Enabled: false
41
44
  RSpec/MultipleExpectations:
42
45
  Enabled: false
46
+ Style/ArgumentsForwarding:
47
+ Enabled: false
43
48
  Style/Documentation:
44
49
  Enabled: false
45
50
  Style/ExpandPathArguments:
data/CHANGELOG.md CHANGED
@@ -6,6 +6,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [1.3.1] - 2021-07-21
10
+ ### Changed
11
+ - Improved Railtie support
12
+
13
+ ## [1.3.0] - 2021-07-19
14
+ ### Added
15
+ - Added Ruby 3.0 support
16
+
17
+ ## [1.2.0] - 2021-07-13
18
+ ### Updated
19
+ - Update name validator to accept numeric values and remove double quotes
20
+
21
+ ## [1.1.2] - 2021-07-05
22
+ ### Updated
23
+ - Improve array build performance
24
+
9
25
  ## [1.1.1] - 2020-06-06
10
26
  ### Updated
11
27
  - Improve mac address regex
data/Gemfile.lock CHANGED
@@ -1,56 +1,58 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lite-validators (1.1.1)
4
+ lite-validators (1.3.1)
5
5
  activemodel
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- actionpack (6.0.3.4)
11
- actionview (= 6.0.3.4)
12
- activesupport (= 6.0.3.4)
13
- rack (~> 2.0, >= 2.0.8)
10
+ actionpack (6.1.4)
11
+ actionview (= 6.1.4)
12
+ activesupport (= 6.1.4)
13
+ rack (~> 2.0, >= 2.0.9)
14
14
  rack-test (>= 0.6.3)
15
15
  rails-dom-testing (~> 2.0)
16
16
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
17
- actionview (6.0.3.4)
18
- activesupport (= 6.0.3.4)
17
+ actionview (6.1.4)
18
+ activesupport (= 6.1.4)
19
19
  builder (~> 3.1)
20
20
  erubi (~> 1.4)
21
21
  rails-dom-testing (~> 2.0)
22
22
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
23
- activemodel (6.0.3.4)
24
- activesupport (= 6.0.3.4)
25
- activesupport (6.0.3.4)
23
+ activemodel (6.1.4)
24
+ activesupport (= 6.1.4)
25
+ activesupport (6.1.4)
26
26
  concurrent-ruby (~> 1.0, >= 1.0.2)
27
- i18n (>= 0.7, < 2)
28
- minitest (~> 5.1)
29
- tzinfo (~> 1.1)
30
- zeitwerk (~> 2.2, >= 2.2.2)
31
- ast (2.4.1)
27
+ i18n (>= 1.6, < 2)
28
+ minitest (>= 5.1)
29
+ tzinfo (~> 2.0)
30
+ zeitwerk (~> 2.3)
31
+ ast (2.4.2)
32
32
  builder (3.2.4)
33
33
  colorize (0.8.1)
34
- concurrent-ruby (1.1.7)
34
+ concurrent-ruby (1.1.9)
35
35
  crass (1.0.6)
36
36
  diff-lcs (1.4.4)
37
- erubi (1.9.0)
38
- fasterer (0.8.3)
37
+ erubi (1.10.0)
38
+ fasterer (0.9.0)
39
39
  colorize (~> 0.7)
40
40
  ruby_parser (>= 3.14.1)
41
- i18n (1.8.5)
41
+ i18n (1.8.10)
42
42
  concurrent-ruby (~> 1.0)
43
- loofah (2.7.0)
43
+ loofah (2.10.0)
44
44
  crass (~> 1.0.2)
45
45
  nokogiri (>= 1.5.9)
46
46
  method_source (1.0.0)
47
- mini_portile2 (2.4.0)
48
- minitest (5.14.2)
49
- nokogiri (1.10.10)
50
- mini_portile2 (~> 2.4.0)
51
- parallel (1.19.2)
52
- parser (2.7.2.0)
47
+ mini_portile2 (2.5.3)
48
+ minitest (5.14.4)
49
+ nokogiri (1.11.7)
50
+ mini_portile2 (~> 2.5.0)
51
+ racc (~> 1.4)
52
+ parallel (1.20.1)
53
+ parser (3.0.2.0)
53
54
  ast (~> 2.4.1)
55
+ racc (1.5.2)
54
56
  rack (2.2.3)
55
57
  rack-test (1.1.0)
56
58
  rack (>= 1.0, < 3)
@@ -59,64 +61,65 @@ GEM
59
61
  nokogiri (>= 1.6)
60
62
  rails-html-sanitizer (1.3.0)
61
63
  loofah (~> 2.3)
62
- railties (6.0.3.4)
63
- actionpack (= 6.0.3.4)
64
- activesupport (= 6.0.3.4)
64
+ railties (6.1.4)
65
+ actionpack (= 6.1.4)
66
+ activesupport (= 6.1.4)
65
67
  method_source
66
- rake (>= 0.8.7)
67
- thor (>= 0.20.3, < 2.0)
68
+ rake (>= 0.13)
69
+ thor (~> 1.0)
68
70
  rainbow (3.0.0)
69
- rake (13.0.1)
70
- regexp_parser (1.8.2)
71
- rexml (3.2.4)
71
+ rake (13.0.6)
72
+ regexp_parser (2.1.1)
73
+ rexml (3.2.5)
72
74
  rspec (3.10.0)
73
75
  rspec-core (~> 3.10.0)
74
76
  rspec-expectations (~> 3.10.0)
75
77
  rspec-mocks (~> 3.10.0)
76
- rspec-core (3.10.0)
78
+ rspec-core (3.10.1)
77
79
  rspec-support (~> 3.10.0)
78
- rspec-expectations (3.10.0)
80
+ rspec-expectations (3.10.1)
79
81
  diff-lcs (>= 1.2.0, < 2.0)
80
82
  rspec-support (~> 3.10.0)
81
- rspec-mocks (3.10.0)
83
+ rspec-mocks (3.10.2)
82
84
  diff-lcs (>= 1.2.0, < 2.0)
83
85
  rspec-support (~> 3.10.0)
84
- rspec-rails (4.0.1)
85
- actionpack (>= 4.2)
86
- activesupport (>= 4.2)
87
- railties (>= 4.2)
88
- rspec-core (~> 3.9)
89
- rspec-expectations (~> 3.9)
90
- rspec-mocks (~> 3.9)
91
- rspec-support (~> 3.9)
92
- rspec-support (3.10.0)
93
- rubocop (1.2.0)
86
+ rspec-rails (5.0.1)
87
+ actionpack (>= 5.2)
88
+ activesupport (>= 5.2)
89
+ railties (>= 5.2)
90
+ rspec-core (~> 3.10)
91
+ rspec-expectations (~> 3.10)
92
+ rspec-mocks (~> 3.10)
93
+ rspec-support (~> 3.10)
94
+ rspec-support (3.10.2)
95
+ rubocop (1.18.3)
94
96
  parallel (~> 1.10)
95
- parser (>= 2.7.1.5)
97
+ parser (>= 3.0.0.0)
96
98
  rainbow (>= 2.2.2, < 4.0)
97
- regexp_parser (>= 1.8)
99
+ regexp_parser (>= 1.8, < 3.0)
98
100
  rexml
99
- rubocop-ast (>= 1.0.1)
101
+ rubocop-ast (>= 1.7.0, < 2.0)
100
102
  ruby-progressbar (~> 1.7)
101
- unicode-display_width (>= 1.4.0, < 2.0)
102
- rubocop-ast (1.1.1)
103
- parser (>= 2.7.1.5)
104
- rubocop-performance (1.8.1)
105
- rubocop (>= 0.87.0)
103
+ unicode-display_width (>= 1.4.0, < 3.0)
104
+ rubocop-ast (1.8.0)
105
+ parser (>= 3.0.1.1)
106
+ rubocop-performance (1.11.4)
107
+ rubocop (>= 1.7.0, < 2.0)
106
108
  rubocop-ast (>= 0.4.0)
107
- rubocop-rspec (2.0.0)
109
+ rubocop-rake (0.6.0)
110
+ rubocop (~> 1.0)
111
+ rubocop-rspec (2.4.0)
108
112
  rubocop (~> 1.0)
109
113
  rubocop-ast (>= 1.1.0)
110
- ruby-progressbar (1.10.1)
111
- ruby_parser (3.15.0)
112
- sexp_processor (~> 4.9)
113
- sexp_processor (4.15.1)
114
- thor (1.0.1)
115
- thread_safe (0.3.6)
116
- tzinfo (1.2.7)
117
- thread_safe (~> 0.1)
118
- unicode-display_width (1.7.0)
119
- zeitwerk (2.4.1)
114
+ ruby-progressbar (1.11.0)
115
+ ruby_parser (3.16.0)
116
+ sexp_processor (~> 4.15, >= 4.15.1)
117
+ sexp_processor (4.15.3)
118
+ thor (1.1.0)
119
+ tzinfo (2.0.4)
120
+ concurrent-ruby (~> 1.0)
121
+ unicode-display_width (2.0.0)
122
+ zeitwerk (2.4.2)
120
123
 
121
124
  PLATFORMS
122
125
  ruby
@@ -131,7 +134,8 @@ DEPENDENCIES
131
134
  rspec-rails
132
135
  rubocop
133
136
  rubocop-performance
137
+ rubocop-rake
134
138
  rubocop-rspec
135
139
 
136
140
  BUNDLED WITH
137
- 2.1.4
141
+ 2.2.24
data/docs/NAME.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  ```ruby
6
6
  # 1. Pattern
7
- /^([A-Za-z'"-]+\s+){1,4}[A-Za-z'"-]*\z/
7
+ /^([A-Za-z0-9'-]+\s+){1,4}[A-Za-z0-9'-]*\z/
8
8
  ```
9
9
 
10
10
  #### Usage
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'active_model'
3
+ require 'active_model' unless defined?(ActiveModel)
4
4
 
5
+ require 'lite/validators/railtie' if defined?(Rails::Railtie)
5
6
  require 'lite/validators/version'
6
- require 'lite/validators/railtie' if defined?(Rails)
7
7
 
8
8
  %w[
9
9
  base alpha alpha_numeric base64 boolean compare coordinate credit_card currency cusip email ein
@@ -2,7 +2,7 @@
2
2
 
3
3
  class AlphaValidator < BaseValidator
4
4
 
5
- CASES ||= {
5
+ CASES = {
6
6
  lower: 'a-z',
7
7
  upper: 'A-Z',
8
8
  any: 'A-Za-z'
@@ -2,8 +2,6 @@
2
2
 
3
3
  class Base64Validator < BaseValidator
4
4
 
5
- # rubocop:disable Layout/LineLength
6
- REGEXP ||= /^(?:[A-Za-z0-9+$]{4})*(?:[A-Za-z0-9+$]{2}==|[A-Za-z0-9+$]{3}=|[A-Za-z0-9+$]{4})$/.freeze
7
- # rubocop:enable Layout/LineLength
5
+ REGEXP = /^(?:[A-Za-z0-9+$]{4})*(?:[A-Za-z0-9+$]{2}==|[A-Za-z0-9+$]{3}=|[A-Za-z0-9+$]{4})$/
8
6
 
9
7
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  class BooleanValidator < BaseValidator
4
4
 
5
- CHECKS ||= {
5
+ CHECKS = {
6
6
  all: nil,
7
7
  false_only: %w[0 f false n no off],
8
8
  true_only: %w[1 t true y yes on]
@@ -2,7 +2,7 @@
2
2
 
3
3
  class CompareValidator < BaseValidator
4
4
 
5
- CHECKS ||= {
5
+ CHECKS = {
6
6
  less_than: :<,
7
7
  less_than_or_equal_to: :<=,
8
8
  greater_than: :>,
@@ -2,7 +2,7 @@
2
2
 
3
3
  class CoordinateValidator < BaseValidator
4
4
 
5
- BOUNDARIES ||= {
5
+ BOUNDARIES = {
6
6
  latitude: 90.0,
7
7
  longitude: 180.0
8
8
  }.freeze
@@ -4,7 +4,7 @@ class CreditCardValidator < BaseValidator
4
4
 
5
5
  # NOTE: https://en.wikipedia.org/wiki/Payment_card_value#Issuer_identification_value_.28IIN.29
6
6
 
7
- PROVIDERS ||= {
7
+ PROVIDERS = {
8
8
  american_express: {
9
9
  sizes: [15],
10
10
  prefixes: [34, 37]
@@ -4,7 +4,7 @@ require 'csv'
4
4
 
5
5
  class CsvValidator < FileSizeValidator
6
6
 
7
- DIMENSIONS ||= %i[
7
+ DIMENSIONS = %i[
8
8
  columns rows
9
9
  ].freeze
10
10
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  class CurrencyValidator < BaseValidator
4
4
 
5
- REGEXP ||= /^\d*+(\.\d{1,2})$/.freeze
5
+ REGEXP = /^\d*+(\.\d{1,2})$/
6
6
 
7
7
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  class CusipValidator < BaseValidator
4
4
 
5
- REGEXP ||= /^[0-9A-Z]{9}$/.freeze
5
+ REGEXP = /^[0-9A-Z]{9}$/
6
6
 
7
7
  private
8
8
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  class EinValidator < BaseValidator
4
4
 
5
- REGEXP ||= /^[1-9]\d?-\d{7}$/.freeze
5
+ REGEXP = /^[1-9]\d?-\d{7}$/
6
6
 
7
7
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  class EmailValidator < BaseValidator
4
4
 
5
- REGEXP ||= /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i.freeze
5
+ REGEXP = /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i
6
6
 
7
7
  private
8
8
 
@@ -13,7 +13,7 @@ class EmailValidator < BaseValidator
13
13
  def valid_domain?
14
14
  return true unless options.key?(:domain)
15
15
 
16
- [options[:domain]].flatten.any? { |domain| value.downcase.end_with?(".#{domain.downcase}") }
16
+ Array(options[:domain]).any? { |domain| value.downcase.end_with?(".#{domain.downcase}") }
17
17
  end
18
18
 
19
19
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  class FileSizeValidator < BaseValidator
4
4
 
5
- CHECKS ||= {
5
+ CHECKS = {
6
6
  in: :===,
7
7
  less_than: :<,
8
8
  less_than_or_equal_to: :<=,
@@ -2,6 +2,6 @@
2
2
 
3
3
  class HexValidator < BaseValidator
4
4
 
5
- REGEXP ||= /^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.freeze
5
+ REGEXP = /^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/
6
6
 
7
7
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  class ImeiValidator < BaseValidator
4
4
 
5
- REGEXP ||= /\A[\d.:\-\s]+\z/i.freeze
5
+ REGEXP = /\A[\d.:\-\s]+\z/i
6
6
 
7
7
  private
8
8
 
@@ -4,7 +4,7 @@ require 'resolv'
4
4
 
5
5
  class IpAddressValidator < BaseValidator
6
6
 
7
- REGEXP ||= {
7
+ REGEXP = {
8
8
  ipv4: Resolv::IPv4::Regex,
9
9
  ipv6: Resolv::IPv6::Regex
10
10
  }.freeze
@@ -2,7 +2,7 @@
2
2
 
3
3
  class IsbnValidator < BaseValidator
4
4
 
5
- CHARACTERS ||= %w[
5
+ CHARACTERS = %w[
6
6
  0 1 2 3 4 5 6 7 8 9 x
7
7
  ].freeze
8
8
 
@@ -3,7 +3,7 @@
3
3
  class IsinValidator < BaseValidator
4
4
 
5
5
  # rubocop:disable Layout/LineLength
6
- REGEXP ||= /^((AF|AX|AL|DZ|AS|AD|AO|AI|AQ|AG|AR|AM|AW|AU|AT|AZ|BS|BH|BD|BB|BY|BE|BZ|BJ|BM|BT|BO|BQ|BA|BW|BV|BR|IO|BN|BG|BF|BI|KH|CM|CA|CV|KY|CF|TD|CL|CN|CX|CC|CO|KM|CG|CD|CK|CR|CI|HR|CU|CW|CY|CZ|DK|DJ|DM|DO|EC|EG|SV|GQ|ER|EE|ET|FK|FO|FJ|FI|FR|GF|PF|TF|GA|GM|GE|DE|GH|GI|GR|GL|GD|GP|GU|GT|GG|GN|GW|GY|HT|HM|VA|HN|HK|HU|IS|IN|ID|IR|IQ|IE|IM|IL|IT|JM|JP|JE|JO|KZ|KE|KI|KP|KR|KW|KG|LA|LV|LB|LS|LR|LY|LI|LT|LU|MO|MK|MG|MW|MY|MV|ML|MT|MH|MQ|MR|MU|YT|MX|FM|MD|MC|MN|ME|MS|MA|MZ|MM|NA|NR|NP|NL|NC|NZ|NI|NE|NG|NU|NF|MP|NO|OM|PK|PW|PS|PA|PG|PY|PE|PH|PN|PL|PT|PR|QA|RE|RO|RU|RW|BL|SH|KN|LC|MF|PM|VC|WS|SM|ST|SA|SN|RS|SC|SL|SG|SX|SK|SI|SB|SO|ZA|GS|SS|ES|LK|SD|SR|SJ|SZ|SE|CH|SY|TW|TJ|TZ|TH|TL|TG|TK|TO|TT|TN|TR|TM|TC|TV|UG|UA|AE|GB|US|UM|UY|UZ|VU|VE|VN|VG|VI|WF|EH|YE|ZM|ZW{2})([A-Z0-9]{9}))(\d{1})$/.freeze
6
+ REGEXP = /^((AF|AX|AL|DZ|AS|AD|AO|AI|AQ|AG|AR|AM|AW|AU|AT|AZ|BS|BH|BD|BB|BY|BE|BZ|BJ|BM|BT|BO|BQ|BA|BW|BV|BR|IO|BN|BG|BF|BI|KH|CM|CA|CV|KY|CF|TD|CL|CN|CX|CC|CO|KM|CG|CD|CK|CR|CI|HR|CU|CW|CY|CZ|DK|DJ|DM|DO|EC|EG|SV|GQ|ER|EE|ET|FK|FO|FJ|FI|FR|GF|PF|TF|GA|GM|GE|DE|GH|GI|GR|GL|GD|GP|GU|GT|GG|GN|GW|GY|HT|HM|VA|HN|HK|HU|IS|IN|ID|IR|IQ|IE|IM|IL|IT|JM|JP|JE|JO|KZ|KE|KI|KP|KR|KW|KG|LA|LV|LB|LS|LR|LY|LI|LT|LU|MO|MK|MG|MW|MY|MV|ML|MT|MH|MQ|MR|MU|YT|MX|FM|MD|MC|MN|ME|MS|MA|MZ|MM|NA|NR|NP|NL|NC|NZ|NI|NE|NG|NU|NF|MP|NO|OM|PK|PW|PS|PA|PG|PY|PE|PH|PN|PL|PT|PR|QA|RE|RO|RU|RW|BL|SH|KN|LC|MF|PM|VC|WS|SM|ST|SA|SN|RS|SC|SL|SG|SX|SK|SI|SB|SO|ZA|GS|SS|ES|LK|SD|SR|SJ|SZ|SE|CH|SY|TW|TJ|TZ|TH|TL|TG|TK|TO|TT|TN|TR|TM|TC|TV|UG|UA|AE|GB|US|UM|UY|UZ|VU|VE|VN|VG|VI|WF|EH|YE|ZM|ZW{2})([A-Z0-9]{9}))(\d{1})$/
7
7
  # rubocop:enable Layout/LineLength
8
8
 
9
9
  private
File without changes
@@ -2,7 +2,7 @@
2
2
 
3
3
  class MacAddressValidator < BaseValidator
4
4
 
5
- REGEXP ||= [
5
+ REGEXP = [
6
6
  /^(\h{2}[-|.:\s]){5}\h{2}?$/i,
7
7
  /^(\h{4}[-|.:\s]){2}\h{4}?$/i,
8
8
  /^(\h{6}[-|.:\s])\h{6}?$/i,
@@ -2,6 +2,6 @@
2
2
 
3
3
  class NameValidator < BaseValidator
4
4
 
5
- REGEXP ||= /^([A-Za-z'"-]+\s+){1,4}[A-Za-z'"-]*\z/.freeze
5
+ REGEXP = /^([A-Za-z0-9'-]+\s+){1,4}[A-Za-z0-9'-]*\z/
6
6
 
7
7
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  class PasswordValidator < BaseValidator
4
4
 
5
- REGEXP ||= {
5
+ REGEXP = {
6
6
  strong: /\A(?=.{4,255})(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[[:^alnum:]])/x,
7
7
  weak: /^[A-Za-z0-9.,<>:;!@#$%^&*?_~-]{1,255}$/
8
8
  }.freeze
@@ -2,6 +2,6 @@
2
2
 
3
3
  class PhoneNumberValidator < BaseValidator
4
4
 
5
- REGEXP ||= %r{^[0-9+()#.\s/ext-]+$}.freeze
5
+ REGEXP = %r{^[0-9+()#.\s/ext-]+$}
6
6
 
7
7
  end
@@ -1,20 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'rails/railtie'
4
-
5
3
  module Lite
6
4
  module Validators
7
- class Railtie < ::Rails::Railtie
5
+ class Railtie < Rails::Railtie
8
6
 
9
- initializer 'lite-validators' do |app|
10
- Lite::Validators::Railtie.instance_eval do
11
- [app.config.i18n.available_locales].flatten.each do |locale|
12
- path = File.expand_path("../../../config/locales/#{locale}.yml", __FILE__)
13
- next if !File.file?(path) || I18n.load_path.include?(path)
7
+ initializer 'lite-validators.configure_locales' do |app|
8
+ Array(app.config.i18n.available_locales).each do |locale|
9
+ path = File.expand_path("../locales/#{locale}.yml", __FILE__)
10
+ next unless File.file?(path)
14
11
 
15
- I18n.load_path << path
16
- end
12
+ I18n.load_path << path
17
13
  end
14
+
15
+ I18n.reload!
18
16
  end
19
17
 
20
18
  end
@@ -2,8 +2,8 @@
2
2
 
3
3
  class SedolValidator < BaseValidator
4
4
 
5
- REGEXP ||= /^([A-Z0-9]{6})(\d{1})$/.freeze
6
- WEIGHTS ||= [
5
+ REGEXP = /^([A-Z0-9]{6})(\d{1})$/
6
+ WEIGHTS = [
7
7
  1, 3, 1, 7, 3, 9, 1
8
8
  ].freeze
9
9
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  class SlugValidator < BaseValidator
4
4
 
5
- REGEXP ||= /^[A-Za-z0-9_-]+$/i.freeze
5
+ REGEXP = /^[A-Za-z0-9_-]+$/i
6
6
 
7
7
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  class SsnValidator < BaseValidator
4
4
 
5
- REGEXP ||= /^\A(\d{3}-\d{2}-\d{4}|\d{9})\Z$/.freeze
5
+ REGEXP = /^\A(\d{3}-\d{2}-\d{4}|\d{9})\Z$/
6
6
 
7
7
  end
@@ -4,7 +4,7 @@ require 'uri'
4
4
 
5
5
  class UrlValidator < BaseValidator
6
6
 
7
- SCHEMES ||= %w[
7
+ SCHEMES = %w[
8
8
  http https
9
9
  ].freeze
10
10
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  class UsernameValidator < BaseValidator
4
4
 
5
- REGEXP ||= /^[A-Za-z0-9._-]{1,255}$/.freeze
5
+ REGEXP = /^[A-Za-z0-9._-]{1,255}$/
6
6
 
7
7
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  class UuidValidator < BaseValidator
4
4
 
5
- VERSIONS ||= {
5
+ VERSIONS = {
6
6
  any: /^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i,
7
7
  3 => /^[0-9A-F]{8}-[0-9A-F]{4}-3[0-9A-F]{3}-[0-9A-F]{4}-[0-9A-F]{12}$/i,
8
8
  4 => /^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,
@@ -3,7 +3,7 @@
3
3
  module Lite
4
4
  module Validators
5
5
 
6
- VERSION ||= '1.1.1'
6
+ VERSION = '1.3.1'
7
7
 
8
8
  end
9
9
  end
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
25
25
  )
26
26
  else
27
27
  raise 'RubyGems 2.0 or newer is required to protect against ' \
28
- 'public gem pushes.'
28
+ 'public gem pushes.'
29
29
  end
30
30
 
31
31
  # Specify which files should be added to the gem when it is released.
@@ -47,5 +47,6 @@ Gem::Specification.new do |spec|
47
47
  spec.add_development_dependency 'rspec-rails'
48
48
  spec.add_development_dependency 'rubocop'
49
49
  spec.add_development_dependency 'rubocop-performance'
50
+ spec.add_development_dependency 'rubocop-rake'
50
51
  spec.add_development_dependency 'rubocop-rspec'
51
52
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lite-validators
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Gomez
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-11-07 00:00:00.000000000 Z
11
+ date: 2021-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -136,6 +136,20 @@ dependencies:
136
136
  - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: rubocop-rake
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
139
153
  - !ruby/object:Gem::Dependency
140
154
  name: rubocop-rspec
141
155
  requirement: !ruby/object:Gem::Requirement
@@ -172,7 +186,6 @@ files:
172
186
  - _config.yml
173
187
  - bin/console
174
188
  - bin/setup
175
- - config/locales/en.yml
176
189
  - docs/ALPHA.md
177
190
  - docs/ALPHA_NUMERIC.md
178
191
  - docs/BASE64.md
@@ -226,6 +239,7 @@ files:
226
239
  - lib/lite/validators/ip_address_validator.rb
227
240
  - lib/lite/validators/isbn_validator.rb
228
241
  - lib/lite/validators/isin_validator.rb
242
+ - lib/lite/validators/locales/en.yml
229
243
  - lib/lite/validators/mac_address_validator.rb
230
244
  - lib/lite/validators/name_validator.rb
231
245
  - lib/lite/validators/password_validator.rb
@@ -260,7 +274,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
260
274
  - !ruby/object:Gem::Version
261
275
  version: '0'
262
276
  requirements: []
263
- rubygems_version: 3.1.4
277
+ rubygems_version: 3.2.24
264
278
  signing_key:
265
279
  specification_version: 4
266
280
  summary: Collection of ActiveModel/ActiveRecord validators