@temboplus/frontend-core 0.1.0
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/LICENSE +7 -0
- package/README.md +72 -0
- package/esm/_dnt.test_shims.d.ts.map +1 -0
- package/esm/deps/deno.land/std@0.217.0/assert/_constants.d.ts.map +1 -0
- package/esm/deps/deno.land/std@0.217.0/assert/_diff.d.ts.map +1 -0
- package/esm/deps/deno.land/std@0.217.0/assert/_format.d.ts.map +1 -0
- package/esm/deps/deno.land/std@0.217.0/assert/assert.d.ts.map +1 -0
- package/esm/deps/deno.land/std@0.217.0/assert/assert_almost_equals.d.ts.map +1 -0
- package/esm/deps/deno.land/std@0.217.0/assert/assert_array_includes.d.ts.map +1 -0
- package/esm/deps/deno.land/std@0.217.0/assert/assert_equals.d.ts.map +1 -0
- package/esm/deps/deno.land/std@0.217.0/assert/assert_exists.d.ts.map +1 -0
- package/esm/deps/deno.land/std@0.217.0/assert/assert_false.d.ts.map +1 -0
- package/esm/deps/deno.land/std@0.217.0/assert/assert_greater.d.ts.map +1 -0
- package/esm/deps/deno.land/std@0.217.0/assert/assert_greater_or_equal.d.ts.map +1 -0
- package/esm/deps/deno.land/std@0.217.0/assert/assert_instance_of.d.ts.map +1 -0
- package/esm/deps/deno.land/std@0.217.0/assert/assert_is_error.d.ts.map +1 -0
- package/esm/deps/deno.land/std@0.217.0/assert/assert_less.d.ts.map +1 -0
- package/esm/deps/deno.land/std@0.217.0/assert/assert_less_or_equal.d.ts.map +1 -0
- package/esm/deps/deno.land/std@0.217.0/assert/assert_match.d.ts.map +1 -0
- package/esm/deps/deno.land/std@0.217.0/assert/assert_not_equals.d.ts.map +1 -0
- package/esm/deps/deno.land/std@0.217.0/assert/assert_not_instance_of.d.ts.map +1 -0
- package/esm/deps/deno.land/std@0.217.0/assert/assert_not_match.d.ts.map +1 -0
- package/esm/deps/deno.land/std@0.217.0/assert/assert_not_strict_equals.d.ts.map +1 -0
- package/esm/deps/deno.land/std@0.217.0/assert/assert_object_match.d.ts.map +1 -0
- package/esm/deps/deno.land/std@0.217.0/assert/assert_rejects.d.ts.map +1 -0
- package/esm/deps/deno.land/std@0.217.0/assert/assert_strict_equals.d.ts.map +1 -0
- package/esm/deps/deno.land/std@0.217.0/assert/assert_string_includes.d.ts.map +1 -0
- package/esm/deps/deno.land/std@0.217.0/assert/assert_throws.d.ts.map +1 -0
- package/esm/deps/deno.land/std@0.217.0/assert/assertion_error.d.ts.map +1 -0
- package/esm/deps/deno.land/std@0.217.0/assert/equal.d.ts.map +1 -0
- package/esm/deps/deno.land/std@0.217.0/assert/fail.d.ts.map +1 -0
- package/esm/deps/deno.land/std@0.217.0/assert/mod.d.ts.map +1 -0
- package/esm/deps/deno.land/std@0.217.0/assert/unimplemented.d.ts.map +1 -0
- package/esm/deps/deno.land/std@0.217.0/assert/unreachable.d.ts.map +1 -0
- package/esm/deps/deno.land/std@0.217.0/fmt/colors.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/almost_equals.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/array_includes.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/assert.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/assertion_error.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/equal.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/equals.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/exists.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/fail.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/false.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/greater.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/greater_or_equal.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/instance_of.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/is_error.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/less.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/less_or_equal.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/match.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/mod.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/not_equals.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/not_instance_of.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/not_match.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/not_strict_equals.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/object_match.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/rejects.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/strict_equals.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/string_includes.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/throws.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/unimplemented.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.10/unreachable.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.5/build_message.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.5/diff.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.5/diff_str.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.5/format.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.5/styles.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.5/types.d.ts.map +1 -0
- package/esm/mod.d.ts +3 -0
- package/esm/mod.d.ts.map +1 -0
- package/esm/mod.js +2 -0
- package/esm/package.json +3 -0
- package/esm/src/models/amount/amount.d.ts +55 -0
- package/esm/src/models/amount/amount.d.ts.map +1 -0
- package/esm/src/models/amount/amount.js +229 -0
- package/esm/src/models/amount/amount.test.d.ts.map +1 -0
- package/esm/src/models/amount/antd_validator.d.ts +40 -0
- package/esm/src/models/amount/antd_validator.d.ts.map +1 -0
- package/esm/src/models/amount/antd_validator.js +58 -0
- package/esm/src/models/amount/antd_validator.test.d.ts.map +1 -0
- package/esm/src/models/amount/index.d.ts +3 -0
- package/esm/src/models/amount/index.d.ts.map +1 -0
- package/esm/src/models/amount/index.js +2 -0
- package/esm/src/models/bank/antd_validator.d.ts +11 -0
- package/esm/src/models/bank/antd_validator.d.ts.map +1 -0
- package/esm/src/models/bank/antd_validator.js +26 -0
- package/esm/src/models/bank/antd_validator.test.d.ts.map +1 -0
- package/esm/src/models/bank/bank.d.ts +125 -0
- package/esm/src/models/bank/bank.d.ts.map +1 -0
- package/esm/src/models/bank/bank.js +229 -0
- package/esm/src/models/bank/bank.test.d.ts.map +1 -0
- package/esm/src/models/bank/banks.d.ts +7 -0
- package/esm/src/models/bank/banks.d.ts.map +1 -0
- package/esm/src/models/bank/banks.js +197 -0
- package/esm/src/models/bank/index.d.ts +4 -0
- package/esm/src/models/bank/index.d.ts.map +1 -0
- package/esm/src/models/bank/index.js +3 -0
- package/esm/src/models/bank/utils.d.ts +25 -0
- package/esm/src/models/bank/utils.d.ts.map +1 -0
- package/esm/src/models/bank/utils.js +35 -0
- package/esm/src/models/index.d.ts +4 -0
- package/esm/src/models/index.d.ts.map +1 -0
- package/esm/src/models/index.js +3 -0
- package/esm/src/models/phone_number/antd_validator.d.ts +77 -0
- package/esm/src/models/phone_number/antd_validator.d.ts.map +1 -0
- package/esm/src/models/phone_number/antd_validator.js +90 -0
- package/esm/src/models/phone_number/antdvalidator.test.d.ts.map +1 -0
- package/esm/src/models/phone_number/index.d.ts +4 -0
- package/esm/src/models/phone_number/index.d.ts.map +1 -0
- package/esm/src/models/phone_number/index.js +3 -0
- package/esm/src/models/phone_number/phone_number.d.ts +117 -0
- package/esm/src/models/phone_number/phone_number.d.ts.map +1 -0
- package/esm/src/models/phone_number/phone_number.js +231 -0
- package/esm/src/models/phone_number/phone_number.test.d.ts.map +1 -0
- package/esm/src/models/phone_number/telecom.d.ts +25 -0
- package/esm/src/models/phone_number/telecom.d.ts.map +1 -0
- package/esm/src/models/phone_number/telecom.js +44 -0
- package/esm/src/utils/id.d.ts +12 -0
- package/esm/src/utils/id.d.ts.map +1 -0
- package/esm/src/utils/id.js +19 -0
- package/esm/src/utils/index.d.ts +4 -0
- package/esm/src/utils/index.d.ts.map +1 -0
- package/esm/src/utils/index.js +3 -0
- package/esm/src/utils/text.d.ts +32 -0
- package/esm/src/utils/text.d.ts.map +1 -0
- package/esm/src/utils/text.js +68 -0
- package/esm/src/utils/text.test.d.ts.map +1 -0
- package/esm/src/utils/time.d.ts +21 -0
- package/esm/src/utils/time.d.ts.map +1 -0
- package/esm/src/utils/time.js +34 -0
- package/package.json +35 -0
- package/script/_dnt.test_shims.d.ts.map +1 -0
- package/script/deps/deno.land/std@0.217.0/assert/_constants.d.ts.map +1 -0
- package/script/deps/deno.land/std@0.217.0/assert/_diff.d.ts.map +1 -0
- package/script/deps/deno.land/std@0.217.0/assert/_format.d.ts.map +1 -0
- package/script/deps/deno.land/std@0.217.0/assert/assert.d.ts.map +1 -0
- package/script/deps/deno.land/std@0.217.0/assert/assert_almost_equals.d.ts.map +1 -0
- package/script/deps/deno.land/std@0.217.0/assert/assert_array_includes.d.ts.map +1 -0
- package/script/deps/deno.land/std@0.217.0/assert/assert_equals.d.ts.map +1 -0
- package/script/deps/deno.land/std@0.217.0/assert/assert_exists.d.ts.map +1 -0
- package/script/deps/deno.land/std@0.217.0/assert/assert_false.d.ts.map +1 -0
- package/script/deps/deno.land/std@0.217.0/assert/assert_greater.d.ts.map +1 -0
- package/script/deps/deno.land/std@0.217.0/assert/assert_greater_or_equal.d.ts.map +1 -0
- package/script/deps/deno.land/std@0.217.0/assert/assert_instance_of.d.ts.map +1 -0
- package/script/deps/deno.land/std@0.217.0/assert/assert_is_error.d.ts.map +1 -0
- package/script/deps/deno.land/std@0.217.0/assert/assert_less.d.ts.map +1 -0
- package/script/deps/deno.land/std@0.217.0/assert/assert_less_or_equal.d.ts.map +1 -0
- package/script/deps/deno.land/std@0.217.0/assert/assert_match.d.ts.map +1 -0
- package/script/deps/deno.land/std@0.217.0/assert/assert_not_equals.d.ts.map +1 -0
- package/script/deps/deno.land/std@0.217.0/assert/assert_not_instance_of.d.ts.map +1 -0
- package/script/deps/deno.land/std@0.217.0/assert/assert_not_match.d.ts.map +1 -0
- package/script/deps/deno.land/std@0.217.0/assert/assert_not_strict_equals.d.ts.map +1 -0
- package/script/deps/deno.land/std@0.217.0/assert/assert_object_match.d.ts.map +1 -0
- package/script/deps/deno.land/std@0.217.0/assert/assert_rejects.d.ts.map +1 -0
- package/script/deps/deno.land/std@0.217.0/assert/assert_strict_equals.d.ts.map +1 -0
- package/script/deps/deno.land/std@0.217.0/assert/assert_string_includes.d.ts.map +1 -0
- package/script/deps/deno.land/std@0.217.0/assert/assert_throws.d.ts.map +1 -0
- package/script/deps/deno.land/std@0.217.0/assert/assertion_error.d.ts.map +1 -0
- package/script/deps/deno.land/std@0.217.0/assert/equal.d.ts.map +1 -0
- package/script/deps/deno.land/std@0.217.0/assert/fail.d.ts.map +1 -0
- package/script/deps/deno.land/std@0.217.0/assert/mod.d.ts.map +1 -0
- package/script/deps/deno.land/std@0.217.0/assert/unimplemented.d.ts.map +1 -0
- package/script/deps/deno.land/std@0.217.0/assert/unreachable.d.ts.map +1 -0
- package/script/deps/deno.land/std@0.217.0/fmt/colors.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/assert/1.0.10/almost_equals.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/assert/1.0.10/array_includes.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/assert/1.0.10/assert.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/assert/1.0.10/assertion_error.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/assert/1.0.10/equal.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/assert/1.0.10/equals.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/assert/1.0.10/exists.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/assert/1.0.10/fail.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/assert/1.0.10/false.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/assert/1.0.10/greater.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/assert/1.0.10/greater_or_equal.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/assert/1.0.10/instance_of.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/assert/1.0.10/is_error.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/assert/1.0.10/less.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/assert/1.0.10/less_or_equal.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/assert/1.0.10/match.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/assert/1.0.10/mod.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/assert/1.0.10/not_equals.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/assert/1.0.10/not_instance_of.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/assert/1.0.10/not_match.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/assert/1.0.10/not_strict_equals.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/assert/1.0.10/object_match.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/assert/1.0.10/rejects.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/assert/1.0.10/strict_equals.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/assert/1.0.10/string_includes.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/assert/1.0.10/throws.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/assert/1.0.10/unimplemented.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/assert/1.0.10/unreachable.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/internal/1.0.5/build_message.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/internal/1.0.5/diff.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/internal/1.0.5/diff_str.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/internal/1.0.5/format.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/internal/1.0.5/styles.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/internal/1.0.5/types.d.ts.map +1 -0
- package/script/mod.d.ts +3 -0
- package/script/mod.d.ts.map +1 -0
- package/script/mod.js +18 -0
- package/script/package.json +3 -0
- package/script/src/models/amount/amount.d.ts +55 -0
- package/script/src/models/amount/amount.d.ts.map +1 -0
- package/script/src/models/amount/amount.js +233 -0
- package/script/src/models/amount/amount.test.d.ts.map +1 -0
- package/script/src/models/amount/antd_validator.d.ts +40 -0
- package/script/src/models/amount/antd_validator.d.ts.map +1 -0
- package/script/src/models/amount/antd_validator.js +62 -0
- package/script/src/models/amount/antd_validator.test.d.ts.map +1 -0
- package/script/src/models/amount/index.d.ts +3 -0
- package/script/src/models/amount/index.d.ts.map +1 -0
- package/script/src/models/amount/index.js +18 -0
- package/script/src/models/bank/antd_validator.d.ts +11 -0
- package/script/src/models/bank/antd_validator.d.ts.map +1 -0
- package/script/src/models/bank/antd_validator.js +30 -0
- package/script/src/models/bank/antd_validator.test.d.ts.map +1 -0
- package/script/src/models/bank/bank.d.ts +125 -0
- package/script/src/models/bank/bank.d.ts.map +1 -0
- package/script/src/models/bank/bank.js +236 -0
- package/script/src/models/bank/bank.test.d.ts.map +1 -0
- package/script/src/models/bank/banks.d.ts +7 -0
- package/script/src/models/bank/banks.d.ts.map +1 -0
- package/script/src/models/bank/banks.js +199 -0
- package/script/src/models/bank/index.d.ts +4 -0
- package/script/src/models/bank/index.d.ts.map +1 -0
- package/script/src/models/bank/index.js +19 -0
- package/script/src/models/bank/utils.d.ts +25 -0
- package/script/src/models/bank/utils.d.ts.map +1 -0
- package/script/src/models/bank/utils.js +41 -0
- package/script/src/models/index.d.ts +4 -0
- package/script/src/models/index.d.ts.map +1 -0
- package/script/src/models/index.js +19 -0
- package/script/src/models/phone_number/antd_validator.d.ts +77 -0
- package/script/src/models/phone_number/antd_validator.d.ts.map +1 -0
- package/script/src/models/phone_number/antd_validator.js +94 -0
- package/script/src/models/phone_number/antdvalidator.test.d.ts.map +1 -0
- package/script/src/models/phone_number/index.d.ts +4 -0
- package/script/src/models/phone_number/index.d.ts.map +1 -0
- package/script/src/models/phone_number/index.js +19 -0
- package/script/src/models/phone_number/phone_number.d.ts +117 -0
- package/script/src/models/phone_number/phone_number.d.ts.map +1 -0
- package/script/src/models/phone_number/phone_number.js +235 -0
- package/script/src/models/phone_number/phone_number.test.d.ts.map +1 -0
- package/script/src/models/phone_number/telecom.d.ts +25 -0
- package/script/src/models/phone_number/telecom.d.ts.map +1 -0
- package/script/src/models/phone_number/telecom.js +47 -0
- package/script/src/utils/id.d.ts +12 -0
- package/script/src/utils/id.d.ts.map +1 -0
- package/script/src/utils/id.js +23 -0
- package/script/src/utils/index.d.ts +4 -0
- package/script/src/utils/index.d.ts.map +1 -0
- package/script/src/utils/index.js +19 -0
- package/script/src/utils/text.d.ts +32 -0
- package/script/src/utils/text.d.ts.map +1 -0
- package/script/src/utils/text.js +75 -0
- package/script/src/utils/text.test.d.ts.map +1 -0
- package/script/src/utils/time.d.ts +21 -0
- package/script/src/utils/time.d.ts.map +1 -0
- package/script/src/utils/time.js +39 -0
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import file from "./banks.js";
|
|
2
|
+
/**
|
|
3
|
+
* Represents a bank with essential details.
|
|
4
|
+
* @class Bank
|
|
5
|
+
*/
|
|
6
|
+
export class Bank {
|
|
7
|
+
/**
|
|
8
|
+
* Creates a new Bank instance.
|
|
9
|
+
* @param {string} _fullName - The full name of the bank
|
|
10
|
+
* @param {string} _shortName - The short name or abbreviated name of the bank
|
|
11
|
+
* @param {string} _swiftCode - The SWIFT code associated with the bank
|
|
12
|
+
*/
|
|
13
|
+
constructor(_fullName, _shortName, _swiftCode) {
|
|
14
|
+
Object.defineProperty(this, "_fullName", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
configurable: true,
|
|
17
|
+
writable: true,
|
|
18
|
+
value: _fullName
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(this, "_shortName", {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
configurable: true,
|
|
23
|
+
writable: true,
|
|
24
|
+
value: _shortName
|
|
25
|
+
});
|
|
26
|
+
Object.defineProperty(this, "_swiftCode", {
|
|
27
|
+
enumerable: true,
|
|
28
|
+
configurable: true,
|
|
29
|
+
writable: true,
|
|
30
|
+
value: _swiftCode
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Gets the full name of the bank.
|
|
35
|
+
* @returns {string} The full name of the bank
|
|
36
|
+
*/
|
|
37
|
+
get fullName() {
|
|
38
|
+
return this._fullName;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Gets the short name of the bank.
|
|
42
|
+
* @returns {string} The short name of the bank
|
|
43
|
+
*/
|
|
44
|
+
get shortName() {
|
|
45
|
+
return this._shortName;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Gets the SWIFT code of the bank.
|
|
49
|
+
* @returns {string} The SWIFT code of the bank
|
|
50
|
+
*/
|
|
51
|
+
get swiftCode() {
|
|
52
|
+
return this._swiftCode;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Creates a string representation of the bank.
|
|
56
|
+
* @returns {string} String representation of the bank
|
|
57
|
+
*/
|
|
58
|
+
toString() {
|
|
59
|
+
return `${this.fullName} (${this.shortName}) - SWIFT: ${this.swiftCode}`;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Retrieves a bank by its SWIFT code.
|
|
63
|
+
* @param {string} swiftCode The SWIFT code of the bank.
|
|
64
|
+
* @returns {Bank | undefined} The bank corresponding to the SWIFT code or `undefined` if not found.
|
|
65
|
+
*/
|
|
66
|
+
static fromSWIFTCode(swiftCode) {
|
|
67
|
+
return this.getAll().find((b) => b.swiftCode.toUpperCase() === swiftCode.toUpperCase());
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Retrieves a bank by its short or full name.
|
|
71
|
+
* @param {string} bankName The full name of the bank.
|
|
72
|
+
* @returns {Bank | undefined} The bank corresponding to the full name or `undefined` if not found.
|
|
73
|
+
*/
|
|
74
|
+
static fromBankName(bankName) {
|
|
75
|
+
return this.getAll().find((bank) => bank.fullName.toLowerCase() === bankName.toLowerCase() ||
|
|
76
|
+
bankName.toLowerCase() === bank.shortName.toLowerCase());
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Validates if a given SWIFT/BIC (Bank Identifier Code) is valid
|
|
80
|
+
*
|
|
81
|
+
* @param {string | null | undefined} swiftCode - The SWIFT/BIC code to validate.
|
|
82
|
+
* Should be in the format of 8 or 11 characters (e.g., 'NMIBTZTZ' or 'CRDBTZTZXXX').
|
|
83
|
+
*
|
|
84
|
+
* @returns {boolean} Returns true if:
|
|
85
|
+
* - The SWIFT code is not null/undefined
|
|
86
|
+
* - The SWIFT code successfully creates a valid Bank instance
|
|
87
|
+
* Returns false otherwise.
|
|
88
|
+
*/
|
|
89
|
+
static isValidSwiftCode(swiftCode) {
|
|
90
|
+
if (!swiftCode)
|
|
91
|
+
return false;
|
|
92
|
+
const bank = Bank.fromSWIFTCode(swiftCode);
|
|
93
|
+
return !!bank;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Validates if a given bank name is valid
|
|
97
|
+
*
|
|
98
|
+
* @param {string | null | undefined} bankName - The bank name to validate.
|
|
99
|
+
* Should be either 'CRDB' or 'NMB'.
|
|
100
|
+
*
|
|
101
|
+
* @returns {boolean} Returns true if:
|
|
102
|
+
* - The bank name is not null/undefined
|
|
103
|
+
* - The bank name successfully creates a valid Bank instance
|
|
104
|
+
* Returns false otherwise.
|
|
105
|
+
*/
|
|
106
|
+
static isValidBankName(bankName) {
|
|
107
|
+
if (!bankName)
|
|
108
|
+
return false;
|
|
109
|
+
const bank = Bank.fromBankName(bankName);
|
|
110
|
+
return !!bank;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Gets all banks from the JSON data.
|
|
114
|
+
* @returns {Bank[]} Array of all banks
|
|
115
|
+
*/
|
|
116
|
+
static getAll() {
|
|
117
|
+
const data = JSON.parse(JSON.stringify(file));
|
|
118
|
+
return data.map((b) => new Bank(b.fullName, b.shortName, b.swiftCode));
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Checks the validity of the bank data
|
|
122
|
+
* @returns true if the bank information is available and valid
|
|
123
|
+
*/
|
|
124
|
+
validate() {
|
|
125
|
+
try {
|
|
126
|
+
return (Bank.fromBankName(this._fullName) !== undefined &&
|
|
127
|
+
Bank.fromBankName(this._shortName) !== undefined &&
|
|
128
|
+
Bank.fromSWIFTCode(this._swiftCode) !== undefined);
|
|
129
|
+
}
|
|
130
|
+
catch (_) {
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Attempts to create a Bank instance from a bank name or SWIFT code
|
|
136
|
+
* First tries to create from bank name, then from SWIFT code if bank name fails
|
|
137
|
+
*
|
|
138
|
+
* @param {string} input - The bank name or SWIFT code
|
|
139
|
+
* @returns {Bank | undefined} A Bank instance if valid input, undefined otherwise
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* const bank = Bank.from('CORUTZTZ'); // From SWIFT code
|
|
143
|
+
* const sameBank = Bank.from('CRDB'); // From bank name
|
|
144
|
+
*/
|
|
145
|
+
static from(input) {
|
|
146
|
+
if (Bank.canConstruct(input)) {
|
|
147
|
+
const bank1 = Bank.fromBankName(input);
|
|
148
|
+
if (bank1)
|
|
149
|
+
return bank1;
|
|
150
|
+
const bank2 = Bank.fromSWIFTCode(input);
|
|
151
|
+
if (bank2)
|
|
152
|
+
return bank2;
|
|
153
|
+
}
|
|
154
|
+
return undefined;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Validates if the input can be used to construct a valid Bank instance
|
|
158
|
+
* Checks if the input resolves to the same bank via both name and SWIFT code
|
|
159
|
+
*
|
|
160
|
+
* @param {string | null | undefined} input - The bank name or SWIFT code to validate
|
|
161
|
+
* @returns {boolean} True if input can construct a valid bank, false otherwise
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* Bank.canConstruct('CORUTZTZ'); // true
|
|
165
|
+
* Bank.canConstruct(''); // false
|
|
166
|
+
* Bank.canConstruct(null); // false
|
|
167
|
+
*/
|
|
168
|
+
static canConstruct(input) {
|
|
169
|
+
if (!input || typeof input !== "string")
|
|
170
|
+
return false;
|
|
171
|
+
const text = input.trim();
|
|
172
|
+
if (text.length === 0)
|
|
173
|
+
return false;
|
|
174
|
+
const bankFromSwift = Bank.fromSWIFTCode(text);
|
|
175
|
+
const bankFromName = Bank.fromBankName(text);
|
|
176
|
+
return bankFromSwift !== undefined || bankFromName !== undefined;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Checks if an unknown value is a Bank instance.
|
|
180
|
+
* Validates the structural integrity of a bank object.
|
|
181
|
+
*
|
|
182
|
+
* @param {unknown} obj - The value to validate
|
|
183
|
+
* @returns {obj is Bank} Type predicate indicating if the value is a valid Bank
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* const maybeBank = JSON.parse(someData);
|
|
187
|
+
* if (Bank.is(maybeBank)) {
|
|
188
|
+
* console.log(maybeBank.fullName); // maybeBank is typed as Bank
|
|
189
|
+
* }
|
|
190
|
+
*
|
|
191
|
+
* @see {@link Bank.fromSWIFTCode} for creating instances from SWIFT codes
|
|
192
|
+
* @see {@link Bank.fromBankName} for creating instances from bank names
|
|
193
|
+
*/
|
|
194
|
+
static is(obj) {
|
|
195
|
+
if (!obj || typeof obj !== "object")
|
|
196
|
+
return false;
|
|
197
|
+
const maybeBank = obj;
|
|
198
|
+
// Check private properties exist with correct types
|
|
199
|
+
if (typeof maybeBank._fullName !== "string")
|
|
200
|
+
return false;
|
|
201
|
+
if (typeof maybeBank._shortName !== "string")
|
|
202
|
+
return false;
|
|
203
|
+
if (typeof maybeBank._swiftCode !== "string")
|
|
204
|
+
return false;
|
|
205
|
+
// Validate against known banks
|
|
206
|
+
const bankFromSwift = Bank.from(maybeBank._swiftCode);
|
|
207
|
+
const bankFromName = Bank.from(maybeBank._fullName);
|
|
208
|
+
const bankFromName2 = Bank.from(maybeBank._shortName);
|
|
209
|
+
return Boolean(bankFromSwift &&
|
|
210
|
+
bankFromName &&
|
|
211
|
+
bankFromName2 &&
|
|
212
|
+
compare(bankFromName, bankFromName2) &&
|
|
213
|
+
compare(bankFromSwift, bankFromName) &&
|
|
214
|
+
compare(bankFromSwift, bankFromName2));
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Compares two Bank instances for equality by checking their full name, short name, and SWIFT code
|
|
219
|
+
*
|
|
220
|
+
* @param {Bank} bank1 - First bank to compare
|
|
221
|
+
* @param {Bank} bank2 - Second bank to compare
|
|
222
|
+
* @returns {boolean} True if banks are equal, false otherwise
|
|
223
|
+
* @private
|
|
224
|
+
*/
|
|
225
|
+
function compare(bank1, bank2) {
|
|
226
|
+
return (bank1.fullName === bank2.fullName &&
|
|
227
|
+
bank1.shortName === bank2.shortName &&
|
|
228
|
+
bank1.swiftCode === bank2.swiftCode);
|
|
229
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bank.test.d.ts","sourceRoot":"","sources":["../../../../src/src/models/bank/bank.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"banks.d.ts","sourceRoot":"","sources":["../../../../src/src/models/bank/banks.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
export default [
|
|
2
|
+
{
|
|
3
|
+
"fullName": "CRDB BANK PLC",
|
|
4
|
+
"shortName": "CRDB",
|
|
5
|
+
"swiftCode": "CORUTZTZ"
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
"fullName": "PEOPLE'S BANK OF ZANZIBAR LTD",
|
|
9
|
+
"shortName": "PBZ",
|
|
10
|
+
"swiftCode": "PBZATZTZ"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"fullName": "STANDARD CHARTERED BANK (T) LIMITED",
|
|
14
|
+
"shortName": "SCB",
|
|
15
|
+
"swiftCode": "SCBLTZTX"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"fullName": "STANBIC BANK TANZANIA LTD.",
|
|
19
|
+
"shortName": "STANBIC",
|
|
20
|
+
"swiftCode": "SBICTZTX"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"fullName": "CITIBANK TANZANIA LTD",
|
|
24
|
+
"shortName": "CITI",
|
|
25
|
+
"swiftCode": "CITITZTZ"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"fullName": "BANK OF AFRICA TANZANIA LIMITED",
|
|
29
|
+
"shortName": "BOA",
|
|
30
|
+
"swiftCode": "EUAFTZTZ"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"fullName": "DIAMOND TRUST BANK TANZANIA LTD",
|
|
34
|
+
"shortName": "DTB",
|
|
35
|
+
"swiftCode": "DTKETZTZ"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"fullName": "AKIBA COMMERCIAL BANK LTD",
|
|
39
|
+
"shortName": "AKIBA",
|
|
40
|
+
"swiftCode": "AKCOTZTZ"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"fullName": "EXIM BANK (TANZANIA) LTD",
|
|
44
|
+
"shortName": "EXIM",
|
|
45
|
+
"swiftCode": "EXTNTZTZ"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"fullName": "KILIMANJARO CO-OPERATIVE BANK LTD",
|
|
49
|
+
"shortName": "KILIMANJARO",
|
|
50
|
+
"swiftCode": "KLMJTZTZ"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"fullName": "NATIONAL BANK OF COMMERCE LTD",
|
|
54
|
+
"shortName": "NBC",
|
|
55
|
+
"swiftCode": "NLCBTZTX"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"fullName": "NATIONAL MICROFINANCE BANK LIMITED",
|
|
59
|
+
"shortName": "NMB",
|
|
60
|
+
"swiftCode": "NMIBTZTZ"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"fullName": "KCB BANK TANZANIA LIMITED",
|
|
64
|
+
"shortName": "KCB",
|
|
65
|
+
"swiftCode": "KCBLTZTZ"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"fullName": "HABIB AFRICAN BANK LIMITED",
|
|
69
|
+
"shortName": "HABIB",
|
|
70
|
+
"swiftCode": "HABLTZTZ"
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"fullName": "INTERNATIONAL COMMERCIAL BANK (TANZANIA) LIMITED",
|
|
74
|
+
"shortName": "ICB",
|
|
75
|
+
"swiftCode": "BKMYTZTZ"
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"fullName": "ABSA BANK TANZANIA LTD",
|
|
79
|
+
"shortName": "ABSA",
|
|
80
|
+
"swiftCode": "BARCTZTZ"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"fullName": "I&M BANK LIMITED",
|
|
84
|
+
"shortName": "IMBANK",
|
|
85
|
+
"swiftCode": "IMBLTZTZ"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"fullName": "NCBA BANK LIMITED",
|
|
89
|
+
"shortName": "NCBA",
|
|
90
|
+
"swiftCode": "CBAFTZTZ"
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"fullName": "DAR ES SALAAM COMMUNITY BANK LTD",
|
|
94
|
+
"shortName": "DCB",
|
|
95
|
+
"swiftCode": "DASUTZTZ"
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"fullName": "BANK OF BARODA (TANZANIA) LTD",
|
|
99
|
+
"shortName": "BARODA",
|
|
100
|
+
"swiftCode": "BARBTZTZ"
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
"fullName": "AZANIA BANK LIMITED",
|
|
104
|
+
"shortName": "AZANIA",
|
|
105
|
+
"swiftCode": "AZANTZTZ"
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"fullName": "UCHUMI COMMERCIAL BANK (T) LTD",
|
|
109
|
+
"shortName": "UCHUMI",
|
|
110
|
+
"swiftCode": "UCCTTZTZ"
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
"fullName": "AFRICAN BANKING CORPORATION TANZANIA LIMITED",
|
|
114
|
+
"shortName": "BANCABC",
|
|
115
|
+
"swiftCode": "FMBZTZTX"
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
"fullName": "ACCESSBANK TANZANIA LTD",
|
|
119
|
+
"shortName": "ACCESS",
|
|
120
|
+
"swiftCode": "ACTZTZTZ"
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
"fullName": "BANK OF INDIA (TANZANIA) LIMITED",
|
|
124
|
+
"shortName": "BOI",
|
|
125
|
+
"swiftCode": "BKIDTZTZ"
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
"fullName": "UNITED BANK FOR AFRICA (T) LTD",
|
|
129
|
+
"shortName": "UBA",
|
|
130
|
+
"swiftCode": "UNAFTZTZ"
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
"fullName": "MKOMBOZI COMMERCIAL BANK",
|
|
134
|
+
"shortName": "MKOMBOZI",
|
|
135
|
+
"swiftCode": "MKCBTZTZ"
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
"fullName": "ECOBANK TANZANIA LIMITED",
|
|
139
|
+
"shortName": "ECOBANK",
|
|
140
|
+
"swiftCode": "ECOCTZTZ"
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
"fullName": "MWANGA HAKIKA MICROFINANCE BANK LIMITED",
|
|
144
|
+
"shortName": "MWANGA",
|
|
145
|
+
"swiftCode": "MWCBTZTZ"
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
"fullName": "FIRST NATIONAL BANK LIMITED",
|
|
149
|
+
"shortName": "FNB",
|
|
150
|
+
"swiftCode": "FIRNTZTX"
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
"fullName": "AMANA BANK LIMITED",
|
|
154
|
+
"shortName": "AMANA",
|
|
155
|
+
"swiftCode": "AMNNTZTZ"
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
"fullName": "EQUITY BANK TANZANIA LIMITED",
|
|
159
|
+
"shortName": "EQUITY",
|
|
160
|
+
"swiftCode": "EQBLTZTZ"
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
"fullName": "TANZANIA COMMERCIAL BANK PLC",
|
|
164
|
+
"shortName": "TCB",
|
|
165
|
+
"swiftCode": "TAPBTZTZ"
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
"fullName": "MAENDELEO BANK LTD",
|
|
169
|
+
"shortName": "MAENDELEO",
|
|
170
|
+
"swiftCode": "MBTLTZTZ"
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
"fullName": "CANARA BANK TANZANIA LTD",
|
|
174
|
+
"shortName": "CANARA",
|
|
175
|
+
"swiftCode": "CNRBTZTZ"
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
"fullName": "MWALIMU COMMERCIAL BANK PLC",
|
|
179
|
+
"shortName": "MWALIMU",
|
|
180
|
+
"swiftCode": "MWCOTZTZ"
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
"fullName": "GUARANTY TRUST BANK (T) LTD",
|
|
184
|
+
"shortName": "GT BANK",
|
|
185
|
+
"swiftCode": "GTBITZTZ"
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
"fullName": "YETU MICROFINANCE BANK PLC",
|
|
189
|
+
"shortName": "YETU",
|
|
190
|
+
"swiftCode": "YETMTZTZ"
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
"fullName": "CHINA DASHENG BANK LIMITED",
|
|
194
|
+
"shortName": "DASHENG",
|
|
195
|
+
"swiftCode": "CDSHTZTZ"
|
|
196
|
+
}
|
|
197
|
+
];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/src/models/bank/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Regex pattern to validate SWIFT codes.
|
|
3
|
+
* The SWIFT code must follow the format: XXXX XX XX XXX (optional last part for branches).
|
|
4
|
+
* @constant {RegExp}
|
|
5
|
+
*/
|
|
6
|
+
export declare const SWIFT_CODE_REGEX: RegExp;
|
|
7
|
+
/**
|
|
8
|
+
* Retrieves all SWIFT codes from the TZ_BANKS list.
|
|
9
|
+
* @returns {string[]} A list of all SWIFT codes in uppercase.
|
|
10
|
+
*/
|
|
11
|
+
export declare function getAllSwiftCodes(): string[];
|
|
12
|
+
/**
|
|
13
|
+
* Checks whether a given SWIFT code is in the correct format.
|
|
14
|
+
* @param {string} swiftCode The SWIFT code to check.
|
|
15
|
+
* @returns {boolean} `true` if the SWIFT code matches the expected format; `false` otherwise.
|
|
16
|
+
*/
|
|
17
|
+
export declare function isValidSwiftCodeFormat(swiftCode: string): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Validates whether a given SWIFT code is correct.
|
|
20
|
+
* It checks both the SWIFT code format and if the SWIFT code exists in the list of valid codes.
|
|
21
|
+
* @param {string} [swiftCode] The SWIFT code to validate.
|
|
22
|
+
* @returns {boolean} `true` if valid, otherwise `false`.
|
|
23
|
+
*/
|
|
24
|
+
export declare const validateSWIFTCode: (swiftCode?: string) => boolean;
|
|
25
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/src/models/bank/utils.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,QAAgD,CAAC;AAE9E;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,EAAE,CAE3C;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAEjE;AAED;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,eAAgB,MAAM,KAAG,OAQtD,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Bank } from "./bank.js";
|
|
2
|
+
/**
|
|
3
|
+
* Regex pattern to validate SWIFT codes.
|
|
4
|
+
* The SWIFT code must follow the format: XXXX XX XX XXX (optional last part for branches).
|
|
5
|
+
* @constant {RegExp}
|
|
6
|
+
*/
|
|
7
|
+
export const SWIFT_CODE_REGEX = /^[A-Z]{4}[A-Z]{2}[A-Z0-9]{2}([A-Z0-9]{3})?$/;
|
|
8
|
+
/**
|
|
9
|
+
* Retrieves all SWIFT codes from the TZ_BANKS list.
|
|
10
|
+
* @returns {string[]} A list of all SWIFT codes in uppercase.
|
|
11
|
+
*/
|
|
12
|
+
export function getAllSwiftCodes() {
|
|
13
|
+
return Bank.getAll().map((bank) => bank.swiftCode.toUpperCase());
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Checks whether a given SWIFT code is in the correct format.
|
|
17
|
+
* @param {string} swiftCode The SWIFT code to check.
|
|
18
|
+
* @returns {boolean} `true` if the SWIFT code matches the expected format; `false` otherwise.
|
|
19
|
+
*/
|
|
20
|
+
export function isValidSwiftCodeFormat(swiftCode) {
|
|
21
|
+
return SWIFT_CODE_REGEX.test(swiftCode);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Validates whether a given SWIFT code is correct.
|
|
25
|
+
* It checks both the SWIFT code format and if the SWIFT code exists in the list of valid codes.
|
|
26
|
+
* @param {string} [swiftCode] The SWIFT code to validate.
|
|
27
|
+
* @returns {boolean} `true` if valid, otherwise `false`.
|
|
28
|
+
*/
|
|
29
|
+
export const validateSWIFTCode = (swiftCode) => {
|
|
30
|
+
if (!swiftCode)
|
|
31
|
+
return false;
|
|
32
|
+
const normalizedCode = swiftCode.trim().toUpperCase();
|
|
33
|
+
return (isValidSwiftCodeFormat(normalizedCode) &&
|
|
34
|
+
getAllSwiftCodes().includes(normalizedCode));
|
|
35
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/src/models/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { RuleObject } from "antd/es/form";
|
|
2
|
+
import { PhoneNumber } from "./phone_number.js";
|
|
3
|
+
/**
|
|
4
|
+
* Validates a Tanzanian phone number according to specified format rules.
|
|
5
|
+
* This validator is designed for Ant Design Form components and performs the following validations:
|
|
6
|
+
* 1. Required field validation (if specified in rules)
|
|
7
|
+
* 2. Format validation for valid Tanzanian phone numbers using TZ_PHONE_NUMBER_REGEX
|
|
8
|
+
*
|
|
9
|
+
* The validator accepts phone numbers in the following formats:
|
|
10
|
+
* Format 1: With prefix
|
|
11
|
+
* - Starting with 255, 0, or +255
|
|
12
|
+
* - Followed by valid operator codes:
|
|
13
|
+
* • Vodacom: 74, 75, 76, 78, 79
|
|
14
|
+
* • Tigo: 65, 67, 71
|
|
15
|
+
* • Airtel: 68, 69, 77
|
|
16
|
+
* • Halotel: 61, 62
|
|
17
|
+
* - Followed by 7 digits
|
|
18
|
+
*
|
|
19
|
+
* Format 2: Without prefix
|
|
20
|
+
* - Starting directly with operator code (listed above)
|
|
21
|
+
* - Followed by 7 digits
|
|
22
|
+
*
|
|
23
|
+
* @param {RuleObject} rule - Ant Design rule object containing validation rules
|
|
24
|
+
* @param {string | null | undefined} value - The phone number to validate
|
|
25
|
+
* @returns {Promise<void>} Resolves if validation passes, rejects with Error if validation fails
|
|
26
|
+
* @throws {Error} Throws an error with a descriptive message for validation failures:
|
|
27
|
+
* - "Phone number is required." - When field is required but empty/null/undefined
|
|
28
|
+
* - "Invalid phone number format." - When value doesn't match expected TZ phone number format
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* // Usage in Ant Design form rules:
|
|
32
|
+
* const rules = [
|
|
33
|
+
* {
|
|
34
|
+
* required: true,
|
|
35
|
+
* validator: PHONENUMBER_VALIDATOR
|
|
36
|
+
* }
|
|
37
|
+
* ];
|
|
38
|
+
*
|
|
39
|
+
* // Valid inputs:
|
|
40
|
+
* // "+255742345678" -> International format with plus (Vodacom)
|
|
41
|
+
* // "255652345678" -> International format without plus (Tigo)
|
|
42
|
+
* // "0712345678" -> Local format with leading zero (Tigo)
|
|
43
|
+
* // "652345678" -> Local format without prefix (Tigo)
|
|
44
|
+
*
|
|
45
|
+
* // Invalid inputs:
|
|
46
|
+
* // "+255722345678" -> Invalid operator code (72)
|
|
47
|
+
* // "652345" -> Too short
|
|
48
|
+
* // "6523456789" -> Too long
|
|
49
|
+
* // "abc65234567" -> Non-numeric characters
|
|
50
|
+
* // "" -> Empty when required
|
|
51
|
+
* // undefined -> Missing when required
|
|
52
|
+
* // null -> Null when required
|
|
53
|
+
*
|
|
54
|
+
* @notes
|
|
55
|
+
* The validator uses TZ_PHONE_NUMBER_REGEX which matches:
|
|
56
|
+
* ^(?:255|0|\+255)(74|75|76|78|79|68|69|71|65|67|77|62|61)\d{7}$|^(?:74|75|76|78|79|68|69|71|65|67|77|62|61)\d{7}$
|
|
57
|
+
*
|
|
58
|
+
* This breaks down to:
|
|
59
|
+
* ^ -> Start of string
|
|
60
|
+
* (?:255|0|\+255) -> Country code group: 255, 0, or +255
|
|
61
|
+
* ( -> Start operator code group
|
|
62
|
+
* 74|75|76|78|79 -> Vodacom prefixes
|
|
63
|
+
* |68|69|71 -> Tigo prefixes
|
|
64
|
+
* |65|67|77 -> Airtel prefixes
|
|
65
|
+
* |62|61 -> Halotel prefixes
|
|
66
|
+
* ) -> End operator code group
|
|
67
|
+
* \d{7} -> Exactly 7 digits
|
|
68
|
+
* $ -> End of string
|
|
69
|
+
* | -> OR
|
|
70
|
+
* ^ -> Start of string (alternative format)
|
|
71
|
+
* (same operator codes as above)
|
|
72
|
+
* \d{7} -> Exactly 7 digits
|
|
73
|
+
* $ -> End of string
|
|
74
|
+
*/
|
|
75
|
+
export declare const TZ_PHONE_NUMBER_REGEX: RegExp;
|
|
76
|
+
export declare const PHONENUMBER_VALIDATOR: (rule: RuleObject, value: string | null | undefined) => Promise<PhoneNumber | undefined>;
|
|
77
|
+
//# sourceMappingURL=antd_validator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"antd_validator.d.ts","sourceRoot":"","sources":["../../../../src/src/models/phone_number/antd_validator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuEG;AACH,eAAO,MAAM,qBAAqB,QACkF,CAAC;AAErH,eAAO,MAAM,qBAAqB,SAC1B,UAAU,SACT,MAAM,GAAG,IAAI,GAAG,SAAS,KAC/B,OAAO,CAAC,WAAW,GAAG,SAAS,CAiBjC,CAAC"}
|