lite-validators 1.1.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +8 -1
  3. data/CHANGELOG.md +16 -0
  4. data/Gemfile.lock +81 -75
  5. data/docs/ALPHA.md +3 -3
  6. data/docs/ALPHA_NUMERIC.md +3 -3
  7. data/docs/BASE64.md +1 -1
  8. data/docs/BOOLEAN.md +2 -2
  9. data/docs/COMPARE.md +1 -1
  10. data/docs/COORDINATE.md +2 -2
  11. data/docs/CREDIT_CARD.md +2 -2
  12. data/docs/CSV.md +3 -3
  13. data/docs/CURRENCY.md +1 -1
  14. data/docs/CUSIP.md +1 -1
  15. data/docs/EMAIL.md +3 -3
  16. data/docs/FILE_CONTENT_TYPE.md +3 -3
  17. data/docs/FILE_EXTENSION.md +2 -2
  18. data/docs/FILE_SIZE.md +3 -3
  19. data/docs/HEX.md +1 -1
  20. data/docs/IMEI.md +1 -1
  21. data/docs/IP_ADDRESS.md +2 -2
  22. data/docs/ISBN.md +1 -1
  23. data/docs/ISIN.md +1 -1
  24. data/docs/MAC_ADDRESS.md +1 -1
  25. data/docs/NAME.md +2 -2
  26. data/docs/PASSWORD.md +2 -2
  27. data/docs/PHONE_NUMBER.md +1 -1
  28. data/docs/SEDOL.md +1 -1
  29. data/docs/SLUG.md +1 -1
  30. data/docs/SSN.md +1 -1
  31. data/docs/TIME_ZONE.md +1 -1
  32. data/docs/TYPE.md +5 -5
  33. data/docs/URL.md +4 -4
  34. data/docs/USERNAME.md +1 -1
  35. data/docs/UUID.md +2 -2
  36. data/lib/lite/validators/alpha_validator.rb +1 -1
  37. data/lib/lite/validators/base64_validator.rb +1 -3
  38. data/lib/lite/validators/boolean_validator.rb +1 -1
  39. data/lib/lite/validators/compare_validator.rb +1 -1
  40. data/lib/lite/validators/coordinate_validator.rb +1 -1
  41. data/lib/lite/validators/credit_card_validator.rb +1 -1
  42. data/lib/lite/validators/csv_validator.rb +1 -1
  43. data/lib/lite/validators/currency_validator.rb +1 -1
  44. data/lib/lite/validators/cusip_validator.rb +1 -1
  45. data/lib/lite/validators/ein_validator.rb +1 -1
  46. data/lib/lite/validators/email_validator.rb +2 -2
  47. data/lib/lite/validators/file_size_validator.rb +1 -1
  48. data/lib/lite/validators/hex_validator.rb +1 -1
  49. data/lib/lite/validators/imei_validator.rb +1 -1
  50. data/lib/lite/validators/ip_address_validator.rb +1 -1
  51. data/lib/lite/validators/isbn_validator.rb +1 -1
  52. data/lib/lite/validators/isin_validator.rb +2 -2
  53. data/lib/lite/validators/mac_address_validator.rb +4 -4
  54. data/lib/lite/validators/name_validator.rb +1 -1
  55. data/lib/lite/validators/password_validator.rb +1 -1
  56. data/lib/lite/validators/phone_number_validator.rb +1 -1
  57. data/lib/lite/validators/railtie.rb +1 -1
  58. data/lib/lite/validators/sedol_validator.rb +2 -2
  59. data/lib/lite/validators/slug_validator.rb +1 -1
  60. data/lib/lite/validators/ssn_validator.rb +1 -1
  61. data/lib/lite/validators/url_validator.rb +1 -1
  62. data/lib/lite/validators/username_validator.rb +1 -1
  63. data/lib/lite/validators/uuid_validator.rb +1 -1
  64. data/lib/lite/validators/version.rb +1 -1
  65. data/lite-validators.gemspec +2 -1
  66. metadata +17 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 54bec919570a21f28c087f804b4d60b6a80483a7b95d333f6cae0345f78cba8b
4
- data.tar.gz: 7ca9aa17a309d52c62d6a63c83dd9236f6c6c2697548df1c29037a321f589f80
3
+ metadata.gz: fa69377873f2ee0d6ef14558b29db5fc92da777468505e75414b49d60a7b64b0
4
+ data.tar.gz: 455b5668ab8b970df14d560bdf2a3bf1ce2c816e05437007e043c75ea4623878
5
5
  SHA512:
