Skip to content

Commit dcd7719

Browse files
gerjanvangeestMikhail Bashkirov
authored andcommitted
fix(input-iban): allow formatting empty IBAN model values
1 parent 03264b3 commit dcd7719

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

packages/input-iban/src/formatters.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,9 @@ import { friendlyFormatIBAN } from '@bundled-es-modules/ibantools';
77
* @return {string} formatted value
88
*/
99
export function formatIBAN(modelValue) {
10+
// defensive code because of ibantools
11+
if (modelValue === '') {
12+
return '';
13+
}
1014
return friendlyFormatIBAN(modelValue);
1115
}

packages/input-iban/test/formatters.test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,8 @@ describe('formatIBAN', () => {
66
it('formats the IBAN', () => {
77
expect(formatIBAN('NL17INGB0002822608')).to.equal('NL17 INGB 0002 8226 08');
88
});
9+
10+
it('returns `` if no value is given', () => {
11+
expect(formatIBAN('')).to.equal('');
12+
});
913
});

0 commit comments

Comments
 (0)