Gathering detailed insights and metrics for ngx-iban-validator
Gathering detailed insights and metrics for ngx-iban-validator
Gathering detailed insights and metrics for ngx-iban-validator
Gathering detailed insights and metrics for ngx-iban-validator
IBAN Validator for your reactive Angular forms, comes without any dependencies and can be used even outside of Angular as standalone function in any JS project. It can perform format, digit and length IBAN validations.
npm install ngx-iban-validator
Typescript
Module System
Node Version
NPM Version
78.7
Supply Chain
99.5
Quality
76.8
Maintenance
100
Vulnerability
100
License
TypeScript (99.18%)
JavaScript (0.82%)
Total Downloads
196,087
Last Day
306
Last Week
2,422
Last Month
10,048
Last Year
89,422
3 Stars
27 Commits
2 Forks
1 Watchers
2 Branches
3 Contributors
Updated on Nov 22, 2024
Latest Version
1.2.2
Package Id
ngx-iban-validator@1.2.2
Unpacked Size
58.05 kB
Size
9.74 kB
File Count
13
NPM Version
10.8.2
Node Version
20.12.2
Published on
Aug 07, 2024
Cumulative downloads
Total Downloads
Last Day
-26.3%
306
Compared to previous day
Last Week
-2%
2,422
Compared to previous week
Last Month
23.6%
10,048
Compared to previous month
Last Year
26.4%
89,422
Compared to previous year
4
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 112 countries are supported.
1npm install ngx-iban-validator --save
You can use validateIBAN function independently from any forms.
Value can be passed as part of object in this case validation flow will be the same as for form validation:
If IBAN is valid as result of validation null is returned.
If IBAN is invalid and some of the checks fail IBANValidationResult object is returned containing more info about error.
1const ibanIsInvalid = 2 validateIBAN({ 3 value: "AL35202111090000000001234567", 4 }) !== null;
Value can be passed as a string:
1const ibanIsInvalid = validateIBAN("AL35202111090000000001234567").ibanInvalid;
1const ibanValidator = require("ngx-iban-validator"); 2const ibanIsInvalid = ibanValidator.validateIBAN( 3 "BA393385804800211234" 4).ibanInvalid;
If IBAN is valid as result of validation null is returned.
If IBAN is invalid and some of the checks fail IBANValidationResult object is returned containing more info about error.
1export interface IBANValidationResult { 2 ibanInvalid: boolean; 3 error: IBANError; 4} 5 6export interface IBANError { 7 countryUnsupported: boolean; 8 codeLengthInvalid: boolean; 9 patternInvalid: boolean; 10}
Error object contains more details about validation error. You can display errors easily as with any other validator.
Import validateIBAN function from ngx-iban-validator package into your component file. Add validateIBAN to your form validators array.
1import { Component, inject } from "@angular/core"; 2import { NgIf } from "@angular/common"; 3import { 4 FormBuilder, 5 FormGroup, 6 ReactiveFormsModule, 7 Validators, 8} from "@angular/forms"; 9 10import { validateIBAN } from "ngx-iban-validator"; 11 12@Component({ 13 selector: "my-app", 14 standalone: true, 15 imports: [NgIf, ReactiveFormsModule], 16 template: ` 17 <div class="page"> 18 <form [formGroup]="ibanForm" (ngSubmit)="submit(ibanForm)"> 19 <h2>NGX IBAN Validator</h2> 20 <div> 21 <input type="text" formControlName="iban" placeholder="Enter IBAN" /> 22 <button [disabled]="ibanForm.invalid">Submit</button> 23 </div> 24 <div class="validation-errors"> 25 <small 26 *ngIf=" 27 ibanForm.get('iban')?.errors && ibanForm.get('iban')?.errors?.['ibanInvalid'] 28 " 29 > 30 <span 31 *ngIf="ibanForm.get('iban')?.errors?.['error']['countryUnsupported']" 32 > 33 Country not supported 34 </span> 35 <span 36 *ngIf="ibanForm.get('iban')?.errors?.['error']['codeLengthInvalid']" 37 > 38 IBAN Code length is invalid 39 </span> 40 <span 41 *ngIf="ibanForm.get('iban')?.errors?.['error']['patternInvalid']" 42 > 43 IBAN Code pattern is invalid 44 </span> 45 </small> 46 </div> 47 </form> 48 </div> 49 `, 50 styles: [ 51 ` 52 .page { 53 height: 100vh; 54 display: flex; 55 justify-content: center; 56 align-items: center; 57 } 58 h2 { 59 text-align: center; 60 } 61 form { 62 padding: 20px; 63 } 64 input { 65 padding: 10px; 66 } 67 button { 68 padding: 10px; 69 } 70 .validation-errors { 71 color: red; 72 } 73 `, 74 ], 75}) 76export class App { 77 formBuilder = inject(FormBuilder); 78 ibanForm = this.formBuilder.group({ 79 iban: [null, [Validators.required, validateIBAN]], 80 }); 81 submit(form: FormGroup) { 82 const { valid, value } = form; 83 const { iban } = value; 84 if (valid) { 85 alert(`IBAN: ${iban}, is valid!`); 86 } 87 } 88}
1import { useState } from "react"; 2import { 3 IBANError, 4 IBANValidationResult, 5 validateIBAN, 6} from "ngx-iban-validator/dist/iban.validator"; 7 8import "./App.css"; 9 10function App() { 11 const [error, setError] = useState<IBANError | null>(null); 12 13 const validate = (iban: string): boolean => { 14 const validation = validateIBAN({ 15 value: iban, 16 }); 17 if (validation) { 18 const { ibanInvalid, error }: IBANValidationResult = validation; 19 if (ibanInvalid) { 20 setError(error); 21 return false; 22 } else { 23 setError(null); 24 return true; 25 } 26 } else { 27 setError(null); 28 return true; 29 } 30 }; 31 32 const handleSubmit = (event: React.FormEvent<HTMLFormElement>) => { 33 event.preventDefault(); 34 const formData = new FormData(event.currentTarget); 35 const iban = formData.get("iban") as string; 36 const validation = validate(iban); 37 if (validation) { 38 alert("IBAN is valid"); 39 } else { 40 alert("IBAN is not valid"); 41 } 42 }; 43 44 const handleIbanChanged = (event: React.ChangeEvent<HTMLInputElement>) => { 45 const { value } = event.target; 46 validate(value); 47 }; 48 49 return ( 50 <div className="page"> 51 <form onSubmit={handleSubmit}> 52 <h2>NGX IBAN Validator</h2> 53 <div> 54 <input 55 type="text" 56 name="iban" 57 placeholder="Enter IBAN" 58 onChange={handleIbanChanged} 59 /> 60 <button>Submit</button> 61 </div> 62 <div className="validation-errors"> 63 <small hidden={!error}> 64 <span hidden={!error?.countryUnsupported}> 65 Country not supported 66 </span> 67 <span hidden={!error?.codeLengthInvalid}> 68 IBAN Code length is invalid 69 </span> 70 <span hidden={!error?.patternInvalid}> 71 IBAN Code pattern is invalid 72 </span> 73 </small> 74 </div> 75 </form> 76 </div> 77 ); 78} 79 80export default App;
Check demo applications for usage examples:
No | Country | Country Code | Length |
---|---|---|---|
1 | Albania | AL | 28 |
2 | Algeria | DZ | 26 |
3 | Andorra | AD | 24 |
4 | Angola | AO | 25 |
5 | Austria | AT | 20 |
6 | Azerbaijan | AZ | 28 |
7 | Bahrain | BH | 22 |
8 | Belarus | BY | 28 |
9 | Belgium | BE | 16 |
10 | Benin | BJ | 28 |
11 | Bosnia and Herzegovina | BA | 20 |
12 | Brazil | BR | 29 |
13 | Bulgaria | BG | 22 |
14 | Burundi | BI | 27 |
15 | Burkina Faso | BF | 28 |
16 | Cameroon | CM | 27 |
17 | Cape Verde | CV | 25 |
18 | Central African Republic | CF | 27 |
19 | Chad | TD | 27 |
20 | Comoros | KM | 27 |
21 | Congo | CG | 27 |
22 | Costa Rica | CR | 22 |
23 | Croatia | HR | 21 |
24 | Cyprus | CY | 28 |
25 | Czech Republic | CZ | 24 |
26 | Denmark | DK | 18 |
27 | Djibouti | DJ | 27 |
28 | Dominican Republic | DO | 28 |
29 | Egypt | EG | 29 |
30 | El Salvador | SV | 28 |
32 | Equatorial Guinea | GQ | 27 |
33 | Estonia | EE | 20 |
34 | Falkland Islands | FK | 18 |
35 | Faroe Islands | FO | 18 |
36 | Finland | FI | 18 |
37 | France | FR | 27 |
38 | Gabon | GA | 27 |
39 | Georgia | GE | 22 |
40 | Germany | DE | 22 |
41 | Gibraltar | GI | 23 |
42 | Greece | GR | 27 |
43 | Greenland | GL | 18 |
44 | Guatemala | GT | 28 |
45 | Guinea-Bissau | GW | 25 |
46 | Vatican | VA | 22 |
47 | Honduras | HN | 28 |
48 | Hungary | HU | 28 |
49 | Iceland | IS | 26 |
50 | Iran | IR | 26 |
51 | Iraq | IQ | 23 |
52 | Ireland | IE | 22 |
53 | Israel | IL | 23 |
54 | Italy | IT | 27 |
55 | Ivory Coast | CI | 28 |
56 | Jordan | JO | 30 |
57 | Kazakhstan | KZ | 20 |
58 | Kosovo | XK | 20 |
59 | Kuwait | KW | 30 |
60 | Latvia | LV | 21 |
61 | Lebanon | LB | 28 |
62 | Libya | LY | 25 |
63 | Liechtenstein | LI | 21 |
64 | Lithuania | LT | 20 |
65 | Luxembourg | LU | 20 |
66 | Madagascar | MG | 27 |
67 | Mali | ML | 28 |
68 | Malta | MT | 31 |
69 | Mauritania | MR | 27 |
70 | Mauritius | MU | 30 |
71 | Moldova | MD | 24 |
72 | Monaco | MC | 27 |
73 | Mongolia | MN | 20 |
74 | Montenegro | ME | 22 |
75 | Morocco | MA | 28 |
76 | Mozambique | MZ | 25 |
77 | Netherlands | NL | 18 |
78 | Nicaragua | NI | 28 |
79 | Niger | NE | 28 |
80 | North Macedonia | MK | 19 |
81 | Norway | NO | 15 |
82 | Pakistan | PK | 24 |
83 | Palestine | PS | 29 |
84 | Poland | PL | 28 |
85 | Portugal | PT | 25 |
86 | Qatar | QA | 29 |
87 | Romania | RO | 24 |
88 | Russia | RU | 33 |
89 | Saint Lucia | LC | 32 |
90 | San Marino | SM | 27 |
91 | Sao Tome and Principe | ST | 25 |
92 | Saudi Arabia | SA | 24 |
93 | Senegal | SN | 28 |
94 | Serbia | RS | 22 |
95 | Seychelles | SC | 31 |
96 | Slovak Republic | SK | 24 |
97 | Slovenia | SI | 19 |
98 | Somalia | SO | 23 |
99 | Spain | ES | 24 |
100 | Sudan | SD | 18 |
101 | Sultanate of Oman | OM | 23 |
102 | Sweden | SE | 24 |
103 | Switzerland | CH | 21 |
104 | Timor-Leste | TL | 23 |
105 | Togo | TG | 28 |
106 | Tunisia | TN | 24 |
107 | Turkey | TR | 26 |
108 | Ukraine | UA | 29 |
109 | United Arab Emirates | AE | 23 |
110 | United Kingdom | GB | 22 |
111 | Virgin Islands, British | VG | 24 |
112 | Yemen | YE | 30 |
1npm i
1npm run test
1npx tsc
Added additional pattern validation Added more tests to improve test coverage 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
Avoid Angular warnings for old CommonJS module usage (see https://angular.io/guide/build#configuring-commonjs-dependencies)
Replaced mocha and chai with JEST for tests
Added support for new countries: Vatican, Libya, Sao Tome and Principe, Sudan Updated length for LC Saint Lucia from 30 to 32
Added Tests Added Mocha and Chai for testing
Updated length for CR to 22 - @freddy36
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
6 existing vulnerabilities detected
Details
Reason
Found 2/25 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
license file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-07-14
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More