bra_document_validation 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/.github/dependabot.yml +8 -0
- data/.github/workflows/main.yml +29 -0
- data/.mise.toml +2 -0
- data/.travis.yml +4 -1
- data/CHANGELOG.md +37 -1
- data/Gemfile.lock +70 -41
- data/README.md +21 -2
- data/bin/console +1 -3
- data/bin/rake +16 -0
- data/bin/rspec +16 -0
- data/bra_document_validation.gemspec +3 -4
- data/lib/bra_document_validation/cnpj_validator.rb +8 -27
- data/lib/bra_document_validation/cpf_or_cnpj_validator.rb +31 -0
- data/lib/bra_document_validation/cpf_validator.rb +8 -22
- data/lib/bra_document_validation/version.rb +1 -1
- data/lib/bra_document_validation.rb +1 -0
- metadata +13 -24
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ec08fe50acbaf14c9a29341bed95128f5e842902fe64637dcf2b91cc3a3a723c
|
|
4
|
+
data.tar.gz: 032a15b71e33bc2150df270e91701f64966ac6c72176b23329fd59c8f406c19b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '086401b9a0813aaa45327cbeb628dad6c7171d9dfe0b133bbf39b0169fcebff165e593196ba6787e75c9595cac697d4183000ab848498478bafa20edece0d83e'
|
|
7
|
+
data.tar.gz: f47e3d9fb3470016ed7b7c94f8b97a6eabe5a62ef59b82ff45357bdbd74cfff1b30ed62b31f272677f8d5e95ad246bafec91d75ae4fb05e9190392c389ba27ff
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
name: Ruby
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- master
|
|
7
|
+
|
|
8
|
+
pull_request:
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
build:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
name: Ruby ${{ matrix.ruby }}
|
|
14
|
+
strategy:
|
|
15
|
+
matrix:
|
|
16
|
+
ruby:
|
|
17
|
+
- '3.3.7'
|
|
18
|
+
- '3.4.2'
|
|
19
|
+
- '4.0.0'
|
|
20
|
+
|
|
21
|
+
steps:
|
|
22
|
+
- uses: actions/checkout@v5
|
|
23
|
+
- name: Set up Ruby
|
|
24
|
+
uses: ruby/setup-ruby@v1
|
|
25
|
+
with:
|
|
26
|
+
ruby-version: ${{ matrix.ruby }}
|
|
27
|
+
bundler-cache: true
|
|
28
|
+
- name: Run the default task
|
|
29
|
+
run: bundle exec rake
|
data/.mise.toml
ADDED
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
# Changelog
|
|
3
|
+
|
|
3
4
|
All notable changes to this project will be documented in this file.
|
|
4
5
|
|
|
5
6
|
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
|
@@ -7,6 +8,41 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
|
7
8
|
|
|
8
9
|
## [Unreleased]
|
|
9
10
|
|
|
11
|
+
## [1.1.0] - 2026-01-14
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
|
|
15
|
+
- Update `bra_documents` dependency to `>= 1.1.0` for alphanumeric CNPJ support
|
|
16
|
+
- Update CNPJ validator to support alphanumeric format as per new Brazilian Federal Revenue regulation (effective July 2026)
|
|
17
|
+
- Reference: https://www.gov.br/receitafederal/pt-br/assuntos/noticias/2024/outubro/cnpj-tera-letras-e-numeros-a-partir-de-julho-de-2026
|
|
18
|
+
|
|
19
|
+
### Added
|
|
20
|
+
|
|
21
|
+
- Add IRB as development dependency
|
|
22
|
+
- Add binstubs for rake and rspec
|
|
23
|
+
|
|
24
|
+
## [1.0.2] - 2022-01-04
|
|
25
|
+
|
|
26
|
+
### Removed
|
|
27
|
+
|
|
28
|
+
- Drop Support for Ruby 2.6 or less
|
|
29
|
+
|
|
30
|
+
### Refactory
|
|
31
|
+
|
|
32
|
+
- Refactory CPF and CNPJ Validators to use new bra_documents's methods
|
|
33
|
+
|
|
34
|
+
### Added
|
|
35
|
+
|
|
36
|
+
- Add new validator to check if an attribute is a CPF or a CNPJ
|
|
37
|
+
|
|
38
|
+
## [1.0.1] - 2020-11-08
|
|
39
|
+
|
|
40
|
+
### Fixed
|
|
41
|
+
|
|
42
|
+
- Fix Gemfile lock
|
|
43
|
+
|
|
10
44
|
## [1.0.0] - 2020-11-08
|
|
45
|
+
|
|
11
46
|
### Added
|
|
12
|
-
|
|
47
|
+
|
|
48
|
+
- CPF and CNPJ Validators
|
data/Gemfile.lock
CHANGED
|
@@ -1,62 +1,91 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
bra_document_validation (
|
|
4
|
+
bra_document_validation (1.1.0)
|
|
5
5
|
activemodel (>= 4.0)
|
|
6
|
-
bra_documents
|
|
6
|
+
bra_documents (>= 1.1.0)
|
|
7
7
|
|
|
8
8
|
GEM
|
|
9
9
|
remote: https://rubygems.org/
|
|
10
10
|
specs:
|
|
11
|
-
activemodel (
|
|
12
|
-
activesupport (=
|
|
13
|
-
activesupport (
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
11
|
+
activemodel (8.1.1)
|
|
12
|
+
activesupport (= 8.1.1)
|
|
13
|
+
activesupport (8.1.1)
|
|
14
|
+
base64
|
|
15
|
+
bigdecimal
|
|
16
|
+
concurrent-ruby (~> 1.0, >= 1.3.1)
|
|
17
|
+
connection_pool (>= 2.2.5)
|
|
18
|
+
drb
|
|
19
|
+
i18n (>= 1.6, < 2)
|
|
20
|
+
json
|
|
21
|
+
logger (>= 1.4.2)
|
|
22
|
+
minitest (>= 5.1)
|
|
23
|
+
securerandom (>= 0.3)
|
|
24
|
+
tzinfo (~> 2.0, >= 2.0.5)
|
|
25
|
+
uri (>= 0.13.1)
|
|
26
|
+
base64 (0.3.0)
|
|
27
|
+
bigdecimal (4.0.1)
|
|
28
|
+
bra_documents (1.1.0)
|
|
29
|
+
concurrent-ruby (1.3.6)
|
|
30
|
+
connection_pool (3.0.2)
|
|
31
|
+
date (3.5.1)
|
|
32
|
+
diff-lcs (1.6.2)
|
|
33
|
+
drb (2.2.3)
|
|
34
|
+
erb (6.0.1)
|
|
35
|
+
i18n (1.14.8)
|
|
24
36
|
concurrent-ruby (~> 1.0)
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
io-console (0.8.2)
|
|
38
|
+
irb (1.16.0)
|
|
39
|
+
pp (>= 0.6.0)
|
|
40
|
+
rdoc (>= 4.0.0)
|
|
41
|
+
reline (>= 0.4.2)
|
|
42
|
+
json (2.18.0)
|
|
43
|
+
logger (1.7.0)
|
|
44
|
+
minitest (6.0.1)
|
|
45
|
+
prism (~> 1.5)
|
|
46
|
+
pp (0.6.3)
|
|
47
|
+
prettyprint
|
|
48
|
+
prettyprint (0.2.0)
|
|
49
|
+
prism (1.7.0)
|
|
50
|
+
psych (5.3.1)
|
|
51
|
+
date
|
|
52
|
+
stringio
|
|
53
|
+
rake (13.3.1)
|
|
54
|
+
rdoc (7.1.0)
|
|
55
|
+
erb
|
|
56
|
+
psych (>= 4.0.0)
|
|
57
|
+
tsort
|
|
58
|
+
reline (0.6.3)
|
|
59
|
+
io-console (~> 0.5)
|
|
60
|
+
rspec (3.13.2)
|
|
61
|
+
rspec-core (~> 3.13.0)
|
|
62
|
+
rspec-expectations (~> 3.13.0)
|
|
63
|
+
rspec-mocks (~> 3.13.0)
|
|
64
|
+
rspec-core (3.13.6)
|
|
65
|
+
rspec-support (~> 3.13.0)
|
|
66
|
+
rspec-expectations (3.13.5)
|
|
40
67
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
41
|
-
rspec-support (~> 3.
|
|
42
|
-
rspec-mocks (3.
|
|
68
|
+
rspec-support (~> 3.13.0)
|
|
69
|
+
rspec-mocks (3.13.7)
|
|
43
70
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
44
|
-
rspec-support (~> 3.
|
|
45
|
-
rspec-support (3.
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
71
|
+
rspec-support (~> 3.13.0)
|
|
72
|
+
rspec-support (3.13.6)
|
|
73
|
+
securerandom (0.4.1)
|
|
74
|
+
stringio (3.2.0)
|
|
75
|
+
tsort (0.2.0)
|
|
76
|
+
tzinfo (2.0.6)
|
|
77
|
+
concurrent-ruby (~> 1.0)
|
|
78
|
+
uri (1.1.1)
|
|
50
79
|
|
|
51
80
|
PLATFORMS
|
|
52
81
|
ruby
|
|
82
|
+
x86_64-darwin-24
|
|
53
83
|
|
|
54
84
|
DEPENDENCIES
|
|
55
85
|
bra_document_validation!
|
|
56
|
-
|
|
57
|
-
pry-nav
|
|
86
|
+
irb
|
|
58
87
|
rake
|
|
59
88
|
rspec
|
|
60
89
|
|
|
61
90
|
BUNDLED WITH
|
|
62
|
-
|
|
91
|
+
4.0.3
|
data/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# BraDocumentValidation
|
|
2
2
|
|
|
3
|
+
[](https://travis-ci.com/bvicenzo/bra_document_validation)
|
|
4
|
+
|
|
3
5
|
This gem allows to validate Brazilian documents, CPF and CNPJ, with format and digit verification.
|
|
4
6
|
|
|
5
7
|
## Installation
|
|
@@ -12,17 +14,32 @@ gem 'bra_document_validation'
|
|
|
12
14
|
|
|
13
15
|
And then execute:
|
|
14
16
|
|
|
15
|
-
|
|
17
|
+
```sh
|
|
18
|
+
bundle install
|
|
19
|
+
```
|
|
16
20
|
|
|
17
21
|
Or install it yourself as:
|
|
18
22
|
|
|
19
|
-
|
|
23
|
+
```sh
|
|
24
|
+
gem install bra_document_validation
|
|
25
|
+
```
|
|
20
26
|
|
|
21
27
|
## Usage
|
|
22
28
|
|
|
23
29
|
```rb
|
|
24
30
|
validates :document_number, 'bra_document_validation/cpf': true
|
|
25
31
|
validates :document_number, 'bra_document_validation/cnpj': true
|
|
32
|
+
validates :document_number, 'bra_document_validation/cpf_or_cnpj': true
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
You might need add CPF and CNPJ acronyms to inflactions.
|
|
36
|
+
|
|
37
|
+
```rb
|
|
38
|
+
# config/initializers/inflections.rb
|
|
39
|
+
ActiveSupport::Inflector.inflections do |inflect|
|
|
40
|
+
inflect.acronym 'CPF'
|
|
41
|
+
inflect.acronym 'CNPJ'
|
|
42
|
+
end
|
|
26
43
|
```
|
|
27
44
|
|
|
28
45
|
# Format
|
|
@@ -33,6 +50,7 @@ However you can pass options if your number is formatted.
|
|
|
33
50
|
```rb
|
|
34
51
|
validates :document_number, 'bra_document_validation/cpf': { formatted: true }
|
|
35
52
|
validates :document_number, 'bra_document_validation/cnpj': { formatted: false }
|
|
53
|
+
validates :document_number, 'bra_document_validation/cpf_or_cnpj': { formatted: false }
|
|
36
54
|
```
|
|
37
55
|
|
|
38
56
|
# Messaging
|
|
@@ -44,6 +62,7 @@ However you can add a custom message that substitute the above messages.
|
|
|
44
62
|
```rb
|
|
45
63
|
validates :document_number, 'bra_document_validation/cpf': { message: :invalid }
|
|
46
64
|
validates :document_number, 'bra_document_validation/cnpj': { message: 'A custom message' }
|
|
65
|
+
validates :document_number, 'bra_document_validation/cpf_or_cnpj': { message: :invalid }
|
|
47
66
|
```
|
|
48
67
|
|
|
49
68
|
## Development
|
data/bin/console
CHANGED
data/bin/rake
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
#
|
|
5
|
+
# This file was generated by Bundler.
|
|
6
|
+
#
|
|
7
|
+
# The application 'rake' is installed as part of a gem, and
|
|
8
|
+
# this file is here to facilitate running it.
|
|
9
|
+
#
|
|
10
|
+
|
|
11
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
|
|
12
|
+
|
|
13
|
+
require "rubygems"
|
|
14
|
+
require "bundler/setup"
|
|
15
|
+
|
|
16
|
+
load Gem.bin_path("rake", "rake")
|
data/bin/rspec
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
#
|
|
5
|
+
# This file was generated by Bundler.
|
|
6
|
+
#
|
|
7
|
+
# The application 'rspec' is installed as part of a gem, and
|
|
8
|
+
# this file is here to facilitate running it.
|
|
9
|
+
#
|
|
10
|
+
|
|
11
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
|
|
12
|
+
|
|
13
|
+
require "rubygems"
|
|
14
|
+
require "bundler/setup"
|
|
15
|
+
|
|
16
|
+
load Gem.bin_path("rspec-core", "rspec")
|
|
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
|
10
10
|
spec.description = %q{We can validate CPF and CNPJ formats and verifying digits.}
|
|
11
11
|
spec.homepage = 'https://github.com/bvicenzo/bra_document_validation'
|
|
12
12
|
spec.license = 'MIT'
|
|
13
|
-
spec.required_ruby_version = Gem::Requirement.new('>=
|
|
13
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 3.3.0')
|
|
14
14
|
|
|
15
15
|
spec.metadata['allowed_push_host'] = 'https://rubygems.org/'
|
|
16
16
|
|
|
@@ -28,10 +28,9 @@ Gem::Specification.new do |spec|
|
|
|
28
28
|
spec.require_paths = ['lib']
|
|
29
29
|
|
|
30
30
|
spec.add_runtime_dependency 'activemodel', '>= 4.0'
|
|
31
|
-
spec.add_runtime_dependency 'bra_documents'
|
|
31
|
+
spec.add_runtime_dependency 'bra_documents', '>= 1.1.0'
|
|
32
32
|
|
|
33
|
-
spec.add_development_dependency '
|
|
34
|
-
spec.add_development_dependency 'pry-nav'
|
|
33
|
+
spec.add_development_dependency 'irb'
|
|
35
34
|
spec.add_development_dependency 'rake'
|
|
36
35
|
spec.add_development_dependency 'rspec'
|
|
37
36
|
end
|
|
@@ -2,43 +2,24 @@
|
|
|
2
2
|
|
|
3
3
|
module BraDocumentValidation
|
|
4
4
|
class CNPJValidator < ActiveModel::EachValidator
|
|
5
|
-
FORMATTED_CNPJ_PATTERN = /\A(\d{2}\.\d{3}\.\d{3}\/\d{4})-(\d{2})\Z/.freeze
|
|
6
|
-
RAW_CNPJ_PATTERN = /\A\d{14}\Z/.freeze
|
|
7
|
-
NOT_NUMBER_PATTERN = /\D/.freeze
|
|
8
|
-
|
|
9
5
|
def validate_each(record, attribute, value)
|
|
10
|
-
return record.errors.add(attribute, error_message(:invalid_format)) unless
|
|
11
|
-
full_number = only_numbers_for(value.to_s)
|
|
12
|
-
record.errors.add(attribute, error_message(:invalid_verification_digit)) if black_listed?(full_number) || !digit_verified?(full_number)
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
private
|
|
6
|
+
return record.errors.add(attribute, error_message(:invalid_format)) unless valid_format?(value)
|
|
16
7
|
|
|
17
|
-
|
|
18
|
-
company_number, matrix_subsidiary_number = numbers_for(full_number)
|
|
19
|
-
|
|
20
|
-
full_number == BraDocuments::CNPJGenerator.generate(company_number: company_number, matrix_subsidiary_number: matrix_subsidiary_number)
|
|
8
|
+
record.errors.add(attribute, error_message(:invalid_verification_digit)) unless valid_verification_digit?(value)
|
|
21
9
|
end
|
|
22
10
|
|
|
23
|
-
|
|
24
|
-
number = value.gsub(NOT_NUMBER_PATTERN, '').chars
|
|
25
|
-
|
|
26
|
-
[
|
|
27
|
-
number.shift(BraDocuments::CNPJGenerator::COMPANY_NUMBER_SIZE).join,
|
|
28
|
-
number.shift(BraDocuments::CNPJGenerator::MATRIX_SUBSIDIARY_SIZE).join
|
|
29
|
-
]
|
|
30
|
-
end
|
|
11
|
+
private
|
|
31
12
|
|
|
32
|
-
def
|
|
33
|
-
|
|
13
|
+
def valid_format?(document)
|
|
14
|
+
BraDocuments::Matcher.match?(document.to_s, kind: :cnpj, mode: document_format)
|
|
34
15
|
end
|
|
35
16
|
|
|
36
|
-
def
|
|
37
|
-
|
|
17
|
+
def valid_verification_digit?(document)
|
|
18
|
+
BraDocuments::CNPJGenerator.valid_verification_digit?(document: document.to_s)
|
|
38
19
|
end
|
|
39
20
|
|
|
40
21
|
def document_format
|
|
41
|
-
options[:formatted] ?
|
|
22
|
+
options[:formatted] ? :formatted : :raw
|
|
42
23
|
end
|
|
43
24
|
|
|
44
25
|
def error_message(default_message)
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module BraDocumentValidation
|
|
4
|
+
class CPFOrCNPJValidator < ActiveModel::EachValidator
|
|
5
|
+
def validate_each(record, attribute, value)
|
|
6
|
+
return record.errors.add(attribute, error_message(:invalid_format)) unless valid_format?(value)
|
|
7
|
+
|
|
8
|
+
record.errors.add(attribute, error_message(:invalid_verification_digit)) unless valid_verification_digit?(value)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
private
|
|
12
|
+
|
|
13
|
+
def valid_format?(document)
|
|
14
|
+
BraDocuments::Matcher.match?(document.to_s, kind: :cpf, mode: document_format) ||
|
|
15
|
+
BraDocuments::Matcher.match?(document.to_s, kind: :cnpj, mode: document_format)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def valid_verification_digit?(document)
|
|
19
|
+
BraDocuments::CPFGenerator.valid_verification_digit?(document: document.to_s) ||
|
|
20
|
+
BraDocuments::CNPJGenerator.valid_verification_digit?(document: document.to_s)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def document_format
|
|
24
|
+
options[:formatted] ? :formatted : :raw
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def error_message(default_message)
|
|
28
|
+
options.fetch(:message, default_message)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -2,38 +2,24 @@
|
|
|
2
2
|
|
|
3
3
|
module BraDocumentValidation
|
|
4
4
|
class CPFValidator < ActiveModel::EachValidator
|
|
5
|
-
FORMATTED_CPF_PATTERN = /^(\d{3}\.\d{3}\.\d{3})-(\d{2})$/.freeze
|
|
6
|
-
RAW_CPF_PATTERN = /\A\d{11}\z/
|
|
7
|
-
NOT_NUMBER_PATTERN = /\D/.freeze
|
|
8
|
-
|
|
9
5
|
def validate_each(record, attribute, value)
|
|
10
|
-
return record.errors.add(attribute, error_message(:invalid_format)) unless
|
|
11
|
-
full_number = only_numbers_for(value.to_s)
|
|
12
|
-
record.errors.add(attribute, error_message(:invalid_verification_digit)) if black_listed?(full_number) || !digit_verified?(full_number)
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
private
|
|
6
|
+
return record.errors.add(attribute, error_message(:invalid_format)) unless valid_format?(value)
|
|
16
7
|
|
|
17
|
-
|
|
18
|
-
person_number = number_without_verifying_digits_for(number)
|
|
19
|
-
|
|
20
|
-
number == BraDocuments::CPFGenerator.generate(person_number: person_number)
|
|
8
|
+
record.errors.add(attribute, error_message(:invalid_verification_digit)) unless valid_verification_digit?(value)
|
|
21
9
|
end
|
|
22
10
|
|
|
23
|
-
|
|
24
|
-
number.chars.shift(BraDocuments::CPFGenerator::PERSON_NUMBER_SIZE).join
|
|
25
|
-
end
|
|
11
|
+
private
|
|
26
12
|
|
|
27
|
-
def
|
|
28
|
-
|
|
13
|
+
def valid_format?(document)
|
|
14
|
+
BraDocuments::Matcher.match?(document.to_s, kind: :cpf, mode: document_format)
|
|
29
15
|
end
|
|
30
16
|
|
|
31
|
-
def
|
|
32
|
-
|
|
17
|
+
def valid_verification_digit?(document)
|
|
18
|
+
BraDocuments::CPFGenerator.valid_verification_digit?(document: document.to_s)
|
|
33
19
|
end
|
|
34
20
|
|
|
35
21
|
def document_format
|
|
36
|
-
options[:formatted] ?
|
|
22
|
+
options[:formatted] ? :formatted : :raw
|
|
37
23
|
end
|
|
38
24
|
|
|
39
25
|
def error_message(default_message)
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: bra_document_validation
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Bruno Vicenzo
|
|
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
|
|
@@ -30,30 +29,16 @@ dependencies:
|
|
|
30
29
|
requirements:
|
|
31
30
|
- - ">="
|
|
32
31
|
- !ruby/object:Gem::Version
|
|
33
|
-
version:
|
|
32
|
+
version: 1.1.0
|
|
34
33
|
type: :runtime
|
|
35
34
|
prerelease: false
|
|
36
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
36
|
requirements:
|
|
38
37
|
- - ">="
|
|
39
38
|
- !ruby/object:Gem::Version
|
|
40
|
-
version:
|
|
41
|
-
- !ruby/object:Gem::Dependency
|
|
42
|
-
name: pry
|
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
|
44
|
-
requirements:
|
|
45
|
-
- - ">="
|
|
46
|
-
- !ruby/object:Gem::Version
|
|
47
|
-
version: '0'
|
|
48
|
-
type: :development
|
|
49
|
-
prerelease: false
|
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
-
requirements:
|
|
52
|
-
- - ">="
|
|
53
|
-
- !ruby/object:Gem::Version
|
|
54
|
-
version: '0'
|
|
39
|
+
version: 1.1.0
|
|
55
40
|
- !ruby/object:Gem::Dependency
|
|
56
|
-
name:
|
|
41
|
+
name: irb
|
|
57
42
|
requirement: !ruby/object:Gem::Requirement
|
|
58
43
|
requirements:
|
|
59
44
|
- - ">="
|
|
@@ -101,7 +86,10 @@ executables: []
|
|
|
101
86
|
extensions: []
|
|
102
87
|
extra_rdoc_files: []
|
|
103
88
|
files:
|
|
89
|
+
- ".github/dependabot.yml"
|
|
90
|
+
- ".github/workflows/main.yml"
|
|
104
91
|
- ".gitignore"
|
|
92
|
+
- ".mise.toml"
|
|
105
93
|
- ".rspec"
|
|
106
94
|
- ".travis.yml"
|
|
107
95
|
- CHANGELOG.md
|
|
@@ -111,10 +99,13 @@ files:
|
|
|
111
99
|
- README.md
|
|
112
100
|
- Rakefile
|
|
113
101
|
- bin/console
|
|
102
|
+
- bin/rake
|
|
103
|
+
- bin/rspec
|
|
114
104
|
- bin/setup
|
|
115
105
|
- bra_document_validation.gemspec
|
|
116
106
|
- lib/bra_document_validation.rb
|
|
117
107
|
- lib/bra_document_validation/cnpj_validator.rb
|
|
108
|
+
- lib/bra_document_validation/cpf_or_cnpj_validator.rb
|
|
118
109
|
- lib/bra_document_validation/cpf_validator.rb
|
|
119
110
|
- lib/bra_document_validation/version.rb
|
|
120
111
|
homepage: https://github.com/bvicenzo/bra_document_validation
|
|
@@ -125,7 +116,6 @@ metadata:
|
|
|
125
116
|
homepage_uri: https://github.com/bvicenzo/bra_document_validation
|
|
126
117
|
source_code_uri: https://github.com/bvicenzo/bra_document_validation
|
|
127
118
|
changelog_uri: https://github.com/bvicenzo/bra_document_validation/blob/master/CHANGELOG.md
|
|
128
|
-
post_install_message:
|
|
129
119
|
rdoc_options: []
|
|
130
120
|
require_paths:
|
|
131
121
|
- lib
|
|
@@ -133,15 +123,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
133
123
|
requirements:
|
|
134
124
|
- - ">="
|
|
135
125
|
- !ruby/object:Gem::Version
|
|
136
|
-
version:
|
|
126
|
+
version: 3.3.0
|
|
137
127
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
138
128
|
requirements:
|
|
139
129
|
- - ">="
|
|
140
130
|
- !ruby/object:Gem::Version
|
|
141
131
|
version: '0'
|
|
142
132
|
requirements: []
|
|
143
|
-
rubygems_version:
|
|
144
|
-
signing_key:
|
|
133
|
+
rubygems_version: 4.0.3
|
|
145
134
|
specification_version: 4
|
|
146
135
|
summary: This gem add ActiveModel validations to Brazilian documents.
|
|
147
136
|
test_files: []
|