6
- metadata.gz: 7957705bf86716d717ed2ab8d00d9a620f2813b31273160a1d8e6085e06cfa4fb3885f2b8b4f2773e8c4a3df9daf8a229ad49a221efbff46615ed2cbcd25cdfa
7
- data.tar.gz: 0cc83bed5b93b76c69c30c1e7cbbaad8561004dcefee2d29fed07ca90543dcfb1d557885467ce68d2bc4f76adcb1a2e1173cc8a0a6addef293269f307e7006fb
6
+ metadata.gz: b8929cf7229fb4e634de7b436227c0b034ee63eecb03567466fa523f7456b714b478f7ad7393edd8c295df3d3eecde246e35214f9145c140ab01e1bdfe6fa900
7
+ data.tar.gz: 035152f46aa9d2d9125e9dbf3b305bfcf6a15977c2f1b049d785dc489ed9ea4c54e2e1baeaa85ea14fca12eeb187828c2810fd5366fb35bf9d413c5461f16a1f
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
@@ -21,6 +22,10 @@ Layout/LineLength:
21
22
  Max: 100
22
23
  Layout/SpaceAroundMethodCallOperator:
23
24
  Enabled: true
25
+ Lint/ConstantDefinitionInBlock:
26
+ Enabled: false
27
+ Lint/EmptyClass:
28
+ Enabled: false
24
29
  Lint/RaiseException:
25
30
  Enabled: true
26
31
  Lint/StructNewOverride:
@@ -38,6 +43,8 @@ RSpec/LeakyConstantDeclaration:
38
43
  Enabled: false
39
44
  RSpec/MultipleExpectations:
40
45
  Enabled: false
46
+ Style/ArgumentsForwarding:
47
+ Enabled: false
41
48
  Style/Documentation:
42
49
  Enabled: false
43
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.0] - 2021-07-19
10
+ ### Added
11
+ - Added Ruby 3.0 support
12
+
13
+ ## [1.2.0] - 2021-07-13
14
+ ### Updated
15
+ - Update name validator to accept numeric values and remove double quotes
16
+
17
+ ## [1.1.2] - 2021-07-05
18
+ ### Updated
19
+ - Improve array build performance
20
+
21
+ ## [1.1.1] - 2020-06-06
22
+ ### Updated
23
+ - Improve mac address regex
24
+
9
25
  ## [1.1.0] - 2020-09-04
10
26
  ### Updated
11
27
  - Updated username regex
data/Gemfile.lock CHANGED
@@ -1,56 +1,58 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lite-validators (1.1.0)
4
+ lite-validators (1.3.0)
5
5
  activemodel
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- actionpack (6.0.3.2)
11
- actionview (= 6.0.3.2)
12
- activesupport (= 6.0.3.2)
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.2)
18
- activesupport (= 6.0.3.2)
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.2)
24
- activesupport (= 6.0.3.2)
25
- activesupport (6.0.3.2)
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.1.4)
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,62 +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.2)
63
- actionpack (= 6.0.3.2)
64
- activesupport (= 6.0.3.2)
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.7.1)
71
- rexml (3.2.4)
72
- rspec (3.9.0)
73
- rspec-core (~> 3.9.0)
74
- rspec-expectations (~> 3.9.0)
75
- rspec-mocks (~> 3.9.0)
76
- rspec-core (3.9.2)
77
- rspec-support (~> 3.9.3)
78
- rspec-expectations (3.9.2)
71
+ rake (13.0.6)
72
+ regexp_parser (2.1.1)
73
+ rexml (3.2.5)
74
+ rspec (3.10.0)
75
+ rspec-core (~> 3.10.0)
76
+ rspec-expectations (~> 3.10.0)
77
+ rspec-mocks (~> 3.10.0)
78
+ rspec-core (3.10.1)
79
+ rspec-support (~> 3.10.0)
80
+ rspec-expectations (3.10.1)
79
81
  diff-lcs (>= 1.2.0, < 2.0)
80
- rspec-support (~> 3.9.0)
81
- rspec-mocks (3.9.1)
82
+ rspec-support (~> 3.10.0)
83
+ rspec-mocks (3.10.2)
82
84
  diff-lcs (>= 1.2.0, < 2.0)
