Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CE validation #13

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/br_documents/documents/ie/ce.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ class IE::CE < IE::Base

set_verify_digits_weights first: %w(9 8 7 6 5 4 3 2)

set_format_regexp %r{^(06)[.-]?(\d{6})[-.]?(\d{1})}
set_format_regexp %r{^(0)(\d{1})[.-]?(\d{6})[-.]?(\d{1})}

set_pretty_format_mask %(%s.%s-%s)
set_pretty_format_mask %(%s%s.%s-%s)

set_fixed_digits [0, 6]
set_fixed_digits [0]

end
end
2 changes: 1 addition & 1 deletion lib/br_documents/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module BRDocuments
VERSION = "0.1.8"
VERSION = "0.1.9"
end
9 changes: 8 additions & 1 deletion spec/documents/ie/ce_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,25 @@
before :all do

@format_examples = {
"060000015" => "06.000001-5"
"060000015" => "06.000001-5",
"070558604" => "07.055860-4"
}

@valid_numbers = %w(
060000015
06.000.001-5
06000001-5
070558604
07.055.860-4
)

@invalid_numbers = %w(
0600000151
1060000015
060000051
070558601
0705586041
1070558604
)

@valid_verify_digits = {
Expand All @@ -38,6 +44,7 @@
'06.276959-6', # ESMALTEC S A
'06.666801-8', # CGTF CENTRAL GERADORA TERMELETRICA FORTALEZA S A
'06.859236-1', # COMPANHIA DE AGUA E ESGOTO DO CEARA CAGECE
'07.055860-4', # SOME RANDOM NUMBERS STARTED WITH 7
]
end

Expand Down