{"id":21556142,"url":"https://github.com/SKaDiZZ/ngx-iban-validator","last_synced_at":"2025-07-16T15:31:17.740Z","repository":{"id":44876922,"uuid":"239200135","full_name":"SKaDiZZ/ngx-iban-validator","owner":"SKaDiZZ","description":"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.","archived":false,"fork":false,"pushed_at":"2024-08-06T13:43:58.000Z","size":239,"stargazers_count":2,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-16T12:18:41.474Z","etag":null,"topics":["angular","iban","iban-validator","javascript","node","npm-package"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SKaDiZZ.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-02-08T20:30:16.000Z","updated_at":"2024-08-06T13:44:01.000Z","dependencies_parsed_at":"2024-08-06T15:46:15.718Z","dependency_job_id":"95077a41-d9d2-4827-9a17-f40e0ccf360c","html_url":"https://github.com/SKaDiZZ/ngx-iban-validator","commit_stats":{"total_commits":25,"total_committers":3,"mean_commits":8.333333333333334,"dds":0.07999999999999996,"last_synced_commit":"b3613ec593fd949b4b0fe41bcf9b83024580675e"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SKaDiZZ%2Fngx-iban-validator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SKaDiZZ%2Fngx-iban-validator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SKaDiZZ%2Fngx-iban-validator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SKaDiZZ%2Fngx-iban-validator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SKaDiZZ","download_url":"https://codeload.github.com/SKaDiZZ/ngx-iban-validator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226138856,"owners_count":17579497,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["angular","iban","iban-validator","javascript","node","npm-package"],"created_at":"2024-11-24T08:01:56.252Z","updated_at":"2024-11-24T08:04:44.861Z","avatar_url":"https://github.com/SKaDiZZ.png","language":"TypeScript","funding_links":[],"categories":["Recently Updated","Table of contents"],"sub_categories":["[Nov 23, 2024](/content/2024/11/23/README.md)","Third Party Components"],"readme":"# IBAN Validator\n\nIBAN 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.\n\n## Content\n\n- [Install](#install)\n- [Use as a standalone function](#use-as-a-standalone-function)\n- [Error Response](#error-response)\n- [Use as a form validator](#use-as-a-form-validator)\n  - [Angular example](#angular)\n  - [React example](#react)\n- [Demo Applications](#demo)\n- [Supported countries](#supported-countries)\n- [Development](#development)\n  - [Install dependencies](#install-dependencies)\n  - [Test](#test)\n  - [Build](#build)\n- [Changelog](#changelog)\n- [Read more](#read-more)\n\n## Install\n\n```bash\nnpm install ngx-iban-validator --save\n```\n\n## Use as a standalone function\n\nYou can use validateIBAN function independently from any forms.\n\nValue can be passed as part of object in this case validation flow will be the same as for form validation:\n\n- If IBAN is valid as result of validation **null** is returned.\n\n- If IBAN is invalid and some of the checks fail IBANValidationResult object is returned containing more info about error.\n\n```typescript\nconst ibanIsInvalid =\n  validateIBAN({\n    value: \"AL35202111090000000001234567\",\n  }) !== null;\n```\n\nValue can be passed as a string:\n\n- For valid and invalid IBAN IBANValidationResult object is returned\n\n```bash\nconst ibanIsInvalid = validateIBAN(\"AL35202111090000000001234567\").ibanInvalid;\n```\n\n### NodeJS\n\n```javascript\nconst ibanValidator = require(\"ngx-iban-validator\");\nconst ibanIsInvalid = ibanValidator.validateIBAN(\n  \"BA393385804800211234\"\n).ibanInvalid;\n```\n\n## Error Response\n\n- If IBAN is valid as result of validation **null** is returned.\n\n- If IBAN is invalid and some of the checks fail IBANValidationResult object is returned containing more info about error.\n\n```typescript\nexport interface IBANValidationResult {\n  ibanInvalid: boolean;\n  error: IBANError;\n}\n\nexport interface IBANError {\n  countryUnsupported: boolean;\n  codeLengthInvalid: boolean;\n  patternInvalid: boolean;\n}\n```\n\nError object contains more details about validation error. You can display errors easily as with any other validator.\n\n## Use as a form validator\n\n### Angular\n\nImport validateIBAN function from ngx-iban-validator package into your component file. Add validateIBAN to your form validators array.\n\n```ts\nimport { Component, inject } from \"@angular/core\";\nimport { NgIf } from \"@angular/common\";\nimport {\n  FormBuilder,\n  FormGroup,\n  ReactiveFormsModule,\n  Validators,\n} from \"@angular/forms\";\n\nimport { validateIBAN } from \"ngx-iban-validator\";\n\n@Component({\n  selector: \"my-app\",\n  standalone: true,\n  imports: [NgIf, ReactiveFormsModule],\n  template: `\n    \u003cdiv class=\"page\"\u003e\n      \u003cform [formGroup]=\"ibanForm\" (ngSubmit)=\"submit(ibanForm)\"\u003e\n        \u003ch2\u003eNGX IBAN Validator\u003c/h2\u003e\n        \u003cdiv\u003e\n          \u003cinput type=\"text\" formControlName=\"iban\" placeholder=\"Enter IBAN\" /\u003e\n          \u003cbutton [disabled]=\"ibanForm.invalid\"\u003eSubmit\u003c/button\u003e\n        \u003c/div\u003e\n        \u003cdiv class=\"validation-errors\"\u003e\n          \u003csmall\n            *ngIf=\"\n                ibanForm.get('iban')?.errors \u0026\u0026 ibanForm.get('iban')?.errors?.['ibanInvalid']\n              \"\n          \u003e\n            \u003cspan\n              *ngIf=\"ibanForm.get('iban')?.errors?.['error']['countryUnsupported']\"\n            \u003e\n              Country not supported\n            \u003c/span\u003e\n            \u003cspan\n              *ngIf=\"ibanForm.get('iban')?.errors?.['error']['codeLengthInvalid']\"\n            \u003e\n              IBAN Code length is invalid\n            \u003c/span\u003e\n            \u003cspan\n              *ngIf=\"ibanForm.get('iban')?.errors?.['error']['patternInvalid']\"\n            \u003e\n              IBAN Code pattern is invalid\n            \u003c/span\u003e\n          \u003c/small\u003e\n        \u003c/div\u003e\n      \u003c/form\u003e\n    \u003c/div\u003e\n  `,\n  styles: [\n    `\n      .page {\n        height: 100vh;\n        display: flex;\n        justify-content: center;\n        align-items: center;\n      }\n      h2 {\n        text-align: center;\n      }\n      form {\n        padding: 20px;\n      }\n      input {\n        padding: 10px;\n      }\n      button {\n        padding: 10px;\n      }\n      .validation-errors {\n        color: red;\n      }\n    `,\n  ],\n})\nexport class App {\n  formBuilder = inject(FormBuilder);\n  ibanForm = this.formBuilder.group({\n    iban: [null, [Validators.required, validateIBAN]],\n  });\n  submit(form: FormGroup) {\n    const { valid, value } = form;\n    const { iban } = value;\n    if (valid) {\n      alert(`IBAN: ${iban}, is valid!`);\n    }\n  }\n}\n```\n\n### React\n\n```tsx\nimport { useState } from \"react\";\nimport {\n  IBANError,\n  IBANValidationResult,\n  validateIBAN,\n} from \"ngx-iban-validator/dist/iban.validator\";\n\nimport \"./App.css\";\n\nfunction App() {\n  const [error, setError] = useState\u003cIBANError | null\u003e(null);\n\n  const validate = (iban: string): boolean =\u003e {\n    const validation = validateIBAN({\n      value: iban,\n    });\n    if (validation) {\n      const { ibanInvalid, error }: IBANValidationResult = validation;\n      if (ibanInvalid) {\n        setError(error);\n        return false;\n      } else {\n        setError(null);\n        return true;\n      }\n    } else {\n      setError(null);\n      return true;\n    }\n  };\n\n  const handleSubmit = (event: React.FormEvent\u003cHTMLFormElement\u003e) =\u003e {\n    event.preventDefault();\n    const formData = new FormData(event.currentTarget);\n    const iban = formData.get(\"iban\") as string;\n    const validation = validate(iban);\n    if (validation) {\n      alert(\"IBAN is valid\");\n    } else {\n      alert(\"IBAN is not valid\");\n    }\n  };\n\n  const handleIbanChanged = (event: React.ChangeEvent\u003cHTMLInputElement\u003e) =\u003e {\n    const { value } = event.target;\n    validate(value);\n  };\n\n  return (\n    \u003cdiv className=\"page\"\u003e\n      \u003cform onSubmit={handleSubmit}\u003e\n        \u003ch2\u003eNGX IBAN Validator\u003c/h2\u003e\n        \u003cdiv\u003e\n          \u003cinput\n            type=\"text\"\n            name=\"iban\"\n            placeholder=\"Enter IBAN\"\n            onChange={handleIbanChanged}\n          /\u003e\n          \u003cbutton\u003eSubmit\u003c/button\u003e\n        \u003c/div\u003e\n        \u003cdiv className=\"validation-errors\"\u003e\n          \u003csmall hidden={!error}\u003e\n            \u003cspan hidden={!error?.countryUnsupported}\u003e\n              Country not supported\n            \u003c/span\u003e\n            \u003cspan hidden={!error?.codeLengthInvalid}\u003e\n              IBAN Code length is invalid\n            \u003c/span\u003e\n            \u003cspan hidden={!error?.patternInvalid}\u003e\n              IBAN Code pattern is invalid\n            \u003c/span\u003e\n          \u003c/small\u003e\n        \u003c/div\u003e\n      \u003c/form\u003e\n    \u003c/div\u003e\n  );\n}\n\nexport default App;\n```\n\n## Demo\n\nCheck demo applications for usage examples:\n\n- [Angular - Demo Application](https://stackblitz.com/edit/stackblitz-starters-d6zn46?file=src%2Fmain.ts)\n- [React - Demo Application](https://stackblitz.com/edit/vitejs-vite-mhe5gj?file=src%2FApp.tsx)\n\n###\n\n# Supported countries\n\n####\n\n\u003cdetails\u003e\n\u003csummary\u003e\n Click here to expand list of supported countries\n\u003c/summary\u003e\n\n| No  | Country                  | Country Code | Length |\n| --- | ------------------------ | ------------ | ------ |\n| 1   | Albania                  | AL           | 28     |\n| 2   | Algeria                  | DZ           | 26     |\n| 3   | Andorra                  | AD           | 24     |\n| 4   | Angola                   | AO           | 25     |\n| 5   | Austria                  | AT           | 20     |\n| 6   | Azerbaijan               | AZ           | 28     |\n| 7   | Bahrain                  | BH           | 22     |\n| 8   | Belarus                  | BY           | 28     |\n| 9   | Belgium                  | BE           | 16     |\n| 10  | Benin                    | BJ           | 28     |\n| 11  | Bosnia and Herzegovina   | BA           | 20     |\n| 12  | Brazil                   | BR           | 29     |\n| 13  | Bulgaria                 | BG           | 22     |\n| 14  | Burundi                  | BI           | 27     |\n| 15  | Burkina Faso             | BF           | 28     |\n| 16  | Cameroon                 | CM           | 27     |\n| 17  | Cape Verde               | CV           | 25     |\n| 18  | Central African Republic | CF           | 27     |\n| 19  | Chad                     | TD           | 27     |\n| 20  | Comoros                  | KM           | 27     |\n| 21  | Congo                    | CG           | 27     |\n| 22  | Costa Rica               | CR           | 22     |\n| 23  | Croatia                  | HR           | 21     |\n| 24  | Cyprus                   | CY           | 28     |\n| 25  | Czech Republic           | CZ           | 24     |\n| 26  | Denmark                  | DK           | 18     |\n| 27  | Djibouti                 | DJ           | 27     |\n| 28  | Dominican Republic       | DO           | 28     |\n| 29  | Egypt                    | EG           | 29     |\n| 30  | El Salvador              | SV           | 28     |\n| 32  | Equatorial Guinea        | GQ           | 27     |\n| 33  | Estonia                  | EE           | 20     |\n| 34  | Falkland Islands         | FK           | 18     |\n| 35  | Faroe Islands            | FO           | 18     |\n| 36  | Finland                  | FI           | 18     |\n| 37  | France                   | FR           | 27     |\n| 38  | Gabon                    | GA           | 27     |\n| 39  | Georgia                  | GE           | 22     |\n| 40  | Germany                  | DE           | 22     |\n| 41  | Gibraltar                | GI           | 23     |\n| 42  | Greece                   | GR           | 27     |\n| 43  | Greenland                | GL           | 18     |\n| 44  | Guatemala                | GT           | 28     |\n| 45  | Guinea-Bissau            | GW           | 25     |\n| 46  | Vatican                  | VA           | 22     |\n| 47  | Honduras                 | HN           | 28     |\n| 48  | Hungary                  | HU           | 28     |\n| 49  | Iceland                  | IS           | 26     |\n| 50  | Iran                     | IR           | 26     |\n| 51  | Iraq                     | IQ           | 23     |\n| 52  | Ireland                  | IE           | 22     |\n| 53  | Israel                   | IL           | 23     |\n| 54  | Italy                    | IT           | 27     |\n| 55  | Ivory Coast              | CI           | 28     |\n| 56  | Jordan                   | JO           | 30     |\n| 57  | Kazakhstan               | KZ           | 20     |\n| 58  | Kosovo                   | XK           | 20     |\n| 59  | Kuwait                   | KW           | 30     |\n| 60  | Latvia                   | LV           | 21     |\n| 61  | Lebanon                  | LB           | 28     |\n| 62  | Libya                    | LY           | 25     |\n| 63  | Liechtenstein            | LI           | 21     |\n| 64  | Lithuania                | LT           | 20     |\n| 65  | Luxembourg               | LU           | 20     |\n| 66  | Madagascar               | MG           | 27     |\n| 67  | Mali                     | ML           | 28     |\n| 68  | Malta                    | MT           | 31     |\n| 69  | Mauritania               | MR           | 27     |\n| 70  | Mauritius                | MU           | 30     |\n| 71  | Moldova                  | MD           | 24     |\n| 72  | Monaco                   | MC           | 27     |\n| 73  | Mongolia                 | MN           | 20     |\n| 74  | Montenegro               | ME           | 22     |\n| 75  | Morocco                  | MA           | 28     |\n| 76  | Mozambique               | MZ           | 25     |\n| 77  | Netherlands              | NL           | 18     |\n| 78  | Nicaragua                | NI           | 28     |\n| 79  | Niger                    | NE           | 28     |\n| 80  | North Macedonia          | MK           | 19     |\n| 81  | Norway                   | NO           | 15     |\n| 82  | Pakistan                 | PK           | 24     |\n| 83  | Palestine                | PS           | 29     |\n| 84  | Poland                   | PL           | 28     |\n| 85  | Portugal                 | PT           | 25     |\n| 86  | Qatar                    | QA           | 29     |\n| 87  | Romania                  | RO           | 24     |\n| 88  | Russia                   | RU           | 33     |\n| 89  | Saint Lucia              | LC           | 32     |\n| 90  | San Marino               | SM           | 27     |\n| 91  | Sao Tome and Principe    | ST           | 25     |\n| 92  | Saudi Arabia             | SA           | 24     |\n| 93  | Senegal                  | SN           | 28     |\n| 94  | Serbia                   | RS           | 22     |\n| 95  | Seychelles               | SC           | 31     |\n| 96  | Slovak Republic          | SK           | 24     |\n| 97  | Slovenia                 | SI           | 19     |\n| 98  | Somalia                  | SO           | 23     |\n| 99  | Spain                    | ES           | 24     |\n| 100 | Sudan                    | SD           | 18     |\n| 101 | Sultanate of Oman        | OM           | 23     |\n| 102 | Sweden                   | SE           | 24     |\n| 103 | Switzerland              | CH           | 21     |\n| 104 | Timor-Leste              | TL           | 23     |\n| 105 | Togo                     | TG           | 28     |\n| 106 | Tunisia                  | TN           | 24     |\n| 107 | Turkey                   | TR           | 26     |\n| 108 | Ukraine                  | UA           | 29     |\n| 109 | United Arab Emirates     | AE           | 23     |\n| 110 | United Kingdom           | GB           | 22     |\n| 111 | Virgin Islands, British  | VG           | 24     |\n| 112 | Yemen                    | YE           | 30     |\n\n\u003c/details\u003e\n\n###\n\n# Development\n\n## Install dependencies\n\n```bash\nnpm i\n```\n\n## Test\n\n```bash\nnpm run test\n```\n\n## Build\n\n```bash\nnpx tsc\n```\n\n# Changelog\n\n## v 1.2.2\n\n- Added Support for Yemen\n- 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\n- Updated tests and docs\n\n## v 1.2.1\n\n- Updated Burundi (BI) length 16 -\u003e 27\n- Updated Nicaragua (NI) length 32 -\u003e 28\n\n## v 1.2.0\n\n- Updated documentation\n\n## v 1.1.9\n\n- Added support for Sultanate of Oman\n\n## v 1.1.8\n\n- Added support for Falkland Islands\n\n## v 1.1.7\n\n- Added support for Djibouti and Somalia\n\n## v 1.1.6\n\n- Updated error display logic\n- Value can be passed directly as a string or part of the object.\n  - If value is passed as a part of object same logic as for form validation is applied:\n    - If IBAN is valid as result of validation **null** is returned.\n    - If IBAN is invalid and some of the checks fail IBANValidationResult object is returned containing more info about error.\n  - If value is passed as a string:\n    - For valid and invalid IBAN IBANValidationResult object is returned.\n- Return null for valid form field to fix issue with disabling | enabling buttons\n  - Thnx to @pramodEE for reporting the issue\n\n## v 1.1.5\n\nAdded additional pattern validation\nAdded more tests to improve test coverage\nAdded 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\n\n## v 1.1.4\n\nAvoid Angular warnings for old CommonJS module usage (see https://angular.io/guide/build#configuring-commonjs-dependencies)\n\nReplaced mocha and chai with JEST for tests\n\n## v 1.1.3\n\nAdded support for new countries: Vatican, Libya, Sao Tome and Principe, Sudan\nUpdated length for LC Saint Lucia from 30 to 32\n\nAdded Tests\nAdded Mocha and Chai for testing\n\n## v 1.1.2\n\nUpdated length for CR to 22 - @freddy36\n\n## Read more\n\n[IBAN Examples](https://www.iban.com/structure)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSKaDiZZ%2Fngx-iban-validator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FSKaDiZZ%2Fngx-iban-validator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSKaDiZZ%2Fngx-iban-validator/lists"}