class-validator icon indicating copy to clipboard operation
class-validator copied to clipboard

feature: Add `IsIBANOptions` to `IsIBAN` decorator

Open LiiaMenke opened this issue 6 months ago • 1 comments

Description

validator.js offers options for the isIBAN validation to pass in a whitelist and blacklist of country codes. This is really helpful when validating IBANs where only specific countries should be accepted, e.g. only IBANs from the EU.

Proposed solution

Add the options as an argument to the IsIBAN decorator as well as the isIBAN function and pass it along to validator.js.

I will open a PR for this, the feature itself is trivial, the only thing I am unsure about is the following: It seems to be standard to have any options for the validation itself be the first argument and ValidationOptions be the second argument. Keeping this up would be a breaking change though. So if anyone has input on what would be the preferred way to handle this, I'd appreciate it.

LiiaMenke avatar Jun 17 '25 15:06 LiiaMenke

You're right, that is a problem with the current standard. We can't do method overloading to solve this, so the only options are to do some rather ugly (not very Typescript-friendly) dynamic arguments or do a breaking change. I'm sure this must have been a discussion some time in the past. Have you searched in the repo to find previous discussions on the topic?

I'm inclined to think that we should change the order of the options such that ValidationOptions always comes first. That way we can add more arguments down the line without breaking anything.

braaar avatar Jun 30 '25 09:06 braaar