validates_identity-br_cnpj 1.0.0 → 1.1.0
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.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/.ruby-version +1 -1
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +71 -66
- data/lib/validates_identity/br_cnpj/validator.rb +7 -7
- data/lib/validates_identity/br_cnpj/version.rb +1 -1
- data/lib/validates_identity/br_cnpj.rb +1 -1
- data/validates_identity-br_cnpj.gemspec +2 -2
- metadata +3 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3e97d59316eeb9fde2fb1c0a0b20adb3c8e5d522588baa94bd20f5f87b53ded4
|
|
4
|
+
data.tar.gz: 878599b1d5c949470346c5650483e3b18ae3e4fd2e0839b9f6c98301f5703f34
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: dd9087d295d64ea508e1af758fde7e3da4ca93702086cb479c37ec8ab197d6edb406a49a2410d8b35f42b2e68ce64f536fd95b84fffaf47f1cce360e76e6c040
|
|
7
|
+
data.tar.gz: 233a47eab5bd0caa771e68e52cfeb531fabf222fbce0941b72762342e36417680e4d8bf2d41b9068034dc21169ceb5f62f3e3ed37b544a7142cfccc0c0f6b27d
|
data/.rubocop.yml
CHANGED
data/.ruby-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
4.0.5
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,113 +1,118 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
validates_identity-br_cnpj (1.
|
|
4
|
+
validates_identity-br_cnpj (1.1.0)
|
|
5
5
|
activemodel
|
|
6
6
|
validates_identity (>= 0.5.0)
|
|
7
7
|
|
|
8
8
|
GEM
|
|
9
9
|
remote: https://rubygems.org/
|
|
10
10
|
specs:
|
|
11
|
-
activemodel (
|
|
12
|
-
activesupport (=
|
|
13
|
-
activesupport (
|
|
11
|
+
activemodel (8.1.3)
|
|
12
|
+
activesupport (= 8.1.3)
|
|
13
|
+
activesupport (8.1.3)
|
|
14
14
|
base64
|
|
15
15
|
bigdecimal
|
|
16
|
-
concurrent-ruby (~> 1.0, >= 1.
|
|
16
|
+
concurrent-ruby (~> 1.0, >= 1.3.1)
|
|
17
17
|
connection_pool (>= 2.2.5)
|
|
18
18
|
drb
|
|
19
19
|
i18n (>= 1.6, < 2)
|
|
20
|
+
json
|
|
21
|
+
logger (>= 1.4.2)
|
|
20
22
|
minitest (>= 5.1)
|
|
21
|
-
|
|
22
|
-
tzinfo (~> 2.0)
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
securerandom (>= 0.3)
|
|
24
|
+
tzinfo (~> 2.0, >= 2.0.5)
|
|
25
|
+
uri (>= 0.13.1)
|
|
26
|
+
amazing_print (1.8.1)
|
|
27
|
+
ast (2.4.3)
|
|
28
|
+
base64 (0.3.0)
|
|
29
|
+
bigdecimal (4.1.2)
|
|
28
30
|
coderay (1.1.3)
|
|
29
|
-
concurrent-ruby (1.
|
|
30
|
-
connection_pool (
|
|
31
|
+
concurrent-ruby (1.3.6)
|
|
32
|
+
connection_pool (3.0.2)
|
|
31
33
|
coolline (0.5.0)
|
|
32
34
|
unicode_utils (~> 1.4)
|
|
33
|
-
diff-lcs (1.
|
|
34
|
-
drb (2.2.
|
|
35
|
-
|
|
36
|
-
i18n (1.14.1)
|
|
35
|
+
diff-lcs (1.6.2)
|
|
36
|
+
drb (2.2.3)
|
|
37
|
+
i18n (1.14.8)
|
|
37
38
|
concurrent-ruby (~> 1.0)
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
pry
|
|
39
|
+
io-console (0.8.2)
|
|
40
|
+
jazz_fingers (7.1.0)
|
|
41
|
+
amazing_print (~> 1.8)
|
|
42
|
+
pry (~> 0.15)
|
|
42
43
|
pry-coolline (~> 0.2)
|
|
43
|
-
json (2.
|
|
44
|
-
language_server-protocol (3.17.0.
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
44
|
+
json (2.19.8)
|
|
45
|
+
language_server-protocol (3.17.0.5)
|
|
46
|
+
lint_roller (1.1.0)
|
|
47
|
+
logger (1.7.0)
|
|
48
|
+
method_source (1.1.0)
|
|
49
|
+
minitest (6.0.6)
|
|
50
|
+
drb (~> 2.0)
|
|
51
|
+
prism (~> 1.5)
|
|
52
|
+
parallel (2.1.0)
|
|
53
|
+
parser (3.3.11.1)
|
|
50
54
|
ast (~> 2.4.1)
|
|
51
55
|
racc
|
|
52
|
-
|
|
56
|
+
prism (1.9.0)
|
|
57
|
+
pry (0.16.0)
|
|
53
58
|
coderay (~> 1.1)
|
|
54
59
|
method_source (~> 1.0)
|
|
55
|
-
|
|
56
|
-
byebug (~> 11.0)
|
|
57
|
-
pry (>= 0.13, < 0.15)
|
|
60
|
+
reline (>= 0.6.0)
|
|
58
61
|
pry-coolline (0.2.6)
|
|
59
62
|
coolline (~> 0.5)
|
|
60
63
|
pry (~> 0.13)
|
|
61
|
-
racc (1.
|
|
64
|
+
racc (1.8.1)
|
|
62
65
|
rainbow (3.1.1)
|
|
63
|
-
rake (13.
|
|
64
|
-
regexp_parser (2.
|
|
65
|
-
|
|
66
|
-
|
|
66
|
+
rake (13.4.2)
|
|
67
|
+
regexp_parser (2.12.0)
|
|
68
|
+
reline (0.6.3)
|
|
69
|
+
io-console (~> 0.5)
|
|
70
|
+
rspec (3.13.2)
|
|
67
71
|
rspec-core (~> 3.13.0)
|
|
68
72
|
rspec-expectations (~> 3.13.0)
|
|
69
73
|
rspec-mocks (~> 3.13.0)
|
|
70
|
-
rspec-core (3.13.
|
|
74
|
+
rspec-core (3.13.6)
|
|
71
75
|
rspec-support (~> 3.13.0)
|
|
72
|
-
rspec-expectations (3.13.
|
|
76
|
+
rspec-expectations (3.13.5)
|
|
73
77
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
74
78
|
rspec-support (~> 3.13.0)
|
|
75
|
-
rspec-mocks (3.13.
|
|
79
|
+
rspec-mocks (3.13.8)
|
|
76
80
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
77
81
|
rspec-support (~> 3.13.0)
|
|
78
|
-
rspec-support (3.13.
|
|
79
|
-
rubocop (1.
|
|
82
|
+
rspec-support (3.13.7)
|
|
83
|
+
rubocop (1.87.0)
|
|
80
84
|
json (~> 2.3)
|
|
81
|
-
language_server-protocol (
|
|
82
|
-
|
|
85
|
+
language_server-protocol (~> 3.17.0.2)
|
|
86
|
+
lint_roller (~> 1.1.0)
|
|
87
|
+
parallel (>= 1.10)
|
|
83
88
|
parser (>= 3.3.0.2)
|
|
84
89
|
rainbow (>= 2.2.2, < 4.0)
|
|
85
|
-
regexp_parser (>=
|
|
86
|
-
|
|
87
|
-
rubocop-ast (>= 1.30.0, < 2.0)
|
|
90
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
|
91
|
+
rubocop-ast (>= 1.49.0, < 2.0)
|
|
88
92
|
ruby-progressbar (~> 1.7)
|
|
89
|
-
unicode-display_width (>= 2.4.0, <
|
|
90
|
-
rubocop-ast (1.
|
|
91
|
-
parser (>= 3.
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
rubocop (
|
|
96
|
-
rubocop-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
rubocop (~> 1.
|
|
100
|
-
rubocop-capybara (~> 2.17)
|
|
101
|
-
rubocop-factory_bot (~> 2.22)
|
|
93
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
|
94
|
+
rubocop-ast (1.49.1)
|
|
95
|
+
parser (>= 3.3.7.2)
|
|
96
|
+
prism (~> 1.7)
|
|
97
|
+
rubocop-rake (0.7.1)
|
|
98
|
+
lint_roller (~> 1.1)
|
|
99
|
+
rubocop (>= 1.72.1)
|
|
100
|
+
rubocop-rspec (3.10.2)
|
|
101
|
+
lint_roller (~> 1.1)
|
|
102
|
+
regexp_parser (>= 2.0)
|
|
103
|
+
rubocop (~> 1.86, >= 1.86.2)
|
|
102
104
|
ruby-progressbar (1.13.0)
|
|
103
|
-
|
|
104
|
-
shoulda-matchers (
|
|
105
|
-
activesupport (>=
|
|
105
|
+
securerandom (0.4.1)
|
|
106
|
+
shoulda-matchers (7.0.1)
|
|
107
|
+
activesupport (>= 7.1)
|
|
106
108
|
tzinfo (2.0.6)
|
|
107
109
|
concurrent-ruby (~> 1.0)
|
|
108
|
-
unicode-display_width (2.
|
|
110
|
+
unicode-display_width (3.2.0)
|
|
111
|
+
unicode-emoji (~> 4.1)
|
|
112
|
+
unicode-emoji (4.2.0)
|
|
109
113
|
unicode_utils (1.4.0)
|
|
110
|
-
|
|
114
|
+
uri (1.1.1)
|
|
115
|
+
validates_identity (1.0.0)
|
|
111
116
|
activemodel
|
|
112
117
|
|
|
113
118
|
PLATFORMS
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
class ValidatesIdentity
|
|
4
4
|
module BrCnpj
|
|
5
5
|
class Validator
|
|
6
|
-
VALIDATION_REGULAR_EXPRESSION = %r{^(\d{2}
|
|
7
|
-
FORMAT_REGULAR_EXPRESSION = /(\d{2})(\d{3})(\d{3})(\d{4})(\d{2})/.freeze
|
|
6
|
+
VALIDATION_REGULAR_EXPRESSION = %r{^([A-Z\d]{2}\.?[A-Z\d]{3}\.?[A-Z\d]{3}/?[A-Z\d]{4})-?(\d{2})$}.freeze
|
|
7
|
+
FORMAT_REGULAR_EXPRESSION = /([A-Z\d]{2})([A-Z\d]{3})([A-Z\d]{3})([A-Z\d]{4})(\d{2})/.freeze
|
|
8
8
|
|
|
9
9
|
attr_reader :value
|
|
10
10
|
|
|
@@ -16,7 +16,7 @@ class ValidatesIdentity
|
|
|
16
16
|
return true if value.blank?
|
|
17
17
|
return false unless number
|
|
18
18
|
return false if striped_value.length != 14
|
|
19
|
-
return false if striped_value.
|
|
19
|
+
return false if striped_value[0, 12].chars.uniq.length == 1
|
|
20
20
|
|
|
21
21
|
verifier_digits == "#{first_digit_verifier}#{second_digit_verifier}"
|
|
22
22
|
end
|
|
@@ -31,7 +31,7 @@ class ValidatesIdentity
|
|
|
31
31
|
private
|
|
32
32
|
|
|
33
33
|
def result
|
|
34
|
-
@result ||= VALIDATION_REGULAR_EXPRESSION.match(value)
|
|
34
|
+
@result ||= VALIDATION_REGULAR_EXPRESSION.match(value.to_s.upcase)
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
def number
|
|
@@ -43,13 +43,13 @@ class ValidatesIdentity
|
|
|
43
43
|
def striped_number
|
|
44
44
|
return if number.nil?
|
|
45
45
|
|
|
46
|
-
@striped_number ||= number.gsub(%r{[
|
|
46
|
+
@striped_number ||= number.gsub(%r{[./-]}, '')
|
|
47
47
|
end
|
|
48
48
|
|
|
49
49
|
def striped_value
|
|
50
50
|
return if number.nil?
|
|
51
51
|
|
|
52
|
-
@striped_value ||= value.gsub(%r{[
|
|
52
|
+
@striped_value ||= value.to_s.upcase.gsub(%r{[./-]}, '')
|
|
53
53
|
end
|
|
54
54
|
|
|
55
55
|
def verifier_digits
|
|
@@ -70,7 +70,7 @@ class ValidatesIdentity
|
|
|
70
70
|
|
|
71
71
|
def multiply_and_sum(array, number)
|
|
72
72
|
multiplications = []
|
|
73
|
-
number.each_char.with_index { |char, index| multiplications[index] = char.
|
|
73
|
+
number.each_char.with_index { |char, index| multiplications[index] = (char.ord - 48) * array[index] }
|
|
74
74
|
multiplications.inject(:+)
|
|
75
75
|
end
|
|
76
76
|
|
|
@@ -10,5 +10,5 @@ class ValidatesIdentity
|
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
ValidatesIdentity.register_legal_identity_type('BR_CNPJ', ValidatesIdentity::BrCnpj::Validator)
|
|
13
|
-
ValidatesIdentity::ShouldaMatchers.register_legal_allowed_values('BR_CNPJ', %w[51.114.450/0001-46 89905757000138])
|
|
13
|
+
ValidatesIdentity::ShouldaMatchers.register_legal_allowed_values('BR_CNPJ', %w[51.114.450/0001-46 89905757000138 AB12CD34EFGH83])
|
|
14
14
|
ValidatesIdentity::ShouldaMatchers.register_legal_disallowed_values('BR_CNPJ', %w[123456 51.114.450/0001-56])
|
|
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
|
|
|
28
28
|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
|
29
29
|
spec.require_paths = ['lib']
|
|
30
30
|
|
|
31
|
-
spec.
|
|
32
|
-
spec.
|
|
31
|
+
spec.add_dependency 'activemodel'
|
|
32
|
+
spec.add_dependency 'validates_identity', '>= 0.5.0'
|
|
33
33
|
spec.metadata['rubygems_mfa_required'] = 'true'
|
|
34
34
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: validates_identity-br_cnpj
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Paulo Ribeiro
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: exe
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: activemodel
|
|
@@ -38,7 +37,6 @@ dependencies:
|
|
|
38
37
|
- - ">="
|
|
39
38
|
- !ruby/object:Gem::Version
|
|
40
39
|
version: 0.5.0
|
|
41
|
-
description:
|
|
42
40
|
email:
|
|
43
41
|
- plribeiro3000@gmail.com
|
|
44
42
|
executables: []
|
|
@@ -68,7 +66,6 @@ metadata:
|
|
|
68
66
|
source_code_uri: https://github.com/plribeiro3000/validates_identity-br_cnpj/blob/master
|
|
69
67
|
changelog_uri: https://github.com/plribeiro3000/validates_identity-br_cnpj/blob/master/CHANGELOG.md
|
|
70
68
|
rubygems_mfa_required: 'true'
|
|
71
|
-
post_install_message:
|
|
72
69
|
rdoc_options: []
|
|
73
70
|
require_paths:
|
|
74
71
|
- lib
|
|
@@ -83,8 +80,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
83
80
|
- !ruby/object:Gem::Version
|
|
84
81
|
version: '0'
|
|
85
82
|
requirements: []
|
|
86
|
-
rubygems_version:
|
|
87
|
-
signing_key:
|
|
83
|
+
rubygems_version: 4.0.10
|
|
88
84
|
specification_version: 4
|
|
89
85
|
summary: Validates Brazilian CNPJ Document and test it with matchers in a simple way.
|
|
90
86
|
test_files: []
|