Additional data in Validator parameters / attributes

I need to create a validator for IBAN/NRB numbers, which apart from just validating the number checks which bank the account belongs to and returns such information to the component.

I only need to accept certain bank account numbers, but I want to show the name of the bank even if the validation is negative.

I know that there are special structures for such additional data in Validators, namely “attributes” and “parameters”, but I’m not quite sure how to use them.

Any help will be appreciated.

As you mentioned, you should use a construct containing parameters, which looks like this:

return [{
        'key': 'wrongBankName',
        'parameters': [bankName, 'We do not support this bank: {0}']
    }];

We return an object containing the validation content key and the parameters property in which we specify the variables that we want to use in the error message.
Referencing a variable is done by using {number}, where number is the number of the variable iterating from 0.
Remember to apply it on the application in the Tłumaczenia tab

image

This is a ScriptCode implementation. Can I do the same in a Charon service?

IBAN validator is simple and does not require high-code.
The best way is to do it in ScriptCode.

The thing is though, that I’m considering having a config file mapping bank numbers to their attributes.
Considering this - is it still possible in ScriptCode?