active_validation 4.0.8 → 4.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/lib/active_validation/validators/cusip_validator.rb +1 -1
- data/lib/active_validation/validators/isin_validator.rb +1 -1
- data/lib/active_validation/validators/sedol_validator.rb +1 -1
- data/lib/active_validation/validators/tracking_number_validator.rb +2 -2
- data/lib/active_validation/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 16f9dcec3331a8ad7b8462c54a74bb9aefcd80a1
|
4
|
+
data.tar.gz: acecbc4a4e4407e53636e599885ff83df9173882
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e6b5932e0dbae78743ad2ef32c65a7870d34aed5557ab0384b4d7c49676ed066e3eb689fa56a7e66d1e530d93e394b6916b4976f33ab8a5b3f043153b7ae4c93
|
7
|
+
data.tar.gz: f30c40d9e4267d2d674ff0f72bb19965bcc70300d28cb8d5ba8244728eb52eeb416837f337277d6d0590086e653fccd4617b618f886c9c32d27e62c9467d1a51
|
data/.rubocop.yml
CHANGED
@@ -10,7 +10,7 @@ class CusipValidator < ActiveModel::EachValidator
|
|
10
10
|
|
11
11
|
# rubocop:disable Lint/UselessAssignment
|
12
12
|
def valid_checksum?(value)
|
13
|
-
digits = value.chars.map { |chr|
|
13
|
+
digits = value.chars.map { |chr| /[A-Z]/.match?(chr) ? (chr.ord - 55) : chr.to_i }
|
14
14
|
even_values = digits.values_at(* digits.each_index.select(&:even?))
|
15
15
|
odd_values = digits.values_at(* digits.each_index.select(&:odd?))
|
16
16
|
values = odd_values.map { |int| int * 2 }.zip(even_values).flatten
|
@@ -10,7 +10,7 @@ class IsinValidator < ActiveModel::EachValidator
|
|
10
10
|
|
11
11
|
def valid_checksum?(value)
|
12
12
|
characters = value.chars
|
13
|
-
digits = characters.map { |chr|
|
13
|
+
digits = characters.map { |chr| /[A-Z]/.match?(chr) ? (chr.ord - 55) : chr.to_i }
|
14
14
|
even_values = digits.values_at(*digits.each_index.select(&:even?))
|
15
15
|
odd_values = digits.values_at(*digits.each_index.select(&:odd?))
|
16
16
|
|
@@ -11,7 +11,7 @@ class SedolValidator < ActiveModel::EachValidator
|
|
11
11
|
private
|
12
12
|
|
13
13
|
def valid_checksum?(value)
|
14
|
-
digits = value.chars.map { |dgt|
|
14
|
+
digits = value.chars.map { |dgt| /[A-Z]/.match?(dgt) ? (dgt.ord - 55) : dgt.to_i }
|
15
15
|
|
16
16
|
total = 0
|
17
17
|
digits.each_with_index { |dgt, idx| total += (WEIGHTS[idx] * dgt) }
|
@@ -81,7 +81,7 @@ class TrackingNumberValidator < ActiveModel::EachValidator
|
|
81
81
|
end
|
82
82
|
|
83
83
|
def valid_fedex_smart_post_checksum?(value)
|
84
|
-
value = "92#{value}" unless
|
84
|
+
value = "92#{value}" unless /^92/.match?(value)
|
85
85
|
return(false) unless value.size == 22
|
86
86
|
|
87
87
|
pattern = CARRIERS_AND_SERVICES[:fedex][:smart_post]
|
@@ -177,7 +177,7 @@ class TrackingNumberValidator < ActiveModel::EachValidator
|
|
177
177
|
end
|
178
178
|
|
179
179
|
def valid_usps_usps91_checksum?(value)
|
180
|
-
value = "91#{value}" unless
|
180
|
+
value = "91#{value}" unless /^(420\d{5})?9[1-5]/.match?(value)
|
181
181
|
return(false) unless value.size == 22
|
182
182
|
|
183
183
|
pattern = CARRIERS_AND_SERVICES[:usps][:usps91]
|