Skip to content

Commit

Permalink
fix/validator-bol (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
OjedaNicolass authored Jul 25, 2024
1 parent 83c0dce commit c48ef4c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.1.5] - 2024-07-24

### Fixed
- The length of the Bolivian account was changed from 22 to between 10-22 digits.

## [1.1.4] - 2024-07-17

### Added
Expand Down
2 changes: 1 addition & 1 deletion src/Bo/BoBankAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function getAccountTile(): string

public function isValid(): bool
{
if (preg_match('/^([a-zA-Z]{3})\+([0-9]{22})$/', $this->bank_account_number) !== 1) {
if (preg_match('/^([a-zA-Z]{3})\+([0-9]{10,22})$/', $this->bank_account_number) !== 1) {
return false;
}

Expand Down
17 changes: 9 additions & 8 deletions tests/Bo/BoBankAccountTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,23 @@ final class BoBankAccountTest extends TestCase
public function testIsValid(): void
{
static::assertFalse((new BoBankAccount(''))->isValid());
static::assertFalse((new BoBankAccount('111111111'))->isValid());
static::assertFalse((new BoBankAccount('WQE+111111111'))->isValid());
static::assertFalse((new BoBankAccount('AAAAA0000'))->isValid());
static::assertFalse((new BoBankAccount('01340946340001361695'))->isValid());
static::assertFalse((new BoBankAccount('AAAAA0000'))->isValid());
static::assertFalse((new BoBankAccount('01050194651194-079423'))->isValid());
static::assertFalse((new BoBankAccount('01050194651194079423 More text?'))->isValid());
static::assertTrue((new BoBankAccount('ASD+1234567891234567891234'))->isValid());
static::assertFalse((new BoBankAccount('ASD+013409'))->isValid());
static::assertFalse((new BoBankAccount('ASD+0105019465114-07'))->isValid());
static::assertFalse((new BoBankAccount('ASD+0105019465119407 More text?'))->isValid());
static::assertFalse((new BoBankAccount('ASD+12345678913423511616123'))->isValid());
static::assertTrue((new BoBankAccount('ASD+1234567891342351161612'))->isValid());
static::assertTrue((new BoBankAccount('ASD+2345678912'))->isValid());
}

public function testBankName(): void
{
static::assertNull((new BoBankAccount('00050194697194012294'))->getBankName());
static::assertNull((new BoBankAccount('00050194697194'))->getBankName());
}

public function testAccountTile(): void
{
static::assertSame('CCI', (new BoBankAccount('01050194697194012294'))->getAccountTile());
static::assertSame('CCI', (new BoBankAccount('01050194697194'))->getAccountTile());
}
}

0 comments on commit c48ef4c

Please sign in to comment.