diff --git a/lib/sepa_king/transaction/direct_debit_transaction.rb b/lib/sepa_king/transaction/direct_debit_transaction.rb index 569fed0..277d003 100644 --- a/lib/sepa_king/transaction/direct_debit_transaction.rb +++ b/lib/sepa_king/transaction/direct_debit_transaction.rb @@ -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) diff --git a/spec/direct_debit_transaction_spec.rb b/spec/direct_debit_transaction_spec.rb index 319a9bd..cf23a8f 100644 --- a/spec/direct_debit_transaction_spec.rb +++ b/spec/direct_debit_transaction_spec.rb @@ -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