Skip to content

Commit

Permalink
Merge pull request #2 from ortic/fix/line-validation
Browse files Browse the repository at this point in the history
Allowed alphanumeric bank identifiers
  • Loading branch information
sprain committed Mar 4, 2016
2 parents 5847326 + 468e51a commit be2623b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions Tests/v11/Tests/v11Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class v11Test extends \PHPUnit_Framework_TestCase
public function testValidate()
{
$v11 = new v11(array(
"002012000002123456000000001291146290519 7500000000000014102414102414102400000000000000000000000",
"002012000002123456000000001291146290519 7500ZY0000000014102414102414102400000000000000000000000",
"012012000002123456000000001290507716881 50000008 000014102314102414102400552073900000000000120",
"002012000002123456000000001288602003992 2550000000000014102414102414102400000000000000000000000",
"002012000002123456000000001290068583973 50000008 000014102314102414102400489435900000000000000",
Expand Down Expand Up @@ -128,12 +128,12 @@ public function testValidateTransactionLineInvalidContents()
$v11 = new v11(array(
"002012000002123456000000001291146290519 7500000000000014102414102414102400000000000000000000000",
"012012000002123456000000001290507716881 50000008 000014102314102414102400552073900000000000120",
"002012000002123456000000001288602003992 255000000A000014102414102414102400000000000000000000000",
"002012000002123456000000001288602003992 255000000.000014102414102414102400000000000000000000000",
"002012000002123456000000001290068583973 50000008 000014102314102414102400489435900000000000000",
"999012000002999999999999999999999999999000000020050000000000004141027000000120000000004 ",
));
$this->assertFalse($v11->validate());
$this->assertSame('Line number 3 contains invalid characters. It may only contain digits and spaces', $v11->getError());
$this->assertSame('Line number 3 contains invalid characters. It may only contain digits, letters and spaces', $v11->getError());
}

public function testValidateNotMatchingNumberOfTransactions()
Expand Down
4 changes: 2 additions & 2 deletions lib/v11/v11.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,8 @@ public function validate()
return false;
}

if (!preg_match('/^[\d ]+$/', $line)) {
$this->setError(sprintf('Line number %s contains invalid characters. It may only contain digits and spaces', $i));
if (!preg_match('/^[\d a-zA-Z]+$/', $line)) {
$this->setError(sprintf('Line number %s contains invalid characters. It may only contain digits, letters and spaces', $i));

return false;
}
Expand Down

0 comments on commit be2623b

Please sign in to comment.