Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add (German) bank account validation with malkusch/bav #188

Merged
merged 1 commit into from Jan 14, 2015
Merged

Add (German) bank account validation with malkusch/bav #188

merged 1 commit into from Jan 14, 2015

Conversation

malkusch
Copy link
Contributor

Hi
I maintain the library malkusch/bav for validation of German bank accounts. This pull requests adds following rules to include bav into your library:

  • v::germanBank()
  • v::germanBankAccount()
  • v::germanBIC()
  • v::bank(string $countryCode)
  • v::bankAccount(string $countryCode, string $bank)
  • v::bic(string $countryCode)

This PR supports only the country code "de".

Enjoy.

@malkusch malkusch changed the title Add bank account validation with malkusch/bav Add German bank account validation with malkusch/bav Jun 25, 2014
@augustohp augustohp added this to the 0.7.0 milestone Jun 26, 2014
@henriquemoody
Copy link
Member

@malkusch, first of all, I'm sorry by our late.

This pull request must be rebased with the current master branch, also, I don't think a good idea to have a rule for an specific country, can you do something more generic like what was done in #226?

@malkusch
Copy link
Contributor Author

malkusch commented Jan 3, 2015

German bank validation has more than 100 validation rules. I'm too lazy to extend the validation for other countries. I will rebase if there is demand for a german bank validation.

@henriquemoody
Copy link
Member

I didn't say you have to extend the validation for other countries. What I'm trying to avoid is to have germanBank(), braziliamBank(), americamBank() and such... Define a country code in the constructor of the validator sounds too much better for me.
For a while, doesn't matter if you have german* private methods in the validator, but since you keep the API clean we can refactor this when other validators come.

@malkusch
Copy link
Contributor Author

malkusch commented Jan 3, 2015

Ok, Sorry I got you wrong. This sounds of course reasonable. I'll rebase and refactor the validator to a universal API with a country code dependency.

@henriquemoody
Copy link
Member

Thanks 😄

@henriquemoody henriquemoody modified the milestones: Backlog, 0.7.0 Jan 7, 2015
@malkusch
Copy link
Contributor Author

Rebased to master and refactored to Bank($countryCode), BankAccount($countryCode) and BIC($countryCode).

@malkusch malkusch changed the title Add German bank account validation with malkusch/bav Add (German) bank account validation with malkusch/bav Jan 13, 2015
@henriquemoody
Copy link
Member

Thanks, @malkusch, now I can review it!

Fist of all, you should fix the detected issues on the Scrutinizer's build.

I will start to review it now.


* "de" (Germany)

This validator needs `malkusch/bav` as dependency.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a dependency of de only, so I think you should put it on the same line of de.

@henriquemoody
Copy link
Member

If you use Callback instead of AbstractRule as you base class I think it's going to be better, but even using Callback you have to create instances inside the method and it is bad in many aspects because you cannot use dependency injection on it, that's why you need to configure and call malkusch/bav' objects instead of mock them.

I have to think about something better but now my headache doesn't let me do it. 😫

@malkusch
Copy link
Contributor Author

but even using Callback you have to create instances inside the method and it is bad in many aspects because you cannot use dependency injection on it

Yes, that comes with the universal validator which gets only the country code injected. You probably want to keep the API clean and simple i.e. prefer __construct($countryCode) over __construct(BankLocale $implementation).

@henriquemoody
Copy link
Member

I have to think more about it, my first thought was __construct($countryCode, BankCallableChain $bankCallableChain = null) but it doesn't looks like other Respect stuff and doesn't look a final idea. Any thoughts, @alganet?

@henriquemoody
Copy link
Member

Any way, it's not a blocker, we can refactor it, since we have a clean API.

@malkusch, just move the validation to the rules' constructors and, if you don't mind, squash these commits (there are too many of them for just 3 rules) and I guess we can merge it as it is.

@malkusch
Copy link
Contributor Author

Refactored and squashed.

$callback = function ($bic) use ($bav) {
return $bav->isValidBIC($bic);
};
break;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not?

$callback = array(new BAV(), 'isValidBIC');

$bav = new BAV();
$callback = function ($bank) use ($bav) {
return $bav->isValidBank($bank);
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

@henriquemoody
Copy link
Member

Thanks for all your work!!

henriquemoody added a commit that referenced this pull request Jan 14, 2015
Add (German) bank account validation with malkusch/bav
@henriquemoody henriquemoody merged commit 15dc825 into Respect:master Jan 14, 2015
@henriquemoody henriquemoody modified the milestones: 0.8.0, Backlog Jan 14, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants