ngx-iban-validator 1.1.3 → 1.1.5

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # IBAN Validator
2
2
 
3
- 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. Currently supports 79 countries
3
+ 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. Currently supports 105 countries
4
4
 
5
5
  ## Install
6
6
 
@@ -13,15 +13,15 @@ npm install ngx-iban-validator --save
13
13
  Import validateIBAN function from ngx-iban-validator package into your component file. Add validateIBAN to your form validators array.
14
14
 
15
15
  ```typescript
16
- import { Component, OnInit } from '@angular/core';
17
- import { FormBuilder, FormGroup, Validators } from '@angular/forms';
16
+ import { Component, OnInit } from "@angular/core";
17
+ import { FormBuilder, FormGroup, Validators } from "@angular/forms";
18
18
 
19
- import { validateIBAN } from 'ngx-iban-validator';
19
+ import { validateIBAN } from "ngx-iban-validator";
20
20
 
21
21
  @Component({
22
- selector: 'app-root',
23
- templateUrl: './app.component.html',
24
- styleUrls: ['./app.component.scss'],
22
+ selector: "app-root",
23
+ templateUrl: "./app.component.html",
24
+ styleUrls: ["./app.component.scss"],
25
25
  })
26
26
  export class AppComponent implements OnInit {
27
27
  ibanForm: FormGroup;
@@ -30,7 +30,7 @@ export class AppComponent implements OnInit {
30
30
 
31
31
  ngOnInit() {
32
32
  this.ibanForm = this.formBuilder.group({
33
- iban: ['', [Validators.required, validateIBAN]],
33
+ iban: ["", [Validators.required, validateIBAN]],
34
34
  });
35
35
  }
36
36
  }
@@ -80,102 +80,129 @@ You can use validateIBAN function independently from any forms. Function will ch
80
80
 
81
81
  ```typescript
82
82
  const ibanIsInvalid = validateIBAN({
83
- value: 'AL35202111090000000001234567',
83
+ value: "AL35202111090000000001234567",
84
84
  }).ibanInvalid;
85
85
  ```
86
86
 
87
87
  # NodeJS
88
88
 
89
89
  ```javascript
90
- const ibanValidator = require('ngx-iban-validator');
90
+ const ibanValidator = require("ngx-iban-validator");
91
91
  const ibanIsInvalid = ibanValidator.validateIBAN({
92
- value: 'BA393385804800211234',
92
+ value: "BA393385804800211234",
93
93
  }).ibanInvalid;
94
94
  ```
95
95
 
96
96
  # Supported countries
97
97
 
98
- | Country | Country Code | Length |
99
- | ----------------------- | ------------ | ------ |
100
- | Albania | AL | 28 |
101
- | Andorra | AD | 24 |
102
- | Austria | AT | 20 |
103
- | Azerbaijan | AZ | 28 |
104
- | Bahrain | BH | 22 |
105
- | Belarus | BY | 28 |
106
- | Belgium | BE | 16 |
107
- | Bosnia and Herzegovina | BA | 20 |
108
- | Brazil | BR | 29 |
109
- | Bulgaria | BG | 22 |
110
- | Costa Rica | CR | 22 |
111
- | Croatia | HR | 21 |
112
- | Cyprus | CY | 28 |
113
- | Czech Republic | CZ | 24 |
114
- | Denmark | DK | 18 |
115
- | Dominican Republic | DO | 28 |
116
- | Egypt | EG | 29 |
117
- | El Salvador | SV | 28 |
118
- | Estonia | EE | 20 |
119
- | Faroe Islands | FO | 18 |
120
- | Finland | FI | 18 |
121
- | France | FR | 27 |
122
- | Georgia | GE | 22 |
123
- | Germany | DE | 22 |
124
- | Gibraltar | GI | 23 |
125
- | Greece | GR | 27 |
126
- | Greenland | GL | 18 |
127
- | Guatemala | GT | 28 |
128
- | Vatican | VA | 22 |
129
- | Hungary | HU | 28 |
130
- | Iceland | IS | 26 |
131
- | Iraq | IQ | 23 |
132
- | Ireland | IE | 22 |
133
- | Israel | IL | 23 |
134
- | Italy | IT | 27 |
135
- | Jordan | JO | 30 |
136
- | Kazakhstan | KZ | 20 |
137
- | Kosovo | XK | 20 |
138
- | Kuwait | KW | 30 |
139
- | Latvia | LV | 21 |
140
- | Lebanon | LB | 28 |
141
- | Libya | LY | 25 |
142
- | Liechtenstein | LI | 21 |
143
- | Lithuania | LT | 20 |
144
- | Luxembourg | LU | 20 |
145
- | Malta | MT | 31 |
146
- | Mauritania | MR | 27 |
147
- | Mauritius | MU | 30 |
148
- | Moldova | MD | 24 |
149
- | Monaco | MC | 27 |
150
- | Montenegro | ME | 22 |
151
- | Netherlands | NL | 18 |
152
- | North Macedonia | MK | 19 |
153
- | Norway | NO | 15 |
154
- | Pakistan | PK | 24 |
155
- | Palestine | PS | 29 |
156
- | Poland | PL | 28 |
157
- | Portugal | PT | 25 |
158
- | Qatar | QA | 29 |
159
- | Romania | RO | 24 |
160
- | Saint Lucia | LC | 32 |
161
- | San Marino | SM | 27 |
162
- | Sao Tome and Principe | ST | 25 |
163
- | Saudi Arabia | SA | 24 |
164
- | Serbia | RS | 22 |
165
- | Seychelles | SC | 31 |
166
- | Slovak Republic | SK | 24 |
167
- | Slovenia | SI | 19 |
168
- | Spain | ES | 24 |
169
- | Sudan | SD | 18 |
170
- | Sweden | SE | 24 |
171
- | Switzerland | CH | 21 |
172
- | Timor-Leste | TL | 23 |
173
- | Tunisia | TN | 24 |
174
- | Turkey | TR | 26 |
175
- | Ukraine | UA | 29 |
176
- | United Arab Emirates | AE | 23 |
177
- | United Kingdom | GB | 22 |
178
- | Virgin Islands, British | VG | 24 |
98
+ | Country | Country Code | Length |
99
+ | ------------------------ | ------------ | ------ |
100
+ | Albania | AL | 28 |
101
+ | Algeria | DZ | 26 |
102
+ | Andorra | AD | 24 |
103
+ | Angola | AO | 25 |
104
+ | Austria | AT | 20 |
105
+ | Azerbaijan | AZ | 28 |
106
+ | Bahrain | BH | 22 |
107
+ | Belarus | BY | 28 |
108
+ | Belgium | BE | 16 |
109
+ | Benin | BJ | 28 |
110
+ | Bosnia and Herzegovina | BA | 20 |
111
+ | Brazil | BR | 29 |
112
+ | Bulgaria | BG | 22 |
113
+ | Burundi | BI | 16 |
114
+ | Burkina Faso | BF | 28 |
115
+ | Cameroon | CM | 27 |
116
+ | Cape Verde | CV | 25 |
117
+ | Central African Republic | CF | 27 |
118
+ | Chad | TD | 27 |
119
+ | Comoros | KM | 27 |
120
+ | Congo | CG | 27 |
121
+ | Costa Rica | CR | 22 |
122
+ | Croatia | HR | 21 |
123
+ | Cyprus | CY | 28 |
124
+ | Czech Republic | CZ | 24 |
125
+ | Denmark | DK | 18 |
126
+ | Dominican Republic | DO | 28 |
127
+ | Egypt | EG | 29 |
128
+ | El Salvador | SV | 28 |
129
+ | Equatorial Guinea | GQ | 27 |
130
+ | Estonia | EE | 20 |
131
+ | Faroe Islands | FO | 18 |
132
+ | Finland | FI | 18 |
133
+ | France | FR | 27 |
134
+ | Gabon | GA | 27 |
135
+ | Georgia | GE | 22 |
136
+ | Germany | DE | 22 |
137
+ | Gibraltar | GI | 23 |
138
+ | Greece | GR | 27 |
139
+ | Greenland | GL | 18 |
140
+ | Guatemala | GT | 28 |
141
+ | Guinea-Bissau | GW | 25 |
142
+ | Vatican | VA | 22 |
143
+ | Honduras | HN | 28 |
144
+ | Hungary | HU | 28 |
145
+ | Iceland | IS | 26 |
146
+ | Iran | IR | 26 |
147
+ | Iraq | IQ | 23 |
148
+ | Ireland | IE | 22 |
149
+ | Israel | IL | 23 |
150
+ | Italy | IT | 27 |
151
+ | Ivory Coast | CI | 28 |
152
+ | Jordan | JO | 30 |
153
+ | Kazakhstan | KZ | 20 |
154
+ | Kosovo | XK | 20 |
155
+ | Kuwait | KW | 30 |
156
+ | Latvia | LV | 21 |
157
+ | Lebanon | LB | 28 |
158
+ | Libya | LY | 25 |
159
+ | Liechtenstein | LI | 21 |
160
+ | Lithuania | LT | 20 |
161
+ | Luxembourg | LU | 20 |
162
+ | Madagascar | MG | 27 |
163
+ | Mali | ML | 28 |
164
+ | Malta | MT | 31 |
165
+ | Mauritania | MR | 27 |
166
+ | Mauritius | MU | 30 |
167
+ | Moldova | MD | 24 |
168
+ | Monaco | MC | 27 |
169
+ | Mongolia | MN | 20 |
170
+ | Montenegro | ME | 22 |
171
+ | Morocco | MA | 28 |
172
+ | Mozambique | MZ | 25 |
173
+ | Netherlands | NL | 18 |
174
+ | Nicaragua | NI | 32 |
175
+ | Niger | NE | 28 |
176
+ | North Macedonia | MK | 19 |
177
+ | Norway | NO | 15 |
178
+ | Pakistan | PK | 24 |
179
+ | Palestine | PS | 29 |
180
+ | Poland | PL | 28 |
181
+ | Portugal | PT | 25 |
182
+ | Qatar | QA | 29 |
183
+ | Romania | RO | 24 |
184
+ | Russia | RU | 33 |
185
+ | Saint Lucia | LC | 32 |
186
+ | San Marino | SM | 27 |
187
+ | Sao Tome and Principe | ST | 25 |
188
+ | Saudi Arabia | SA | 24 |
189
+ | Senegal | SN | 28 |
190
+ | Serbia | RS | 22 |
191
+ | Seychelles | SC | 31 |
192
+ | Slovak Republic | SK | 24 |
193
+ | Slovenia | SI | 19 |
194
+ | Spain | ES | 24 |
195
+ | Sudan | SD | 18 |
196
+ | Sweden | SE | 24 |
197
+ | Switzerland | CH | 21 |
198
+ | Timor-Leste | TL | 23 |
199
+ | Togo | TG | 28 |
200
+ | Tunisia | TN | 24 |
201
+ | Turkey | TR | 26 |
202
+ | Ukraine | UA | 29 |
203
+ | United Arab Emirates | AE | 23 |
204
+ | United Kingdom | GB | 22 |
205
+ | Virgin Islands, British | VG | 24 |
179
206
 
180
207
  # Development
181
208
 
@@ -197,9 +224,21 @@ npm run test
197
224
  npx tsc
198
225
  ```
199
226
 
227
+ # v 1.1.5
228
+
229
+ Added additional pattern validation
230
+ Added more tests to improve test coverage
231
+ 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
232
+
233
+ # v 1.1.4
234
+
235
+ Avoid Angular warnings for old CommonJS module usage (see https://angular.io/guide/build#configuring-commonjs-dependencies)
236
+
237
+ Replaced mocha and chai with JEST for tests
238
+
200
239
  # v 1.1.3
201
240
 
202
- Added support for new countries Vatican, Libya, Sao Tome and Principe, Sudan
241
+ Added support for new countries: Vatican, Libya, Sao Tome and Principe, Sudan
203
242
  Updated length for LC Saint Lucia from 30 to 32
204
243
 
205
244
  Added Tests
package/dist/README.md ADDED
@@ -0,0 +1,253 @@
1
+ # IBAN Validator
2
+
3
+ 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. Currently supports 105 countries
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install ngx-iban-validator --save
9
+ ```
10
+
11
+ ## Use as a form validator
12
+
13
+ Import validateIBAN function from ngx-iban-validator package into your component file. Add validateIBAN to your form validators array.
14
+
15
+ ```typescript
16
+ import { Component, OnInit } from "@angular/core";
17
+ import { FormBuilder, FormGroup, Validators } from "@angular/forms";
18
+
19
+ import { validateIBAN } from "ngx-iban-validator";
20
+
21
+ @Component({
22
+ selector: "app-root",
23
+ templateUrl: "./app.component.html",
24
+ styleUrls: ["./app.component.scss"],
25
+ })
26
+ export class AppComponent implements OnInit {
27
+ ibanForm: FormGroup;
28
+
29
+ constructor(private formBuilder: FormBuilder) {}
30
+
31
+ ngOnInit() {
32
+ this.ibanForm = this.formBuilder.group({
33
+ iban: ["", [Validators.required, validateIBAN]],
34
+ });
35
+ }
36
+ }
37
+ ```
38
+
39
+ ## Display error
40
+
41
+ Validator is returning object as result of checks.
42
+
43
+ ```typescript
44
+ export interface IBANValidationResult {
45
+ ibanInvalid: boolean;
46
+ error: IBANError;
47
+ }
48
+
49
+ export interface IBANError {
50
+ countryUnsupported: boolean;
51
+ codeLengthInvalid: boolean;
52
+ patternInvalid: boolean;
53
+ }
54
+ ```
55
+
56
+ Error object contains more details about validation error. You can display errors easily as with any other validator.
57
+
58
+ ```html
59
+ <form [formGroup]="ibanForm">
60
+ <input type="text" formControlName="iban" />
61
+ <small
62
+ *ngIf="ibanForm.get('iban').errors && ibanForm.get('iban').errors.ibanInvalid"
63
+ >
64
+ <span *ngIf="ibanForm.get('iban').errors.error.countryUnsupported">
65
+ Country not supported
66
+ </span>
67
+ <span *ngIf="ibanForm.get('iban').errors.error.codeLengthInvalid">
68
+ IBAN Code length is invalid
69
+ </span>
70
+ <span *ngIf="ibanForm.get('iban').errors.error.patternInvalid">
71
+ IBAN Code pattern is invalid
72
+ </span>
73
+ </small>
74
+ </form>
75
+ ```
76
+
77
+ ## Use as standalone function
78
+
79
+ You can use validateIBAN function independently from any forms. Function will check IBAN and return object { ibanInvalid: boolean }
80
+
81
+ ```typescript
82
+ const ibanIsInvalid = validateIBAN({
83
+ value: "AL35202111090000000001234567",
84
+ }).ibanInvalid;
85
+ ```
86
+
87
+ # NodeJS
88
+
89
+ ```javascript
90
+ const ibanValidator = require("ngx-iban-validator");
91
+ const ibanIsInvalid = ibanValidator.validateIBAN({
92
+ value: "BA393385804800211234",
93
+ }).ibanInvalid;
94
+ ```
95
+
96
+ # Supported countries
97
+
98
+ | Country | Country Code | Length |
99
+ | ------------------------ | ------------ | ------ |
100
+ | Albania | AL | 28 |
101
+ | Algeria | DZ | 26 |
102
+ | Andorra | AD | 24 |
103
+ | Angola | AO | 25 |
104
+ | Austria | AT | 20 |
105
+ | Azerbaijan | AZ | 28 |
106
+ | Bahrain | BH | 22 |
107
+ | Belarus | BY | 28 |
108
+ | Belgium | BE | 16 |
109
+ | Benin | BJ | 28 |
110
+ | Bosnia and Herzegovina | BA | 20 |
111
+ | Brazil | BR | 29 |
112
+ | Bulgaria | BG | 22 |
113
+ | Burundi | BI | 16 |
114
+ | Burkina Faso | BF | 28 |
115
+ | Cameroon | CM | 27 |
116
+ | Cape Verde | CV | 25 |
117
+ | Central African Republic | CF | 27 |
118
+ | Chad | TD | 27 |
119
+ | Comoros | KM | 27 |
120
+ | Congo | CG | 27 |
121
+ | Costa Rica | CR | 22 |
122
+ | Croatia | HR | 21 |
123
+ | Cyprus | CY | 28 |
124
+ | Czech Republic | CZ | 24 |
125
+ | Denmark | DK | 18 |
126
+ | Dominican Republic | DO | 28 |
127
+ | Egypt | EG | 29 |
128
+ | El Salvador | SV | 28 |
129
+ | Equatorial Guinea | GQ | 27 |
130
+ | Estonia | EE | 20 |
131
+ | Faroe Islands | FO | 18 |
132
+ | Finland | FI | 18 |
133
+ | France | FR | 27 |
134
+ | Gabon | GA | 27 |
135
+ | Georgia | GE | 22 |
136
+ | Germany | DE | 22 |
137
+ | Gibraltar | GI | 23 |
138
+ | Greece | GR | 27 |
139
+ | Greenland | GL | 18 |
140
+ | Guatemala | GT | 28 |
141
+ | Guinea-Bissau | GW | 25 |
142
+ | Vatican | VA | 22 |
143
+ | Honduras | HN | 28 |
144
+ | Hungary | HU | 28 |
145
+ | Iceland | IS | 26 |
146
+ | Iran | IR | 26 |
147
+ | Iraq | IQ | 23 |
148
+ | Ireland | IE | 22 |
149
+ | Israel | IL | 23 |
150
+ | Italy | IT | 27 |
151
+ | Ivory Coast | CI | 28 |
152
+ | Jordan | JO | 30 |
153
+ | Kazakhstan | KZ | 20 |
154
+ | Kosovo | XK | 20 |
155
+ | Kuwait | KW | 30 |
156
+ | Latvia | LV | 21 |
157
+ | Lebanon | LB | 28 |
158
+ | Libya | LY | 25 |
159
+ | Liechtenstein | LI | 21 |
160
+ | Lithuania | LT | 20 |
161
+ | Luxembourg | LU | 20 |
162
+ | Madagascar | MG | 27 |
163
+ | Mali | ML | 28 |
164
+ | Malta | MT | 31 |
165
+ | Mauritania | MR | 27 |
166
+ | Mauritius | MU | 30 |
167
+ | Moldova | MD | 24 |
168
+ | Monaco | MC | 27 |
169
+ | Mongolia | MN | 20 |
170
+ | Montenegro | ME | 22 |
171
+ | Morocco | MA | 28 |
172
+ | Mozambique | MZ | 25 |
173
+ | Netherlands | NL | 18 |
174
+ | Nicaragua | NI | 32 |
175
+ | Niger | NE | 28 |
176
+ | North Macedonia | MK | 19 |
177
+ | Norway | NO | 15 |
178
+ | Pakistan | PK | 24 |
179
+ | Palestine | PS | 29 |
180
+ | Poland | PL | 28 |
181
+ | Portugal | PT | 25 |
182
+ | Qatar | QA | 29 |
183
+ | Romania | RO | 24 |
184
+ | Russia | RU | 33 |
185
+ | Saint Lucia | LC | 32 |
186
+ | San Marino | SM | 27 |
187
+ | Sao Tome and Principe | ST | 25 |
188
+ | Saudi Arabia | SA | 24 |
189
+ | Senegal | SN | 28 |
190
+ | Serbia | RS | 22 |
191
+ | Seychelles | SC | 31 |
192
+ | Slovak Republic | SK | 24 |
193
+ | Slovenia | SI | 19 |
194
+ | Spain | ES | 24 |
195
+ | Sudan | SD | 18 |
196
+ | Sweden | SE | 24 |
197
+ | Switzerland | CH | 21 |
198
+ | Timor-Leste | TL | 23 |
199
+ | Togo | TG | 28 |
200
+ | Tunisia | TN | 24 |
201
+ | Turkey | TR | 26 |
202
+ | Ukraine | UA | 29 |
203
+ | United Arab Emirates | AE | 23 |
204
+ | United Kingdom | GB | 22 |
205
+ | Virgin Islands, British | VG | 24 |
206
+
207
+ # Development
208
+
209
+ ## Install dependencies
210
+
211
+ ```bash
212
+ npm i
213
+ ```
214
+
215
+ ## Test
216
+
217
+ ```bash
218
+ npm run test
219
+ ```
220
+
221
+ ## Build
222
+
223
+ ```bash
224
+ npx tsc
225
+ ```
226
+
227
+ # v 1.1.5
228
+
229
+ Added additional pattern validation
230
+ Added more tests to improve test coverage
231
+ 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
232
+
233
+ # v 1.1.4
234
+
235
+ Avoid Angular warnings for old CommonJS module usage (see https://angular.io/guide/build#configuring-commonjs-dependencies)
236
+
237
+ Replaced mocha and chai with JEST for tests
238
+
239
+ # v 1.1.3
240
+
241
+ Added support for new countries: Vatican, Libya, Sao Tome and Principe, Sudan
242
+ Updated length for LC Saint Lucia from 30 to 32
243
+
244
+ Added Tests
245
+ Added Mocha and Chai for testing
246
+
247
+ # v 1.1.2
248
+
249
+ Updated length for CR to 22 - @freddy36
250
+
251
+ ## Read more
252
+
253
+ [IBAN Examples](https://www.iban.com/structure)