-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Validator ignores extra characters #35
Comments
At least provide a strict mode and/or warn people that they have to sanitize themself and how to do it. |
I'll have a look, but you're right, this should obviously be marked as invalid. |
It shouldn't even convert input to uppercase. We had a problem when Sk2683300000002700890226 passed the validation of this library and then bank transfer failed because of "Sk" instead of "SK" |
Right now the correct way to use isValid seems to be: if(IBAN.isValid(input){
model = IBAN.electronicFormat(input);
view = IBAN.printFormat(input);
} This makes sense when dealing with user input as they are entering it but less so when merely validating if the input adheres to a format. So I think the validation should be exports.isValid = function(input){
if (!isString(input)){
return false;
}
var iban = electronicFormat(input);
if(iban !==input ){
return false;
}
var countryStructure = countries[iban.slice(0,2)];
return !!countryStructure && countryStructure.isValid(iban);
}; And then we might add a parse function to facilitate the other use case exports.parse = function(input){
var iban = electronicFormat(input);
if(isValid(iban)){
return iban;
}
return undefined;
}; So we can do var iban = IBAN.parse(input);
if(iban){
model = iban;
view = IBAN.printFormat(input);
} |
Hey guys, thanks for your feedback. For your use case, I think this lib can also help, though: var strictlyValid = (input === IBAN.electronicFormat(input)) && IBAN.isValid(input); That said, a bank that drops a payment because the IBAN was not all uppercase is 😱 |
This one caught us by surprise as the naming is confusing. It's not just documentation that should be improved. Instead of ‘isValid‘ it would be clearer if ‘containsIBAN‘ or similar would be used. Generally I feel that a isValid should be strict by default and lax alternatives should be named differently. |
Whats the status of this issue? |
The only thing on which there is a consensus is that the documentation could stand some improvement but so far no one has bothered to do so yet. I submitted mmjmanders/ng-iban#19 a while ago and that has been accepted and merged. As far as I am concerned the problem has been resolved. |
I think maybe a IBAN.clean(iban) could be helpful because although spaces and some other strengess are allowed in the specs, most banks does not validate them. clean() should make uppercase remove all that is not A-Z 0-9 |
For me it seems that the validator is too flexible. It says that this is valid:
FI@ +425*000*151=0 == #000$ 0° 23€€€!!!!!
And altho technically it does contain valid numbers for an fictional IBAN number, that gibberish in my mind should not count as a valid IBAN.
The text was updated successfully, but these errors were encountered: