lite-validators 1.0.7 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -0
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +18 -18
- data/docs/USERNAME.md +1 -1
- data/lib/lite/validators/base_validator.rb +1 -1
- data/lib/lite/validators/credit_card_validator.rb +1 -1
- data/lib/lite/validators/file_content_type_validator.rb +1 -1
- data/lib/lite/validators/file_extension_validator.rb +1 -3
- data/lib/lite/validators/isin_validator.rb +2 -2
- data/lib/lite/validators/type_validator.rb +1 -1
- data/lib/lite/validators/url_validator.rb +4 -4
- data/lib/lite/validators/username_validator.rb +1 -1
- data/lib/lite/validators/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 54bec919570a21f28c087f804b4d60b6a80483a7b95d333f6cae0345f78cba8b
|
4
|
+
data.tar.gz: 7ca9aa17a309d52c62d6a63c83dd9236f6c6c2697548df1c29037a321f589f80
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7957705bf86716d717ed2ab8d00d9a620f2813b31273160a1d8e6085e06cfa4fb3885f2b8b4f2773e8c4a3df9daf8a229ad49a221efbff46615ed2cbcd25cdfa
|
7
|
+
data.tar.gz: 0cc83bed5b93b76c69c30c1e7cbbaad8561004dcefee2d29fed07ca90543dcfb1d557885467ce68d2bc4f76adcb1a2e1173cc8a0a6addef293269f307e7006fb
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
lite-validators (1.0
|
4
|
+
lite-validators (1.1.0)
|
5
5
|
activemodel
|
6
6
|
|
7
7
|
GEM
|
@@ -31,22 +31,22 @@ GEM
|
|
31
31
|
ast (2.4.1)
|
32
32
|
builder (3.2.4)
|
33
33
|
colorize (0.8.1)
|
34
|
-
concurrent-ruby (1.1.
|
34
|
+
concurrent-ruby (1.1.7)
|
35
35
|
crass (1.0.6)
|
36
36
|
diff-lcs (1.4.4)
|
37
37
|
erubi (1.9.0)
|
38
38
|
fasterer (0.8.3)
|
39
39
|
colorize (~> 0.7)
|
40
40
|
ruby_parser (>= 3.14.1)
|
41
|
-
i18n (1.8.
|
41
|
+
i18n (1.8.5)
|
42
42
|
concurrent-ruby (~> 1.0)
|
43
|
-
loofah (2.
|
43
|
+
loofah (2.7.0)
|
44
44
|
crass (~> 1.0.2)
|
45
45
|
nokogiri (>= 1.5.9)
|
46
46
|
method_source (1.0.0)
|
47
47
|
mini_portile2 (2.4.0)
|
48
|
-
minitest (5.14.
|
49
|
-
nokogiri (1.10.
|
48
|
+
minitest (5.14.2)
|
49
|
+
nokogiri (1.10.10)
|
50
50
|
mini_portile2 (~> 2.4.0)
|
51
51
|
parallel (1.19.2)
|
52
52
|
parser (2.7.1.4)
|
@@ -90,31 +90,31 @@ GEM
|
|
90
90
|
rspec-mocks (~> 3.9)
|
91
91
|
rspec-support (~> 3.9)
|
92
92
|
rspec-support (3.9.3)
|
93
|
-
rubocop (0.
|
93
|
+
rubocop (0.90.0)
|
94
94
|
parallel (~> 1.10)
|
95
|
-
parser (>= 2.7.
|
95
|
+
parser (>= 2.7.1.1)
|
96
96
|
rainbow (>= 2.2.2, < 4.0)
|
97
97
|
regexp_parser (>= 1.7)
|
98
98
|
rexml
|
99
|
-
rubocop-ast (>= 0.0
|
99
|
+
rubocop-ast (>= 0.3.0, < 1.0)
|
100
100
|
ruby-progressbar (~> 1.7)
|
101
101
|
unicode-display_width (>= 1.4.0, < 2.0)
|
102
|
-
rubocop-ast (0.
|
103
|
-
parser (>= 2.7.
|
104
|
-
rubocop-performance (1.
|
105
|
-
rubocop (>= 0.
|
106
|
-
rubocop-rspec (1.
|
107
|
-
rubocop (
|
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
108
|
ruby-progressbar (1.10.1)
|
109
|
-
ruby_parser (3.
|
109
|
+
ruby_parser (3.15.0)
|
110
110
|
sexp_processor (~> 4.9)
|
111
|
-
sexp_processor (4.15.
|
111
|
+
sexp_processor (4.15.1)
|
112
112
|
thor (1.0.1)
|
113
113
|
thread_safe (0.3.6)
|
114
114
|
tzinfo (1.2.7)
|
115
115
|
thread_safe (~> 0.1)
|
116
116
|
unicode-display_width (1.7.0)
|
117
|
-
zeitwerk (2.
|
117
|
+
zeitwerk (2.4.0)
|
118
118
|
|
119
119
|
PLATFORMS
|
120
120
|
ruby
|
data/docs/USERNAME.md
CHANGED
@@ -23,7 +23,7 @@ class BaseValidator < ActiveModel::EachValidator
|
|
23
23
|
def assert_valid_option!(name, collection, option: nil)
|
24
24
|
option ||= send(name)
|
25
25
|
|
26
|
-
|
26
|
+
Array(option).each do |option_value|
|
27
27
|
next if collection.include?(option_value)
|
28
28
|
|
29
29
|
raise ArgumentError, "Unknown #{name}: #{option_value.inspect}. Valid options are: #{collection.map(&:inspect).join(', ')}"
|
@@ -88,7 +88,7 @@ class CreditCardValidator < BaseValidator
|
|
88
88
|
|
89
89
|
def checksum(value)
|
90
90
|
values = digits(value).reverse.map.with_index { |n, i| i.even? ? n * 2 : n }
|
91
|
-
total = values.reverse.inject(0) { |a, b| a + digits(b).
|
91
|
+
total = values.reverse.inject(0) { |a, b| a + digits(b).sum }
|
92
92
|
checksum = 10 - (total % 10)
|
93
93
|
checksum == 10 ? 0 : checksum
|
94
94
|
end
|
@@ -24,7 +24,7 @@ class FileContentTypeValidator < BaseValidator
|
|
24
24
|
|
25
25
|
# rubocop:disable Style/CaseEquality
|
26
26
|
def valid_content_type?(option, option_value)
|
27
|
-
check =
|
27
|
+
check = Array(option_value).any? { |type| type === value.content_type }
|
28
28
|
option == :exclude ? !check : check
|
29
29
|
end
|
30
30
|
# rubocop:enable Style/CaseEquality
|
@@ -22,10 +22,9 @@ class FileExtensionValidator < BaseValidator
|
|
22
22
|
|
23
23
|
def include_or_exclude
|
24
24
|
values = options[:include] || options[:exclude]
|
25
|
-
|
25
|
+
Array(values)
|
26
26
|
end
|
27
27
|
|
28
|
-
# rubocop:disable Metrics/AbcSize
|
29
28
|
def valid_attr?
|
30
29
|
extension = File.extname(value.original_filename).tr('.', '')
|
31
30
|
return false if extension.empty?
|
@@ -36,6 +35,5 @@ class FileExtensionValidator < BaseValidator
|
|
36
35
|
|
37
36
|
record.errors.add(attribute, *error_message)
|
38
37
|
end
|
39
|
-
# rubocop:enable Metrics/AbcSize
|
40
38
|
|
41
39
|
end
|
@@ -12,7 +12,7 @@ class IsinValidator < BaseValidator
|
|
12
12
|
valid_regexp? && valid_checksum?
|
13
13
|
end
|
14
14
|
|
15
|
-
# rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
|
15
|
+
# rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
|
16
16
|
def valid_checksum?
|
17
17
|
characters = value.chars
|
18
18
|
digits = characters.map { |chr| /[A-Z]/.match?(chr) ? (chr.ord - 55) : chr.to_i }
|
@@ -31,6 +31,6 @@ class IsinValidator < BaseValidator
|
|
31
31
|
|
32
32
|
(10 - (total % 10)) % 10
|
33
33
|
end
|
34
|
-
# rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
|
34
|
+
# rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
|
35
35
|
|
36
36
|
end
|
@@ -31,14 +31,15 @@ class UrlValidator < BaseValidator
|
|
31
31
|
valid_uri? && valid_domain? && valid_scheme? && valid_root?
|
32
32
|
end
|
33
33
|
|
34
|
-
# rubocop:disable Metrics/AbcSize
|
34
|
+
# rubocop:disable Layout/LineLength, Metrics/AbcSize
|
35
35
|
def valid_domain?
|
36
36
|
return true unless options[:domain]
|
37
37
|
|
38
38
|
value_downcased = value.host.to_s.downcase
|
39
|
-
check =
|
39
|
+
check = Array(options[:domain]).any? { |domain| value_downcased.end_with?(".#{domain.downcase}") }
|
40
40
|
record.errors.add(attribute, error_message_for(:domain)) unless check
|
41
41
|
end
|
42
|
+
# rubocop:enable Layout/LineLength, Metrics/AbcSize
|
42
43
|
|
43
44
|
def valid_root?
|
44
45
|
return true unless options[:root_only]
|
@@ -51,10 +52,9 @@ class UrlValidator < BaseValidator
|
|
51
52
|
return true unless options[:scheme]
|
52
53
|
|
53
54
|
value_downcased = value.scheme.to_s.downcase
|
54
|
-
check =
|
55
|
+
check = Array(scheme).any? { |sch| value_downcased == sch.to_s.downcase }
|
55
56
|
record.errors.add(attribute, error_message_for(:scheme)) unless check
|
56
57
|
end
|
57
|
-
# rubocop:enable Metrics/AbcSize
|
58
58
|
|
59
59
|
def valid_uri?
|
60
60
|
value.is_a?(URI::Generic)
|
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.0
|
4
|
+
version: 1.1.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-
|
11
|
+
date: 2020-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|