Skip to content

Commit 697c0e3

Browse files
Merge pull request #3 from avantcredit/company-id-regex-include-letters
Modify company identification regex to accept letters
2 parents 26b8f23 + 46c4a8f commit 697c0e3

File tree

5 files changed

+45
-4
lines changed

5 files changed

+45
-4
lines changed

examples/ach/records/batch_control_example.rb

+21
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,25 @@
3939
lambda { @record.company_identification_code_designator = 'A' }.should_not raise_error
4040
end
4141

42+
describe 'batch control - company identification' do
43+
it 'should allow for numeric values' do
44+
lambda { @record.company_identification = '012345678' }.should_not raise_error
45+
end
46+
47+
it 'should allow for alphanumeric values, with a leading letter' do
48+
lambda { @record.company_identification = 'A12345678' }.should_not raise_error
49+
end
50+
51+
it 'should not allow for multiple letters' do
52+
lambda { @record.company_identification = 'AA1234567' }.should raise_error
53+
end
54+
55+
it 'should not allow invalid length, 6 digits' do
56+
lambda { @record.company_identification = '123456' }.should raise_error
57+
end
58+
59+
it 'should not allow invalid length, 10 digits' do
60+
lambda { @record.company_identification = '1234567890' }.should raise_error
61+
end
62+
end
4263
end

examples/ach/records/batch_header_example.rb

+21-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,26 @@
2828
lambda { @record.standard_entry_class_code = 'CCD' }.should_not raise_error(RuntimeError)
2929
end
3030

31-
it 'should be limited to real codes'
31+
describe 'batch header - company identification' do
32+
it 'should allow for numeric values' do
33+
lambda { @record.company_identification = '012345678' }.should_not raise_error
34+
end
35+
36+
it 'should allow for alphanumeric values, with a leading letter' do
37+
lambda { @record.company_identification = 'A12345678' }.should_not raise_error
38+
end
39+
40+
it 'should not allow for multiple letters' do
41+
lambda { @record.company_identification = 'AA1234567' }.should raise_error
42+
end
43+
44+
it 'should not allow invalid length, 6 digits' do
45+
lambda { @record.company_identification = '123456' }.should raise_error
46+
end
47+
48+
it 'should not allow invalid length, 10 digits' do
49+
lambda { @record.company_identification = '1234567890' }.should raise_error
50+
end
51+
end
3252
end
3353
end

lib/ach/records/batch_control.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class BatchControl < Record
1616
field :company_identification_code_designator, String, nil, '1',
1717
/\A[0-9A-Z ]\z/
1818
field :company_identification, String,
19-
lambda { |f| f.rjust(9) }, nil, /\A\d{7,9}\z/
19+
lambda { |f| f.rjust(9) }, nil, /\A[\dA-Z]\d{6,8}\z/
2020

2121
field :message_authentication_code, String,
2222
lambda { |f| left_justify(f, 19)}, ''

lib/ach/records/batch_header.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class BatchHeader < Record
1414
field :company_identification_code_designator, String, nil, '1',
1515
/\A[0-9A-Z ]\z/
1616
field :company_identification, String,
17-
lambda { |f| f.rjust(9) }, nil, /\A\d{7,9}\z/
17+
lambda { |f| f.rjust(9) }, nil, /\A[\dA-Z]\d{6,8}\z/
1818
# TODO This should be used to determine whether other records are valid for
1919
# this code. Should there be a Class for each code?
2020
# The default of PPD is purely for my benefit (Jared Morgan)

lib/ach/version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module ACH
2-
VERSION = '0.4.4'.freeze
2+
VERSION = '0.4.5'.freeze
33
end

0 commit comments

Comments
 (0)