ngx-iban-validator 1.2.2 → 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +109 -0
- package/LICENCE +21 -0
- package/README.md +46 -240
- package/biome.jsonc +86 -0
- package/dist/LICENCE +21 -0
- package/dist/README.md +46 -240
- package/dist/code-lengths.d.ts +1 -1
- package/dist/code-lengths.js +1 -1
- package/dist/iban.validator.d.ts +3 -11
- package/dist/iban.validator.js +10 -10
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -1
- package/dist/types.d.ts +9 -0
- package/package.json +24 -11
- package/.vscode/settings.json +0 -3
- package/dist/iban.validator.spec.js +0 -386
- /package/dist/{iban.validator.spec.d.ts → types.js} +0 -0
package/dist/README.md
CHANGED
|
@@ -2,30 +2,49 @@
|
|
|
2
2
|
|
|
3
3
|
IBAN Validator for your web application forms ([Angular](#angular), [React](#react), Vue, ...), comes without any dependencies and can be used as a standalone function in any JS project. It can perform format, digit and length IBAN validations. Currently [112 countries](#supported-countries) are supported.
|
|
4
4
|
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Zero external dependencies
|
|
8
|
+
- Works in Node.js and all modern browsers
|
|
9
|
+
- Works with TypeScript and plain JS
|
|
10
|
+
|
|
5
11
|
## Content
|
|
6
12
|
|
|
7
13
|
- [Install](#install)
|
|
8
|
-
- [
|
|
14
|
+
- [Basic usage](#basic-usage)
|
|
9
15
|
- [Error Response](#error-response)
|
|
10
16
|
- [Use as a form validator](#use-as-a-form-validator)
|
|
11
17
|
- [Angular example](#angular)
|
|
12
18
|
- [React example](#react)
|
|
13
19
|
- [Demo Applications](#demo)
|
|
14
|
-
- [Supported countries](
|
|
15
|
-
- [
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
- [Changelog](#changelog)
|
|
20
|
+
- [Supported countries](https://github.com/SKaDiZZ/ngx-iban-validator/blob/master/SUPPORTED_COUNTRIES.md)
|
|
21
|
+
- [Changelog](https://github.com/SKaDiZZ/ngx-iban-validator/blob/master/CHANGELOG.md)
|
|
22
|
+
- [Contributing](https://github.com/SKaDiZZ/ngx-iban-validator/blob/master/CONTRIBUTING.md)
|
|
23
|
+
- [Code of Conduct](https://github.com/SKaDiZZ/ngx-iban-validator/blob/master/CODE_OF_CONDUCT.md)
|
|
24
|
+
- [License](https://github.com/SKaDiZZ/ngx-iban-validator/blob/master/LICENCE)
|
|
20
25
|
- [Read more](#read-more)
|
|
21
26
|
|
|
22
27
|
## Install
|
|
23
28
|
|
|
29
|
+
**npm**
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npm i ngx-iban-validator
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
**pnpm**
|
|
36
|
+
|
|
24
37
|
```bash
|
|
25
|
-
|
|
38
|
+
pnpm add ngx-iban-validator
|
|
26
39
|
```
|
|
27
40
|
|
|
28
|
-
|
|
41
|
+
**yarn**
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
yarn add ngx-iban-validator
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Basic usage
|
|
29
48
|
|
|
30
49
|
You can use validateIBAN function independently from any forms.
|
|
31
50
|
|
|
@@ -38,7 +57,7 @@ Value can be passed as part of object in this case validation flow will be the s
|
|
|
38
57
|
```typescript
|
|
39
58
|
const ibanIsInvalid =
|
|
40
59
|
validateIBAN({
|
|
41
|
-
value:
|
|
60
|
+
value: 'AL35202111090000000001234567',
|
|
42
61
|
}) !== null;
|
|
43
62
|
```
|
|
44
63
|
|
|
@@ -53,9 +72,9 @@ const ibanIsInvalid = validateIBAN("AL35202111090000000001234567").ibanInvalid;
|
|
|
53
72
|
### NodeJS
|
|
54
73
|
|
|
55
74
|
```javascript
|
|
56
|
-
const ibanValidator = require(
|
|
75
|
+
const ibanValidator = require('ngx-iban-validator');
|
|
57
76
|
const ibanIsInvalid = ibanValidator.validateIBAN(
|
|
58
|
-
|
|
77
|
+
'BA393385804800211234'
|
|
59
78
|
).ibanInvalid;
|
|
60
79
|
```
|
|
61
80
|
|
|
@@ -68,7 +87,7 @@ const ibanIsInvalid = ibanValidator.validateIBAN(
|
|
|
68
87
|
```typescript
|
|
69
88
|
export interface IBANValidationResult {
|
|
70
89
|
ibanInvalid: boolean;
|
|
71
|
-
error: IBANError;
|
|
90
|
+
error: IBANError | null;
|
|
72
91
|
}
|
|
73
92
|
|
|
74
93
|
export interface IBANError {
|
|
@@ -87,19 +106,19 @@ Error object contains more details about validation error. You can display error
|
|
|
87
106
|
Import validateIBAN function from ngx-iban-validator package into your component file. Add validateIBAN to your form validators array.
|
|
88
107
|
|
|
89
108
|
```ts
|
|
90
|
-
import { Component, inject } from
|
|
91
|
-
import { NgIf } from
|
|
109
|
+
import { Component, inject } from '@angular/core';
|
|
110
|
+
import { NgIf } from '@angular/common';
|
|
92
111
|
import {
|
|
93
112
|
FormBuilder,
|
|
94
113
|
FormGroup,
|
|
95
114
|
ReactiveFormsModule,
|
|
96
115
|
Validators,
|
|
97
|
-
} from
|
|
116
|
+
} from '@angular/forms';
|
|
98
117
|
|
|
99
|
-
import { validateIBAN } from
|
|
118
|
+
import { validateIBAN } from 'ngx-iban-validator';
|
|
100
119
|
|
|
101
120
|
@Component({
|
|
102
|
-
selector:
|
|
121
|
+
selector: 'my-app',
|
|
103
122
|
standalone: true,
|
|
104
123
|
imports: [NgIf, ReactiveFormsModule],
|
|
105
124
|
template: `
|
|
@@ -180,14 +199,15 @@ export class App {
|
|
|
180
199
|
### React
|
|
181
200
|
|
|
182
201
|
```tsx
|
|
183
|
-
import { useState } from
|
|
202
|
+
import { useState } from 'react';
|
|
203
|
+
|
|
184
204
|
import {
|
|
185
|
-
IBANError,
|
|
186
|
-
IBANValidationResult,
|
|
205
|
+
type IBANError,
|
|
206
|
+
type IBANValidationResult,
|
|
187
207
|
validateIBAN,
|
|
188
|
-
} from
|
|
208
|
+
} from 'ngx-iban-validator';
|
|
189
209
|
|
|
190
|
-
import
|
|
210
|
+
import './App.css';
|
|
191
211
|
|
|
192
212
|
function App() {
|
|
193
213
|
const [error, setError] = useState<IBANError | null>(null);
|
|
@@ -214,12 +234,12 @@ function App() {
|
|
|
214
234
|
const handleSubmit = (event: React.FormEvent<HTMLFormElement>) => {
|
|
215
235
|
event.preventDefault();
|
|
216
236
|
const formData = new FormData(event.currentTarget);
|
|
217
|
-
const iban = formData.get(
|
|
237
|
+
const iban = formData.get('iban') as string;
|
|
218
238
|
const validation = validate(iban);
|
|
219
239
|
if (validation) {
|
|
220
|
-
alert(
|
|
240
|
+
alert(`IBAN: ${iban}, is valid!`);
|
|
221
241
|
} else {
|
|
222
|
-
alert(
|
|
242
|
+
alert(`IBAN: ${iban}, is invalid!`);
|
|
223
243
|
}
|
|
224
244
|
};
|
|
225
245
|
|
|
@@ -269,220 +289,6 @@ Check demo applications for usage examples:
|
|
|
269
289
|
- [Angular - Demo Application](https://stackblitz.com/edit/stackblitz-starters-d6zn46?file=src%2Fmain.ts)
|
|
270
290
|
- [React - Demo Application](https://stackblitz.com/edit/vitejs-vite-mhe5gj?file=src%2FApp.tsx)
|
|
271
291
|
|
|
272
|
-
###
|
|
273
|
-
|
|
274
|
-
# Supported countries
|
|
275
|
-
|
|
276
|
-
####
|
|
277
|
-
|
|
278
|
-
<details>
|
|
279
|
-
<summary>
|
|
280
|
-
Click here to expand list of supported countries
|
|
281
|
-
</summary>
|
|
282
|
-
|
|
283
|
-
| No | Country | Country Code | Length |
|
|
284
|
-
| --- | ------------------------ | ------------ | ------ |
|
|
285
|
-
| 1 | Albania | AL | 28 |
|
|
286
|
-
| 2 | Algeria | DZ | 26 |
|
|
287
|
-
| 3 | Andorra | AD | 24 |
|
|
288
|
-
| 4 | Angola | AO | 25 |
|
|
289
|
-
| 5 | Austria | AT | 20 |
|
|
290
|
-
| 6 | Azerbaijan | AZ | 28 |
|
|
291
|
-
| 7 | Bahrain | BH | 22 |
|
|
292
|
-
| 8 | Belarus | BY | 28 |
|
|
293
|
-
| 9 | Belgium | BE | 16 |
|
|
294
|
-
| 10 | Benin | BJ | 28 |
|
|
295
|
-
| 11 | Bosnia and Herzegovina | BA | 20 |
|
|
296
|
-
| 12 | Brazil | BR | 29 |
|
|
297
|
-
| 13 | Bulgaria | BG | 22 |
|
|
298
|
-
| 14 | Burundi | BI | 27 |
|
|
299
|
-
| 15 | Burkina Faso | BF | 28 |
|
|
300
|
-
| 16 | Cameroon | CM | 27 |
|
|
301
|
-
| 17 | Cape Verde | CV | 25 |
|
|
302
|
-
| 18 | Central African Republic | CF | 27 |
|
|
303
|
-
| 19 | Chad | TD | 27 |
|
|
304
|
-
| 20 | Comoros | KM | 27 |
|
|
305
|
-
| 21 | Congo | CG | 27 |
|
|
306
|
-
| 22 | Costa Rica | CR | 22 |
|
|
307
|
-
| 23 | Croatia | HR | 21 |
|
|
308
|
-
| 24 | Cyprus | CY | 28 |
|
|
309
|
-
| 25 | Czech Republic | CZ | 24 |
|
|
310
|
-
| 26 | Denmark | DK | 18 |
|
|
311
|
-
| 27 | Djibouti | DJ | 27 |
|
|
312
|
-
| 28 | Dominican Republic | DO | 28 |
|
|
313
|
-
| 29 | Egypt | EG | 29 |
|
|
314
|
-
| 30 | El Salvador | SV | 28 |
|
|
315
|
-
| 32 | Equatorial Guinea | GQ | 27 |
|
|
316
|
-
| 33 | Estonia | EE | 20 |
|
|
317
|
-
| 34 | Falkland Islands | FK | 18 |
|
|
318
|
-
| 35 | Faroe Islands | FO | 18 |
|
|
319
|
-
| 36 | Finland | FI | 18 |
|
|
320
|
-
| 37 | France | FR | 27 |
|
|
321
|
-
| 38 | Gabon | GA | 27 |
|
|
322
|
-
| 39 | Georgia | GE | 22 |
|
|
323
|
-
| 40 | Germany | DE | 22 |
|
|
324
|
-
| 41 | Gibraltar | GI | 23 |
|
|
325
|
-
| 42 | Greece | GR | 27 |
|
|
326
|
-
| 43 | Greenland | GL | 18 |
|
|
327
|
-
| 44 | Guatemala | GT | 28 |
|
|
328
|
-
| 45 | Guinea-Bissau | GW | 25 |
|
|
329
|
-
| 46 | Vatican | VA | 22 |
|
|
330
|
-
| 47 | Honduras | HN | 28 |
|
|
331
|
-
| 48 | Hungary | HU | 28 |
|
|
332
|
-
| 49 | Iceland | IS | 26 |
|
|
333
|
-
| 50 | Iran | IR | 26 |
|
|
334
|
-
| 51 | Iraq | IQ | 23 |
|
|
335
|
-
| 52 | Ireland | IE | 22 |
|
|
336
|
-
| 53 | Israel | IL | 23 |
|
|
337
|
-
| 54 | Italy | IT | 27 |
|
|
338
|
-
| 55 | Ivory Coast | CI | 28 |
|
|
339
|
-
| 56 | Jordan | JO | 30 |
|
|
340
|
-
| 57 | Kazakhstan | KZ | 20 |
|
|
341
|
-
| 58 | Kosovo | XK | 20 |
|
|
342
|
-
| 59 | Kuwait | KW | 30 |
|
|
343
|
-
| 60 | Latvia | LV | 21 |
|
|
344
|
-
| 61 | Lebanon | LB | 28 |
|
|
345
|
-
| 62 | Libya | LY | 25 |
|
|
346
|
-
| 63 | Liechtenstein | LI | 21 |
|
|
347
|
-
| 64 | Lithuania | LT | 20 |
|
|
348
|
-
| 65 | Luxembourg | LU | 20 |
|
|
349
|
-
| 66 | Madagascar | MG | 27 |
|
|
350
|
-
| 67 | Mali | ML | 28 |
|
|
351
|
-
| 68 | Malta | MT | 31 |
|
|
352
|
-
| 69 | Mauritania | MR | 27 |
|
|
353
|
-
| 70 | Mauritius | MU | 30 |
|
|
354
|
-
| 71 | Moldova | MD | 24 |
|
|
355
|
-
| 72 | Monaco | MC | 27 |
|
|
356
|
-
| 73 | Mongolia | MN | 20 |
|
|
357
|
-
| 74 | Montenegro | ME | 22 |
|
|
358
|
-
| 75 | Morocco | MA | 28 |
|
|
359
|
-
| 76 | Mozambique | MZ | 25 |
|
|
360
|
-
| 77 | Netherlands | NL | 18 |
|
|
361
|
-
| 78 | Nicaragua | NI | 28 |
|
|
362
|
-
| 79 | Niger | NE | 28 |
|
|
363
|
-
| 80 | North Macedonia | MK | 19 |
|
|
364
|
-
| 81 | Norway | NO | 15 |
|
|
365
|
-
| 82 | Pakistan | PK | 24 |
|
|
366
|
-
| 83 | Palestine | PS | 29 |
|
|
367
|
-
| 84 | Poland | PL | 28 |
|
|
368
|
-
| 85 | Portugal | PT | 25 |
|
|
369
|
-
| 86 | Qatar | QA | 29 |
|
|
370
|
-
| 87 | Romania | RO | 24 |
|
|
371
|
-
| 88 | Russia | RU | 33 |
|
|
372
|
-
| 89 | Saint Lucia | LC | 32 |
|
|
373
|
-
| 90 | San Marino | SM | 27 |
|
|
374
|
-
| 91 | Sao Tome and Principe | ST | 25 |
|
|
375
|
-
| 92 | Saudi Arabia | SA | 24 |
|
|
376
|
-
| 93 | Senegal | SN | 28 |
|
|
377
|
-
| 94 | Serbia | RS | 22 |
|
|
378
|
-
| 95 | Seychelles | SC | 31 |
|
|
379
|
-
| 96 | Slovak Republic | SK | 24 |
|
|
380
|
-
| 97 | Slovenia | SI | 19 |
|
|
381
|
-
| 98 | Somalia | SO | 23 |
|
|
382
|
-
| 99 | Spain | ES | 24 |
|
|
383
|
-
| 100 | Sudan | SD | 18 |
|
|
384
|
-
| 101 | Sultanate of Oman | OM | 23 |
|
|
385
|
-
| 102 | Sweden | SE | 24 |
|
|
386
|
-
| 103 | Switzerland | CH | 21 |
|
|
387
|
-
| 104 | Timor-Leste | TL | 23 |
|
|
388
|
-
| 105 | Togo | TG | 28 |
|
|
389
|
-
| 106 | Tunisia | TN | 24 |
|
|
390
|
-
| 107 | Turkey | TR | 26 |
|
|
391
|
-
| 108 | Ukraine | UA | 29 |
|
|
392
|
-
| 109 | United Arab Emirates | AE | 23 |
|
|
393
|
-
| 110 | United Kingdom | GB | 22 |
|
|
394
|
-
| 111 | Virgin Islands, British | VG | 24 |
|
|
395
|
-
| 112 | Yemen | YE | 30 |
|
|
396
|
-
|
|
397
|
-
</details>
|
|
398
|
-
|
|
399
|
-
###
|
|
400
|
-
|
|
401
|
-
# Development
|
|
402
|
-
|
|
403
|
-
## Install dependencies
|
|
404
|
-
|
|
405
|
-
```bash
|
|
406
|
-
npm i
|
|
407
|
-
```
|
|
408
|
-
|
|
409
|
-
## Test
|
|
410
|
-
|
|
411
|
-
```bash
|
|
412
|
-
npm run test
|
|
413
|
-
```
|
|
414
|
-
|
|
415
|
-
## Build
|
|
416
|
-
|
|
417
|
-
```bash
|
|
418
|
-
npx tsc
|
|
419
|
-
```
|
|
420
|
-
|
|
421
|
-
# Changelog
|
|
422
|
-
|
|
423
|
-
## v 1.2.2
|
|
424
|
-
|
|
425
|
-
- Added Support for Yemen
|
|
426
|
-
- Updated validate function to not return countryUnsupported error if input is for example 'YE' country is supported but length is invalid so instead codeLengthInvalid error will be returned
|
|
427
|
-
- Updated tests and docs
|
|
428
|
-
|
|
429
|
-
## v 1.2.1
|
|
430
|
-
|
|
431
|
-
- Updated Burundi (BI) length 16 -> 27
|
|
432
|
-
- Updated Nicaragua (NI) length 32 -> 28
|
|
433
|
-
|
|
434
|
-
## v 1.2.0
|
|
435
|
-
|
|
436
|
-
- Updated documentation
|
|
437
|
-
|
|
438
|
-
## v 1.1.9
|
|
439
|
-
|
|
440
|
-
- Added support for Sultanate of Oman
|
|
441
|
-
|
|
442
|
-
## v 1.1.8
|
|
443
|
-
|
|
444
|
-
- Added support for Falkland Islands
|
|
445
|
-
|
|
446
|
-
## v 1.1.7
|
|
447
|
-
|
|
448
|
-
- Added support for Djibouti and Somalia
|
|
449
|
-
|
|
450
|
-
## v 1.1.6
|
|
451
|
-
|
|
452
|
-
- Updated error display logic
|
|
453
|
-
- Value can be passed directly as a string or part of the object.
|
|
454
|
-
- If value is passed as a part of object same logic as for form validation is applied:
|
|
455
|
-
- If IBAN is valid as result of validation **null** is returned.
|
|
456
|
-
- If IBAN is invalid and some of the checks fail IBANValidationResult object is returned containing more info about error.
|
|
457
|
-
- If value is passed as a string:
|
|
458
|
-
- For valid and invalid IBAN IBANValidationResult object is returned.
|
|
459
|
-
- Return null for valid form field to fix issue with disabling | enabling buttons
|
|
460
|
-
- Thnx to @pramodEE for reporting the issue
|
|
461
|
-
|
|
462
|
-
## v 1.1.5
|
|
463
|
-
|
|
464
|
-
Added additional pattern validation
|
|
465
|
-
Added more tests to improve test coverage
|
|
466
|
-
Added support for new countries: Algeria, Angola, Benin, Burkina Faso, Burundi, Cameroon, Cape Verde, Central African Republic, Chad, Comoros, Congo, Equatorial Guinea, Gabon, Guinea-Bissau, Honduras, Iran, Ivory Coast, Madagascar, Mali, Mongolia, Morocco, Mozambique, Nicaragua, Niger, Russia, Senegal, Togo
|
|
467
|
-
|
|
468
|
-
## v 1.1.4
|
|
469
|
-
|
|
470
|
-
Avoid Angular warnings for old CommonJS module usage (see https://angular.io/guide/build#configuring-commonjs-dependencies)
|
|
471
|
-
|
|
472
|
-
Replaced mocha and chai with JEST for tests
|
|
473
|
-
|
|
474
|
-
## v 1.1.3
|
|
475
|
-
|
|
476
|
-
Added support for new countries: Vatican, Libya, Sao Tome and Principe, Sudan
|
|
477
|
-
Updated length for LC Saint Lucia from 30 to 32
|
|
478
|
-
|
|
479
|
-
Added Tests
|
|
480
|
-
Added Mocha and Chai for testing
|
|
481
|
-
|
|
482
|
-
## v 1.1.2
|
|
483
|
-
|
|
484
|
-
Updated length for CR to 22 - @freddy36
|
|
485
|
-
|
|
486
292
|
## Read more
|
|
487
293
|
|
|
488
294
|
[IBAN Examples](https://www.iban.com/structure)
|
package/dist/code-lengths.d.ts
CHANGED
package/dist/code-lengths.js
CHANGED
package/dist/iban.validator.d.ts
CHANGED
|
@@ -1,15 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
countryUnsupported: boolean;
|
|
3
|
-
codeLengthInvalid: boolean;
|
|
4
|
-
patternInvalid: boolean;
|
|
5
|
-
}
|
|
6
|
-
export interface IBANValidationResult {
|
|
7
|
-
ibanInvalid: boolean;
|
|
8
|
-
error: IBANError;
|
|
9
|
-
}
|
|
1
|
+
import type { IBANValidationResult } from "./types";
|
|
10
2
|
/**
|
|
11
|
-
*
|
|
12
|
-
* @param {any} control
|
|
3
|
+
* Function to validate an International Bank Account Number (IBAN). It takes a control parameter, which can be either a string or an object with a value property that is a string. The function returns an object with a ibanInvalid property that is true if the IBAN is invalid, and an error object with three properties: countryUnsupported, codeLengthInvalid, and patternInvalid.
|
|
4
|
+
* @param {any} control string | Partial<{value:string}>
|
|
13
5
|
* @returns {any} IBANValidationResult | null
|
|
14
6
|
*/
|
|
15
7
|
export declare function validateIBAN(control: string | Partial<{
|
package/dist/iban.validator.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CODE_LENGTHS } from "./code-lengths";
|
|
2
2
|
function mod97(digital) {
|
|
3
3
|
digital = digital.toString();
|
|
4
|
-
let checksum = digital.slice(0, 2);
|
|
5
|
-
let fragment = "";
|
|
4
|
+
let checksum = parseInt(digital.slice(0, 2), 10);
|
|
6
5
|
for (let offset = 2; offset < digital.length; offset += 7) {
|
|
7
|
-
fragment = checksum + digital.substring(offset, offset + 7);
|
|
6
|
+
const fragment = checksum + digital.substring(offset, offset + 7);
|
|
8
7
|
checksum = parseInt(fragment, 10) % 97;
|
|
9
8
|
}
|
|
10
9
|
return checksum;
|
|
@@ -12,7 +11,7 @@ function mod97(digital) {
|
|
|
12
11
|
function validate(value, control) {
|
|
13
12
|
const iban = value.toUpperCase().replace(/[^A-Z0-9]/g, "");
|
|
14
13
|
const code = iban.match(/^([A-Z]{2})(\d{2})([A-Z\d]+)$/);
|
|
15
|
-
if (code
|
|
14
|
+
if ((code === null || code === void 0 ? void 0 : code[1]) && typeof CODE_LENGTHS[code[1]] === "undefined") {
|
|
16
15
|
return {
|
|
17
16
|
ibanInvalid: true,
|
|
18
17
|
error: {
|
|
@@ -22,7 +21,7 @@ function validate(value, control) {
|
|
|
22
21
|
},
|
|
23
22
|
};
|
|
24
23
|
}
|
|
25
|
-
if (!code || (iban && iban.length !==
|
|
24
|
+
if (!code || (iban && iban.length !== CODE_LENGTHS[code[1]])) {
|
|
26
25
|
return {
|
|
27
26
|
ibanInvalid: true,
|
|
28
27
|
error: {
|
|
@@ -42,7 +41,7 @@ function validate(value, control) {
|
|
|
42
41
|
},
|
|
43
42
|
};
|
|
44
43
|
}
|
|
45
|
-
|
|
44
|
+
const digits = (code[3] + code[1] + code[2]).replace(/[A-Z]/g, (letter) => (letter.charCodeAt(0) - 55).toString());
|
|
46
45
|
return mod97(digits) === 1
|
|
47
46
|
? control
|
|
48
47
|
? null
|
|
@@ -60,8 +59,8 @@ function validate(value, control) {
|
|
|
60
59
|
};
|
|
61
60
|
}
|
|
62
61
|
/**
|
|
63
|
-
*
|
|
64
|
-
* @param {any} control
|
|
62
|
+
* Function to validate an International Bank Account Number (IBAN). It takes a control parameter, which can be either a string or an object with a value property that is a string. The function returns an object with a ibanInvalid property that is true if the IBAN is invalid, and an error object with three properties: countryUnsupported, codeLengthInvalid, and patternInvalid.
|
|
63
|
+
* @param {any} control string | Partial<{value:string}>
|
|
65
64
|
* @returns {any} IBANValidationResult | null
|
|
66
65
|
*/
|
|
67
66
|
export function validateIBAN(control) {
|
|
@@ -69,8 +68,9 @@ export function validateIBAN(control) {
|
|
|
69
68
|
if (typeof control === "string") {
|
|
70
69
|
return validate(control, false);
|
|
71
70
|
}
|
|
72
|
-
if (
|
|
71
|
+
if ("value" in control && control.value) {
|
|
73
72
|
return validate(control.value, true);
|
|
74
73
|
}
|
|
75
74
|
}
|
|
75
|
+
return null;
|
|
76
76
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { validateIBAN } from
|
|
1
|
+
export { validateIBAN } from "./iban.validator";
|
|
2
|
+
export { IBANError, IBANValidationResult } from "./types";
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { validateIBAN } from
|
|
1
|
+
export { validateIBAN } from "./iban.validator";
|
package/dist/types.d.ts
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ngx-iban-validator",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.3",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/SKaDiZZ/ngx-iban-validator.git"
|
|
@@ -11,14 +11,10 @@
|
|
|
11
11
|
"author": {
|
|
12
12
|
"name": "Samir Kahvedzic",
|
|
13
13
|
"email": "akirapowered@gmail.com",
|
|
14
|
-
"url": "https://samirkahvedzic.
|
|
14
|
+
"url": "https://samirkahvedzic.dev"
|
|
15
15
|
},
|
|
16
16
|
"description": "IBAN Validator for your web application forms (Angular, React, Vue, ...), comes without any dependencies and can be used as a standalone function in any JS project. It can perform format, digit and length IBAN validations. Currently 108 countries are supported.",
|
|
17
17
|
"main": "dist/index.js",
|
|
18
|
-
"scripts": {
|
|
19
|
-
"build": "tsc",
|
|
20
|
-
"test": "jest"
|
|
21
|
-
},
|
|
22
18
|
"types": "dist/index.d.ts",
|
|
23
19
|
"keywords": [
|
|
24
20
|
"ngx",
|
|
@@ -35,9 +31,26 @@
|
|
|
35
31
|
],
|
|
36
32
|
"license": "MIT",
|
|
37
33
|
"devDependencies": {
|
|
38
|
-
"@
|
|
39
|
-
"jest": "^
|
|
40
|
-
"
|
|
41
|
-
"
|
|
34
|
+
"@biomejs/biome": "^2.2.2",
|
|
35
|
+
"@types/jest": "^30.0.0",
|
|
36
|
+
"copyfiles": "^2.4.1",
|
|
37
|
+
"jest": "^30.0.5",
|
|
38
|
+
"rimraf": "^6.0.1",
|
|
39
|
+
"ts-jest": "^29.4.1",
|
|
40
|
+
"typescript": "^5.9.2"
|
|
41
|
+
},
|
|
42
|
+
"scripts": {
|
|
43
|
+
"clean": "rimraf dist/",
|
|
44
|
+
"copy-files": "copyfiles README.md LICENCE dist/",
|
|
45
|
+
"fix": "pnpm run format && pnpm run lint",
|
|
46
|
+
"format": "biome check --write .",
|
|
47
|
+
"format:check": "biome check .",
|
|
48
|
+
"lint": "biome lint --write .",
|
|
49
|
+
"lint:check": "biome lint .",
|
|
50
|
+
"preinstall": "npx only-allow pnpm",
|
|
51
|
+
"build": "pnpm clean && pnpm fix && pnpm tsc && pnpm copy-files",
|
|
52
|
+
"test": "jest",
|
|
53
|
+
"release": "pnpm -r publish --no-git-checks --access public",
|
|
54
|
+
"watch": "pnpm tsc --watch"
|
|
42
55
|
}
|
|
43
|
-
}
|
|
56
|
+
}
|
package/.vscode/settings.json
DELETED