Skip to content

Commit

Permalink
DirectDebitTransaction: Validate #mandate_id format
Browse files Browse the repository at this point in the history
  • Loading branch information
ledermann committed Dec 22, 2013
1 parent 2e30d83 commit 8c8493f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/sepa_king/transaction/direct_debit_transaction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module SEPA
class DirectDebitTransaction < Transaction
attr_accessor :mandate_id, :mandate_date_of_signature, :local_instrument, :sequence_type, :creditor_account

validates_length_of :mandate_id, within: 1..35
validates_format_of :mandate_id, :with => /\A([A-Za-z0-9]|[\+|\?|\/|\-|\:|\(|\)|\.|\,|\']){1,35}\z/
validates_presence_of :mandate_date_of_signature
validates_inclusion_of :local_instrument, :in => %w(CORE COR1 B2B)
validates_inclusion_of :sequence_type, :in => %w(FRST OOFF RCUR FNAL)
Expand Down
4 changes: 2 additions & 2 deletions spec/direct_debit_transaction_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@

context 'Mandate ID' do
it 'should allow valid value' do
SEPA::DirectDebitTransaction.should accept('XYZ-123', 'X' * 35, for: :mandate_id)
SEPA::DirectDebitTransaction.should accept('XYZ-123', "+?/-:().,'", 'X' * 35, for: :mandate_id)
end

it 'should not allow invalid value' do
SEPA::DirectDebitTransaction.should_not accept(nil, '', 'X' * 36, for: :mandate_id)
SEPA::DirectDebitTransaction.should_not accept(nil, '', 'X' * 36, 'ABC 123', '#/*', 'Ümläüt', for: :mandate_id)
end
end
end

0 comments on commit 8c8493f

Please sign in to comment.