arturmkrtchyan / iban4j

A Java library for generation and validation of the International Bank Account Numbers (IBAN ISO_13616) and Business Identifier Codes (BIC ISO_9362).
http://iban4j.org
Apache License 2.0
271 stars 124 forks source link

Add additional information to exceptions #16

Closed mikegr closed 9 years ago

mikegr commented 9 years ago

I have added constraints for each exception that specify the exact cause and allow additional information.

I have added a Gradle file to support the use with Android Studio. Furthermore I have added an IbanChecker that validates incomplete IBANs. The Android code has moved to my iban4android project. 'mvn package' still works, but please check if the change of the test cases are okay. I have moved some error cases to the UnsupportedCountryException and replaced the InvalidateArgumentException with their corresponding exception.

arturmkrtchyan commented 9 years ago

Thank you Michael for the pull request.

I have couple of questions.

  1. Why do you need IbanChecker ? (Is there a chance to deliver that functionality trough IbanUtils ?)
  2. Can you do fetch-rebase before pull request to master ?
  3. Can you tell me your requirements/context and I can try to think how can we make the best out of it ?
  4. The change basically touches every single file :) I would love to keep it as simple as possible.

Thank you, Artur  

mikegr commented 9 years ago
  1. I need to check incomplete IBANs as well. Therefore I added the IbanChecker. IbanUtils only works with complete IBANs, but eg. 'AT123' is a valid string that can become a valid IBAN .
  2. I will do that after we finished the discussion. Sorry forgot that.
  3. I would like to translate the error messages in different languages. With the specific constraint and the additional information I can create localized error messages for each error case. Without the changes I can only distinguish between 3 cases(=Exceptions for IbanFormat, InvalidCheckDigit, BicFormat) and show the user a generic message, that some formatting is wrong. However I can't tell her that the length does not fit or the allowed character type does not fit at position x.
  4. Maybe there is a different solution for my context. There could be more specific exceptions (eg InvalidLengthException, InvalidCountryCodeException,...) for special cases.
arturmkrtchyan commented 9 years ago

Thanks for providing the context.

So to sum up you need:

  1. way to get more granular exceptions or details about exceptions
  2. You need reactive or event based validator to get possible problems while user is typing right.

Let me think about solution and I will come back to you during weekend.

arturmkrtchyan commented 9 years ago

Hi Michael,

Let me know what you think.

Thanks, Artur

mikegr commented 9 years ago

Hi Artur, the changes almost solve all my problems.

3 points:

arturmkrtchyan commented 9 years ago

Hi Michael will implement those changes as well and let you know soon.

arturmkrtchyan commented 9 years ago

Hi Michael,

Let me know if this helps.

mikegr commented 9 years ago

I got sick. I will get back to you when I feel better.

mikegr commented 9 years ago

Hello, thanks for your changes. That will be enough information. Does the scope of iban4j includes validation of incomplete IBANs? I have add my code for that in https://github.com/mikegr/iban4android/blob/master/src/main/java/com/github/mikegr/iban4android/IbanChecker.java Not sure about that.

arturmkrtchyan commented 9 years ago

Hi Michael,

I don't think that partial iban checker should be in the project scope.

I will apply some sanity checks to master soon and publish new major version to maven central.

Thank you for helping to improve the library.

Thanks, Artur