83
- rspec-support (~> 3.9.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.9.3)
93
- rubocop (0.90.0)
85
+ rspec-support (~> 3.10.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.1)
97
+ parser (>= 3.0.0.0)
96
98
  rainbow (>= 2.2.2, < 4.0)
97
- regexp_parser (>= 1.7)
99
+ regexp_parser (>= 1.8, < 3.0)
98
100
  rexml
99
- rubocop-ast (>= 0.3.0, < 1.0)
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 (0.3.0)
103
- parser (>= 2.7.1.4)
104
- rubocop-performance (1.8.0)
105
- rubocop (>= 0.87.0)
106
- rubocop-rspec (1.43.2)
107
- rubocop (~> 0.87)
108
- ruby-progressbar (1.10.1)
109
- ruby_parser (3.15.0)
110
- sexp_processor (~> 4.9)
111
- sexp_processor (4.15.1)
112
- thor (1.0.1)
113
- thread_safe (0.3.6)
114
- tzinfo (1.2.7)
115
- thread_safe (~> 0.1)
116
- unicode-display_width (1.7.0)
117
- zeitwerk (2.4.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)
108
+ rubocop-ast (>= 0.4.0)
109
+ rubocop-rake (0.6.0)
110
+ rubocop (~> 1.0)
111
+ rubocop-rspec (2.4.0)
112
+ rubocop (~> 1.0)
113
+ rubocop-ast (>= 1.1.0)
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)
118
123
 
119
124
  PLATFORMS
120
125
  ruby
@@ -129,7 +134,8 @@ DEPENDENCIES
129
134
  rspec-rails
130
135
  rubocop
131
136
  rubocop-performance
137
+ rubocop-rake
132
138
  rubocop-rspec
133
139
 
134
140
  BUNDLED WITH
135
- 2.1.4
141
+ 2.2.24
data/docs/ALPHA.md CHANGED
@@ -21,9 +21,9 @@ allow_space | boolean | true, false | false
21
21
  ```ruby
22
22
  class User < ActiveRecord::Base
23
23
 
24
- validates :input_0, alpha: true
25
- validates :input_1, alpha: { case: :lower }
26
- validates :input_2, alpha: { allow_space: true }
24
+ validates :input0, alpha: true
25
+ validates :input1, alpha: { case: :lower }
26
+ validates :input2, alpha: { allow_space: true }
27
27
 
28
28
  end
29
29
  ```
@@ -21,9 +21,9 @@ allow_space | boolean | true, false | false
21
21
  ```ruby
22
22
  class User < ActiveRecord::Base
23
23
 
24
- validates :input_0, alpha_numeric: true
25
- validates :input_1, alpha_numeric: { case: :lower }
26
- validates :input_2, alpha_numeric: { allow_space: true }
24
+ validates :input0, alpha_numeric: true
25
+ validates :input1, alpha_numeric: { case: :lower }
26
+ validates :input2, alpha_numeric: { allow_space: true }
27
27
 
28
28
  end
29
29
  ```
data/docs/BASE64.md CHANGED
@@ -12,7 +12,7 @@
12
12
  ```ruby
13
13
  class User < ActiveRecord::Base
14
14
 
15
- validates :input_0, base64: true
15
+ validates :input0, base64: true
16
16
 
17
17
  end
18
18
  ```
data/docs/BOOLEAN.md CHANGED
@@ -19,8 +19,8 @@ check | symbol | all, false_only, true_only | all
19
19
  ```ruby
20
20
  class User < ActiveRecord::Base
21
21
 
22
- validates :input_0, boolean: true
23
- validates :input_1, boolean: { check: :true_only }
22
+ validates :input0, boolean: true
23
+ validates :input1, boolean: { check: :true_only }
24
24
 
25
25
  end
26
26
  ```
data/docs/COMPARE.md CHANGED
@@ -24,7 +24,7 @@ to | symbol | |
24
24
  ```ruby
25
25
  class User < ActiveRecord::Base
26
26
 
27
- validates :input_0, equality: { to: :input_1, check: :less_than }
27
+ validates :input0, equality: { to: :input1, check: :less_than }
28
28
 
29
29
  end
30
30
  ```
data/docs/COORDINATE.md CHANGED
@@ -20,8 +20,8 @@ boundary | symbol | latitude, longitude, pair | pair
20
20
  ```ruby
21
21
  class User < ActiveRecord::Base
22
22
 
23
- validates :input_0, coordinate: true
24
- validates :input_1, coordinate: { boundary: :latitude }
23
+ validates :input0, coordinate: true
24
+ validates :input1, coordinate: { boundary: :latitude }
25
25
 
26
26
  end
27
27
  ```
data/docs/CREDIT_CARD.md CHANGED
@@ -22,8 +22,8 @@ provider | symbol | [view here](https://github.com/drexed/lite-validators/blob/m
22
22
  ```ruby
23
23
  class User < ActiveRecord::Base
24
24
 
25
- validates :input_0, credit_card: true
26
- validates :input_1, credit_card: { provider: :visa }
25
+ validates :input0, credit_card: true
26
+ validates :input1, credit_card: { provider: :visa }
27
27
 
28
28
  end
29
29
  ```
data/docs/CSV.md CHANGED
@@ -36,9 +36,9 @@ not_equal_to | numeric | |
36
36
  ```ruby
37
37
  class User < ActiveRecord::Base
38
38
 
39
- validates :input_0, csv: { columns: { less_than: 100 } }
40
- validates :input_1, csv: { rows: { in: (50..100) } }
41
- validates :input_2, csv: { columns: { equal_to: 5 }, rows: { greater_than: 5 } }
39
+ validates :input0, csv: { columns: { less_than: 100 } }
40
+ validates :input1, csv: { rows: { in: (50..100) } }
41
+ validates :input2, csv: { columns: { equal_to: 5 }, rows: { greater_than: 5 } }
42
42
 
43
43
  end
44
44
  ```
data/docs/CURRENCY.md CHANGED
@@ -12,7 +12,7 @@
12
12
  ```ruby
13
13
  class User < ActiveRecord::Base
14
14
 
15
- validates :input_0, currency: true
15
+ validates :input0, currency: true
16
16
 
17
17
  end
18
18
  ```
data/docs/CUSIP.md CHANGED
@@ -14,7 +14,7 @@
14
14
  ```ruby
15
15
  class User < ActiveRecord::Base
16
16
 
17
- validates :input_0, cusip: true
17
+ validates :input0, cusip: true
18
18
 
19
19
  end
20
20
  ```
data/docs/EMAIL.md CHANGED
@@ -18,9 +18,9 @@ domain | array, string, symbol | |
18
18
  ```ruby
19
19
  class User < ActiveRecord::Base
20
20
 
21
- validates :input_0, email: true
22
- validates :input_1, email: { domain: 'com' }
23
- validates :input_2, email: { domain: %w[com org] }
21
+ validates :input0, email: true
22
+ validates :input1, email: { domain: 'com' }
23
+ validates :input2, email: { domain: %w[com org] }
24
24
 
25
25
  end
26
26
  ```
@@ -18,9 +18,9 @@ exclude | array, regexp, string, symbol | |
18
18
  ```ruby
19
19
  class User < ActiveRecord::Base
20
20
 
21
- validates :input_0, file_content_type: { include: 'text/csv' }
22
- validates :input_1, file_content_type: { exclude: %w[image/png text/plain] }
23
- validates :input_2, file_content_type: { include: /^text\/.*/, exclude: 'text/csv' }
21
+ validates :input0, file_content_type: { include: 'text/csv' }
22
+ validates :input1, file_content_type: { exclude: %w[image/png text/plain] }
23
+ validates :input2, file_content_type: { include: /^text\/.*/, exclude: 'text/csv' }
24
24
 
25
25
  end
26
26
  ```
@@ -18,8 +18,8 @@ exclude | array, string, symbol | |
18
18
  ```ruby
19
19
  class User < ActiveRecord::Base
20
20
 
21
- validates :input_0, file_extension: { include: 'csv' }
22
- validates :input_1, file_extension: { exclude: [:png, 'text'] }
21
+ validates :input0, file_extension: { include: 'csv' }
22
+ validates :input1, file_extension: { exclude: [:png, 'text'] }
23
23
 
24
24
  end
25
25
  ```
data/docs/FILE_SIZE.md CHANGED
@@ -30,9 +30,9 @@ not_equal_to | numeric | |
30
30
  ```ruby
31
31
  class User < ActiveRecord::Base
32
32
 
33
- validates :input_0, file_size: { less_than: 100 }
34
- validates :input_1, file_size: { greater_than_or_equal_to: 75, less_than: 100 }
35
- validates :input_0, file_size: { in: (50..100) }
33
+ validates :input0, file_size: { less_than: 100 }
34
+ validates :input1, file_size: { greater_than_or_equal_to: 75, less_than: 100 }
35
+ validates :input0, file_size: { in: (50..100) }
36
36
 
37
37
  end
38
38
  ```
data/docs/HEX.md CHANGED
@@ -12,7 +12,7 @@
12
12
  ```ruby
13
13
  class User < ActiveRecord::Base
14
14
 
15
- validates :input_0, hex: true
15
+ validates :input0, hex: true
16
16
 
17
17
  end
18
18
  ```
data/docs/IMEI.md CHANGED
@@ -14,7 +14,7 @@
14
14
  ```ruby
15
15
  class User < ActiveRecord::Base
16
16
 
17
- validates :input_0, imei: true
17
+ validates :input0, imei: true
18
18
 
19
19
  end
20
20
  ```
data/docs/IP_ADDRESS.md CHANGED
@@ -19,8 +19,8 @@ protocol | symbol | any, ipv4, ipv6 | any
19
19
  ```ruby
20
20
  class User < ActiveRecord::Base
21
21
 
22
- validates :input_0, ip_address: true
23
- validates :input_1, ip_address: { protocol: :ipv4 }
22
+ validates :input0, ip_address: true
23
+ validates :input1, ip_address: { protocol: :ipv4 }
24
24
 
25
25
  end
26
26
  ```
data/docs/ISBN.md CHANGED
@@ -12,7 +12,7 @@
12
12
  ```ruby
13
13
  class User < ActiveRecord::Base
14
14
 
15
- validates :input_0, isbn: true
15
+ validates :input0, isbn: true
16
16
 
17
17
  end
18
18
  ```
data/docs/ISIN.md CHANGED
@@ -14,7 +14,7 @@
14
14
  ```ruby
15
15
  class User < ActiveRecord::Base
16
16
 
17
- validates :input_0, isin: true
17
+ validates :input0, isin: true
18
18
 
19
19
  end
20
20
  ```
data/docs/MAC_ADDRESS.md CHANGED
@@ -15,7 +15,7 @@
15
15
  ```ruby
16
16
  class User < ActiveRecord::Base
17
17
 
18
- validates :input_0, mac_address: true
18
+ validates :input0, mac_address: true
19
19
 
20
20
  end
21
21
  ```
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
@@ -12,7 +12,7 @@
12
12
  ```ruby
13
13
  class User < ActiveRecord::Base
14
14
 
15
- validates :input_0, name: true
15
+ validates :input0, name: true
16
16
 
17
17
  end
18
18
  ```
data/docs/PASSWORD.md CHANGED
@@ -19,8 +19,8 @@ strength | symbol | strong, weak | weak
19
19
  ```ruby
20
20
  class User < ActiveRecord::Base
21
21
 
22
- validates :input_0, password: true
23
- validates :input_1, password: { strength: :strong }
22
+ validates :input0, password: true
23
+ validates :input1, password: { strength: :strong }
24
24
 
25
25
  end
26
26
  ```
data/docs/PHONE_NUMBER.md CHANGED
@@ -12,7 +12,7 @@
12
12
  ```ruby
13
13
  class User < ActiveRecord::Base
14
14
 
15
- validates :input_0, phone_number: true
15
+ validates :input0, phone_number: true
16
16
 
17
17
  end
18
18
  ```
data/docs/SEDOL.md CHANGED
@@ -14,7 +14,7 @@
14
14
  ```ruby
15
15
  class User < ActiveRecord::Base
16
16
 
17
- validates :input_0, sedol: true
17
+ validates :input0, sedol: true
18
18
 
19
19
  end
20
20
  ```
data/docs/SLUG.md CHANGED
@@ -12,7 +12,7 @@
12
12
  ```ruby
13
13
  class User < ActiveRecord::Base
14
14
 
15
- validates :input_0, slug: true
15
+ validates :input0, slug: true
16
16
 
17
17
  end
18
18
  ```
data/docs/SSN.md CHANGED
@@ -12,7 +12,7 @@
12
12
  ```ruby
13
13
  class User < ActiveRecord::Base
14
14
 
15
- validates :input_0, ssn: true
15
+ validates :input0, ssn: true
16
16
 
17
17
  end
18
18
  ```
data/docs/TIME_ZONE.md CHANGED
@@ -11,7 +11,7 @@
11
11
  ```ruby
12
12
  class User < ActiveRecord::Base
13
13
 
14
- validates :input_0, time_zone: true
14
+ validates :input0, time_zone: true
15
15
 
16
16
  end
17
17
  ```
data/docs/TYPE.md CHANGED
@@ -18,11 +18,11 @@ is_not | class | |
18
18
  ```ruby
19
19
  class User < ActiveRecord::Base
20
20
 
21
- validates :input_0, type: { is: Array }
22
- validates :input_1, type: { is: Boolean } #=> Checks both TrueClass and FalseClass
23
- validates :input_2, type: { is: [Array, Hash] }
24
- validates :input_3, type: { is_not: CustomKlass } #=> Any Class based objects
25
- validates :input_4, type: { is_not: Integer }
21
+ validates :input0, type: { is: Array }
22
+ validates :input1, type: { is: Boolean } #=> Checks both TrueClass and FalseClass
23
+ validates :input2, type: { is: [Array, Hash] }
24
+ validates :input3, type: { is_not: CustomKlass } #=> Any Class based objects
25
+ validates :input4, type: { is_not: Integer }
26
26
 
27
27
  end
28
28
  ```
data/docs/URL.md CHANGED
@@ -19,10 +19,10 @@ scheme | array, string, symbol | |
19
19
  ```ruby
20
20
  class User < ActiveRecord::Base
21
21
 
22
- validates :input_0, url: true
23
- validates :input_1, url: { domain: [:com, 'org'] }
24
- validates :input_2, url: { scheme: :https }
25
- validates :input_3, url: { root_only: true }
22
+ validates :input0, url: true
23
+ validates :input1, url: { domain: [:com, 'org'] }
24
+ validates :input2, url: { scheme: :https }
25
+ validates :input3, url: { root_only: true }
26
26
 
27
27
  end
28
28
  ```
data/docs/USERNAME.md CHANGED
@@ -12,7 +12,7 @@
12
12
  ```ruby
13
13
  class User < ActiveRecord::Base
14
14
 
15
- validates :input_0, username: true
15
+ validates :input0, username: true
16
16
 
17
17
  end
18
18
  ```
data/docs/UUID.md CHANGED
@@ -21,8 +21,8 @@ version | symbol, integer | any, 3, 4, 5 | any
21
21
  ```ruby
22
22
  class User < ActiveRecord::Base
23
23
 
24
- validates :input_0, uuid: true
25
- validates :input_1, uuid: { version: 3 }
24
+ validates :input0, uuid: true
25
+ validates :input1, uuid: { version: 3 }
26
26
 
27
27
  end
28
28
  ```
@@ -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
@@ -27,7 +27,7 @@ class IsinValidator < BaseValidator
27
27
 
28
28
  longest = longest.map { |int| int * 2 }
29
29
  values = longest.concat(shortest).to_s.scan(/./).map(&:to_i)
30
- total = values.inject(&:+)
30
+ total = values.sum
31
31
 
32
32
  (10 - (total % 10)) % 10
33
33
  end
@@ -2,10 +2,10 @@
2
2
 
3
3
  class MacAddressValidator < BaseValidator
4
4
 
5
- REGEXP ||= [
6
- /^(\h{2}[-|.:|\s]){5}\h{2}?$/i,
7
- /^(\h{4}[-|.:|\s]){2}\h{4}?$/i,
8
- /^(\h{6}[-|.:|\s])\h{6}?$/i,
5
+ REGEXP = [
6
+ /^(\h{2}[-|.:\s]){5}\h{2}?$/i,
7
+ /^(\h{4}[-|.:\s]){2}\h{4}?$/i,
8
+ /^(\h{6}[-|.:\s])\h{6}?$/i,
9
9
  /^\h{12}?$/i
10
10
  ].freeze
11
11
 
@@ -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
@@ -8,7 +8,7 @@ module Lite
8
8
 
9
9
  initializer 'lite-validators' do |app|
10
10
  Lite::Validators::Railtie.instance_eval do
11
- [app.config.i18n.available_locales].flatten.each do |locale|
11
+ Array(app.config.i18n.available_locales).each do |locale|
12
12
  path = File.expand_path("../../../config/locales/#{locale}.yml", __FILE__)
13
13
  next if !File.file?(path) || I18n.load_path.include?(path)
14
14
 
@@ -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.0'
6
+ VERSION = '1.3.0'
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.0
4
+ version: 1.3.0
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-09-04 00:00:00.000000000 Z
11
+ date: 2021-07-20 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
@@ -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