Validation icon indicating copy to clipboard operation
Validation copied to clipboard

IBAN Validation with non-breaking spaces

Open dennzo opened this issue 1 year ago • 0 comments

Interesting edge case here.

Sometimes people (also me) like to copy their IBAN from the banking app over into a payment form. In this case the IBAN displayed in banking apps have a non-breaking space instead of a regular one.

So when validating according to the IBAN Rule, the result is of course false, because only normal spaces get replaced. https://github.com/Respect/Validation/blob/e3740860f9217baa123bfe070c8a91dd07de89fa/library/Rules/Iban.php#L113C1-L114C1

We have now made a quick fix to our code just replacing the non-breaking spaces with normal ones. But this is just a temporary fix. str_replace(["\xc2\xa0", "\u00a0"], ' ', $body)

Can we also replace non-breaking spaces instead of only regular spaces? https://www.fileformat.info/info/unicode/char/00A0/index.htm

Maybe we can use str_replace(["\xc2\xa0", "\u00a0", " "], '', $body)

I can also create a pull request to fix this if you like.

dennzo avatar Jul 11 '23 08:07 dennzo