Simplify / ibantools

IBANTools is TypeScript/JavaScript library for validation, creation and extraction of IBAN, BBAN and BIC/SWIFT numbers.
http://simplify.github.io/ibantools
Other
204 stars 41 forks source link

isValidBIC doesn't check for null/undefined value - throws error instead #28

Closed ishando closed 4 years ago

ishando commented 4 years ago

Expected behavior

using isValidBIC as a validator with vuelidate should not throw error for an empty form

Actual behavior

[Vue warn]: Error in render: "TypeError: bic is undefined"

Steps to reproduce the behavior

i created two custom validators for IBAN and BIC:

const validAccountNumber = helpers.withParams({type: 'validValue'}, (value) => isNaN(value) ? isValidIBAN(value) : true)
const validBankIdentifier = helpers.withParams({type: 'validValue'}, (value) => isNaN(value) ? isValidBIC(value) : true)

and set them as validators on the form

      form: {
        AccountNumber: { required, alphaNum, validAccountNumber },
        BankNumber: { required, alphaNum, validBankIdentifier },

with just the iban validator in place all works fine, but when I add the BIC validator I get the above error when creating a new form

I suspect the difference in behaviour is due to the isValidBIC function not checking for null/undefined values whereas isValidIBAN does

Simplify commented 4 years ago

@ishando Issue has been fixed and new version (3.2.0) is added into npm registry. Sorry that it took me so long to address this.