jschaedl / iban-validation

:bank: A small library for validating International Bank Account Numbers (IBANs)
MIT License
90 stars 19 forks source link

Question - BIC Feature? #33

Closed quentingosset closed 11 months ago

quentingosset commented 4 years ago

Good morning, sir, Super IBAN verification library :) however do you know a library that allows via the iban to retrieve the BIC code? Or do you have in the future idea of developing this feature?

And is there a possibility to retrieve only the key and not the error message? I use a custom rule in Laravel for IBAN checking and I would like to be able to return only the key of the error message so that I can translate it later in several languages.

jschaedl commented 1 year ago

Hi @quentingosset ,

however do you know a library that allows via the iban to retrieve the BIC code? Or do you have in the future idea of developing this feature?

I am not planning to implement any BIC related features within the iban-validation library. But you can check out https://github.com/jschaedl/Bav it might help you.

And is there a possibility to retrieve only the key and not the error message? I use a custom rule in Laravel for IBAN checking and I would like to be able to return only the key of the error message so that I can translate it later in several languages.

Did you try to configure the violation messages? I mean something like this:

use Iban\Validation\Validator;

$validator = new Validator([
    'violation.unsupported_country' => '<your translation key>',
    'violation.invalid_length' => '<your translation key>',
    'violation.invalid_format' => '<your translation key>',
    'violation.invalid_checksum' => '<your translation key>',
]);

And then translating the violation:

if (!$validator->validate($iban)) {
    foreach ($validator->getViolations() as $violation) {
        echo $translator->trans($violation, 'domain', ...);
    }
}