@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
|
+
// Regex explanation:
|
|
2
|
+
// ^(?:\d{1,3}(?:,\d{3})*|\d+) - Either grouped digits with commas OR just digits
|
|
3
|
+
// (?:\.\d+)?$ - Optional decimal part with any number of digits
|
|
4
|
+
const AMOUNT_REGEX = /^(?:\d{1,3}(?:,\d{3})*|\d+)(?:\.\d+)?$/;
|
|
5
|
+
class Amount {
|
|
6
|
+
constructor(value, text) {
|
|
7
|
+
Object.defineProperty(this, "value", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
configurable: true,
|
|
10
|
+
writable: true,
|
|
11
|
+
value: void 0
|
|
12
|
+
});
|
|
13
|
+
Object.defineProperty(this, "text", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
configurable: true,
|
|
16
|
+
writable: true,
|
|
17
|
+
value: void 0
|
|
18
|
+
});
|
|
19
|
+
this.value = value;
|
|
20
|
+
this.text = text;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Creates an Amount instance from a string or number input
|
|
24
|
+
* Returns undefined if input is invalid or negative
|
|
25
|
+
* @param input - The input value (string or number)
|
|
26
|
+
* @returns Amount instance or undefined if validation fails
|
|
27
|
+
*/
|
|
28
|
+
static from(input) {
|
|
29
|
+
let amountText = input.toString().trim();
|
|
30
|
+
console.log(amountText);
|
|
31
|
+
if (hasComma(amountText)) {
|
|
32
|
+
if (!hasValidCommaPlacement(amountText))
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
amountText = removeCommasAndCurrency(amountText);
|
|
36
|
+
// Handle string input
|
|
37
|
+
if (!AMOUNT_REGEX.test(amountText))
|
|
38
|
+
return undefined;
|
|
39
|
+
// Convert string to number, removing commas
|
|
40
|
+
const value = Number(amountText.replace(/,/g, ""));
|
|
41
|
+
if (!Number.isFinite(value) || value < 0)
|
|
42
|
+
return undefined;
|
|
43
|
+
// Round to 2 decimal places and format the text representation
|
|
44
|
+
const roundedValue = Number(value.toFixed(2));
|
|
45
|
+
const text = roundedValue.toLocaleString("en-US", {
|
|
46
|
+
minimumFractionDigits: 2,
|
|
47
|
+
maximumFractionDigits: 2,
|
|
48
|
+
});
|
|
49
|
+
return new Amount(roundedValue, text);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Returns the formatted string representation of the amount with TZS prefix
|
|
53
|
+
*/
|
|
54
|
+
get label() {
|
|
55
|
+
return `TZS ${this.text}`;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Returns the numeric value of the amount
|
|
59
|
+
*/
|
|
60
|
+
get numericValue() {
|
|
61
|
+
return this.value;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Returns the formatted numeric value of the amount
|
|
65
|
+
*/
|
|
66
|
+
get formattedNumericValue() {
|
|
67
|
+
return this.numericValue.toLocaleString("en-US", {
|
|
68
|
+
minimumFractionDigits: 2,
|
|
69
|
+
maximumFractionDigits: 2,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Checks if the amount is valid
|
|
74
|
+
* @param input amount to be checked for validity
|
|
75
|
+
* @returns true if the amount is valid, false otherwise
|
|
76
|
+
*/
|
|
77
|
+
static canConstruct(input) {
|
|
78
|
+
/// (!input) alone does not work since input could 0 and (!input) return true for this case
|
|
79
|
+
if (input === undefined || input === null)
|
|
80
|
+
return false;
|
|
81
|
+
const amount = Amount.from(input);
|
|
82
|
+
if (!amount)
|
|
83
|
+
return false;
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Checks if an unknown value is an Amount instance.
|
|
88
|
+
* Validates the structural integrity of an amount object.
|
|
89
|
+
*
|
|
90
|
+
* @param {unknown} obj - The value to validate
|
|
91
|
+
* @returns {obj is Amount} Type predicate indicating if the value is a valid Amount
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* const maybeAmount = JSON.parse(someData);
|
|
95
|
+
* if (Amount.is(maybeAmount)) {
|
|
96
|
+
* console.log(maybeAmount.label); // maybeAmount is typed as Amount
|
|
97
|
+
* }
|
|
98
|
+
*
|
|
99
|
+
* @see {@link Amount.canConstruct} for validating raw amount values
|
|
100
|
+
* @see {@link Amount.from} for constructing new instances
|
|
101
|
+
*/
|
|
102
|
+
static is(obj) {
|
|
103
|
+
if (!obj || typeof obj !== "object")
|
|
104
|
+
return false;
|
|
105
|
+
const maybeAmount = obj;
|
|
106
|
+
// Check required properties exist with correct types
|
|
107
|
+
if (typeof maybeAmount.value !== "number")
|
|
108
|
+
return false;
|
|
109
|
+
if (typeof maybeAmount.text !== "string")
|
|
110
|
+
return false;
|
|
111
|
+
const value = maybeAmount.value;
|
|
112
|
+
const text = maybeAmount.text;
|
|
113
|
+
// Validate numeric constraints
|
|
114
|
+
if (!Number.isFinite(value) || value < 0)
|
|
115
|
+
return false;
|
|
116
|
+
const canConstruct = Amount.canConstruct(value);
|
|
117
|
+
if (!canConstruct)
|
|
118
|
+
return false;
|
|
119
|
+
const amount = Amount.from(value);
|
|
120
|
+
return amount != undefined && amount.value === value &&
|
|
121
|
+
amount.text === text;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Checks the validity of the amount data
|
|
125
|
+
* @returns true if the amount data is available and valid
|
|
126
|
+
*/
|
|
127
|
+
validate() {
|
|
128
|
+
try {
|
|
129
|
+
return Amount.canConstruct(this.value);
|
|
130
|
+
}
|
|
131
|
+
catch (_) {
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Removes commas and "TZS" symbol (if present) from a string.
|
|
138
|
+
* Handles both prefixed and suffixed "TZS" symbols, with or without spaces.
|
|
139
|
+
*
|
|
140
|
+
* @param {string} text - The input string to clean
|
|
141
|
+
* @returns {string} A string with commas and "TZS" symbol removed
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* removeCommasAndCurrency("1,234.56"); // Returns: "1234.56"
|
|
145
|
+
* removeCommasAndCurrency("TZS 1,234.56"); // Returns: "1234.56"
|
|
146
|
+
* removeCommasAndCurrency("1,234.56 TZS"); // Returns: "1234.56"
|
|
147
|
+
* removeCommasAndCurrency("TZS1,234.56"); // Returns: "1234.56"
|
|
148
|
+
* removeCommasAndCurrency("1234.56"); // Returns: "1234.56"
|
|
149
|
+
* removeCommasAndCurrency(""); // Returns: ""
|
|
150
|
+
*
|
|
151
|
+
* @remarks
|
|
152
|
+
* - Case insensitive for "TZS" symbol
|
|
153
|
+
* - Removes all commas regardless of position
|
|
154
|
+
* - Handles optional spaces around the currency symbol
|
|
155
|
+
* - Returns empty string if input is empty
|
|
156
|
+
*/
|
|
157
|
+
function removeCommasAndCurrency(text) {
|
|
158
|
+
return text
|
|
159
|
+
.replace(/TZS\s*|\s*TZS/gi, "") // Remove TZS with optional spaces
|
|
160
|
+
.replace(/,/g, ""); // Remove all commas
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Checks if commas in a numeric string are correctly placed to separate groups of three digits.
|
|
164
|
+
* Only validates the part before the decimal point if one exists.
|
|
165
|
+
*
|
|
166
|
+
* @param {string} text - The input string to validate
|
|
167
|
+
* @returns {boolean} True if commas are correctly placed or if there are no commas, false otherwise
|
|
168
|
+
*
|
|
169
|
+
* @example
|
|
170
|
+
* hasValidCommaPlacement("1,234,567.89"); // Returns: true
|
|
171
|
+
* hasValidCommaPlacement("1234567.89"); // Returns: true (no commas)
|
|
172
|
+
* hasValidCommaPlacement("1,234.56"); // Returns: true
|
|
173
|
+
* hasValidCommaPlacement("1,23,456"); // Returns: false (incorrect grouping)
|
|
174
|
+
* hasValidCommaPlacement("1,2345"); // Returns: false (incorrect grouping)
|
|
175
|
+
* hasValidCommaPlacement(",123"); // Returns: false (leading comma)
|
|
176
|
+
* hasValidCommaPlacement("1,234,"); // Returns: false (trailing comma)
|
|
177
|
+
* hasValidCommaPlacement("1,,234"); // Returns: false (consecutive commas)
|
|
178
|
+
*
|
|
179
|
+
* @remarks
|
|
180
|
+
* - Validates comma placement in the whole number part only
|
|
181
|
+
* - Each group after the first must be exactly 3 digits
|
|
182
|
+
* - First group can be 1-3 digits
|
|
183
|
+
* - Returns true if the string contains no commas
|
|
184
|
+
* - Does not validate the decimal part if present
|
|
185
|
+
*/
|
|
186
|
+
function hasValidCommaPlacement(text) {
|
|
187
|
+
// Split at decimal point if it exists and take the whole number part
|
|
188
|
+
const wholeNumberPart = text.split(".")[0];
|
|
189
|
+
// If no commas, it's valid
|
|
190
|
+
if (!wholeNumberPart.includes(",")) {
|
|
191
|
+
return true;
|
|
192
|
+
}
|
|
193
|
+
// Split the whole number by commas
|
|
194
|
+
const groups = wholeNumberPart.split(",");
|
|
195
|
+
// Check for invalid cases:
|
|
196
|
+
// - Empty string before/after comma (e.g. ",123" or "123,")
|
|
197
|
+
// - More than one empty group (consecutive commas)
|
|
198
|
+
if (groups.some((group) => group.length === 0)) {
|
|
199
|
+
return false;
|
|
200
|
+
}
|
|
201
|
+
// First group can be 1-3 digits
|
|
202
|
+
if (groups[0].length > 3 || groups[0].length < 1) {
|
|
203
|
+
return false;
|
|
204
|
+
}
|
|
205
|
+
// All other groups must be exactly 3 digits
|
|
206
|
+
return groups.slice(1).every((group) => group.length === 3);
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Checks if a string contains a comma character.
|
|
210
|
+
*
|
|
211
|
+
* @param {string} text - The input string to check
|
|
212
|
+
* @returns {boolean} True if the string contains at least one comma, false otherwise
|
|
213
|
+
*
|
|
214
|
+
* @example
|
|
215
|
+
* hasComma("1,234.56"); // Returns: true
|
|
216
|
+
* hasComma("1234.56"); // Returns: false
|
|
217
|
+
* hasComma("hello,world"); // Returns: true
|
|
218
|
+
* hasComma(""); // Returns: false
|
|
219
|
+
* hasComma(","); // Returns: true
|
|
220
|
+
*
|
|
221
|
+
* @remarks
|
|
222
|
+
* - Returns false for empty strings
|
|
223
|
+
* - Returns true if one or more commas are present
|
|
224
|
+
* - Position of the comma doesn't matter
|
|
225
|
+
*/
|
|
226
|
+
function hasComma(text) {
|
|
227
|
+
return text.includes(",");
|
|
228
|
+
}
|
|
229
|
+
export { Amount, AMOUNT_REGEX };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"amount.test.d.ts","sourceRoot":"","sources":["../../../../src/src/models/amount/amount.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { RuleObject } from "antd/es/form";
|
|
2
|
+
import { Amount } from "./index.js";
|
|
3
|
+
/**
|
|
4
|
+
* Validates a monetary amount according to specified business 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 using AMOUNT_REGEX pattern for valid numeric format
|
|
8
|
+
* 3. Minimum amount threshold of TZS 1,000
|
|
9
|
+
*
|
|
10
|
+
* @param {RuleObject} rule - Ant Design rule object containing validation rules
|
|
11
|
+
* @param {string | number | undefined} value - The amount to validate
|
|
12
|
+
* @returns {Promise<void>} Resolves if validation passes, rejects with Error if validation fails
|
|
13
|
+
* @throws {Error} Throws an error with a descriptive message for validation failures:
|
|
14
|
+
* - "Amount is required." - When field is required but empty/undefined
|
|
15
|
+
* - "Invalid amount format." - When value doesn't match expected numeric format
|
|
16
|
+
* - "Invalid numeric value." - When value can't be parsed to a valid number
|
|
17
|
+
* - "Amount must not be less than TZS 1000." - When value is below minimum threshold
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* // Usage in Ant Design form rules:
|
|
21
|
+
* const rules = [
|
|
22
|
+
* {
|
|
23
|
+
* required: true,
|
|
24
|
+
* validator: AMOUNT_VALIDATOR
|
|
25
|
+
* }
|
|
26
|
+
* ];
|
|
27
|
+
*
|
|
28
|
+
* // Valid inputs:
|
|
29
|
+
* // "1,000" -> Valid format, meets minimum
|
|
30
|
+
* // "1500.50" -> Valid decimal
|
|
31
|
+
* // 2000 -> Valid number
|
|
32
|
+
*
|
|
33
|
+
* // Invalid inputs:
|
|
34
|
+
* // "abc" -> Invalid format
|
|
35
|
+
* // "500" -> Below minimum
|
|
36
|
+
* // "" -> Empty when required
|
|
37
|
+
* // undefined -> Missing when required
|
|
38
|
+
*/
|
|
39
|
+
export declare const AMOUNT_VALIDATOR: (rule: RuleObject, value: string | number | null | undefined) => Promise<Amount | undefined>;
|
|
40
|
+
//# sourceMappingURL=antd_validator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"antd_validator.d.ts","sourceRoot":"","sources":["../../../../src/src/models/amount/antd_validator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEpC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,eAAO,MAAM,gBAAgB,SACrB,UAAU,SACT,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,KACxC,OAAO,CAAC,MAAM,GAAG,SAAS,CA0B5B,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Amount } from "./index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Validates a monetary amount according to specified business rules.
|
|
4
|
+
* This validator is designed for Ant Design Form components and performs the following validations:
|
|
5
|
+
* 1. Required field validation (if specified in rules)
|
|
6
|
+
* 2. Format validation using AMOUNT_REGEX pattern for valid numeric format
|
|
7
|
+
* 3. Minimum amount threshold of TZS 1,000
|
|
8
|
+
*
|
|
9
|
+
* @param {RuleObject} rule - Ant Design rule object containing validation rules
|
|
10
|
+
* @param {string | number | undefined} value - The amount to validate
|
|
11
|
+
* @returns {Promise<void>} Resolves if validation passes, rejects with Error if validation fails
|
|
12
|
+
* @throws {Error} Throws an error with a descriptive message for validation failures:
|
|
13
|
+
* - "Amount is required." - When field is required but empty/undefined
|
|
14
|
+
* - "Invalid amount format." - When value doesn't match expected numeric format
|
|
15
|
+
* - "Invalid numeric value." - When value can't be parsed to a valid number
|
|
16
|
+
* - "Amount must not be less than TZS 1000." - When value is below minimum threshold
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* // Usage in Ant Design form rules:
|
|
20
|
+
* const rules = [
|
|
21
|
+
* {
|
|
22
|
+
* required: true,
|
|
23
|
+
* validator: AMOUNT_VALIDATOR
|
|
24
|
+
* }
|
|
25
|
+
* ];
|
|
26
|
+
*
|
|
27
|
+
* // Valid inputs:
|
|
28
|
+
* // "1,000" -> Valid format, meets minimum
|
|
29
|
+
* // "1500.50" -> Valid decimal
|
|
30
|
+
* // 2000 -> Valid number
|
|
31
|
+
*
|
|
32
|
+
* // Invalid inputs:
|
|
33
|
+
* // "abc" -> Invalid format
|
|
34
|
+
* // "500" -> Below minimum
|
|
35
|
+
* // "" -> Empty when required
|
|
36
|
+
* // undefined -> Missing when required
|
|
37
|
+
*/
|
|
38
|
+
export const AMOUNT_VALIDATOR = (rule, value) => {
|
|
39
|
+
// Convert value to string and remove whitespace
|
|
40
|
+
const amountString = value?.toString().trim();
|
|
41
|
+
// If field is empty/undefined/null
|
|
42
|
+
if (!amountString) {
|
|
43
|
+
// Only throw if the field is required
|
|
44
|
+
if (rule.required) {
|
|
45
|
+
return Promise.reject(new Error("Amount is required."));
|
|
46
|
+
}
|
|
47
|
+
// If field is not required and empty, validation passes
|
|
48
|
+
return Promise.resolve(undefined);
|
|
49
|
+
}
|
|
50
|
+
const amount = Amount.from(amountString);
|
|
51
|
+
if (!amount) {
|
|
52
|
+
return Promise.reject(new Error("Invalid amount format."));
|
|
53
|
+
}
|
|
54
|
+
if (amount.numericValue < 1000) {
|
|
55
|
+
return Promise.reject(new Error("Amount must not be less than TZS 1000."));
|
|
56
|
+
}
|
|
57
|
+
return Promise.resolve(amount);
|
|
58
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"antd_validator.test.d.ts","sourceRoot":"","sources":["../../../../src/src/models/amount/antd_validator.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/src/models/amount/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { RuleObject } from "antd/es/form";
|
|
2
|
+
import { Bank } from "./bank.js";
|
|
3
|
+
/**
|
|
4
|
+
* Validator for SWIFT code field.
|
|
5
|
+
* Ensures the SWIFT code follows the correct format and is recognized in the list of valid codes.
|
|
6
|
+
* @param {RuleObject} rule The rule object for validation
|
|
7
|
+
* @param {string} value The value to validate.
|
|
8
|
+
* @throws Will throw an error if validation fails.
|
|
9
|
+
*/
|
|
10
|
+
export declare const SWIFT_CODE_VALIDATOR: (rule: RuleObject, value: string | null | undefined) => Promise<Bank | undefined>;
|
|
11
|
+
//# sourceMappingURL=antd_validator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"antd_validator.d.ts","sourceRoot":"","sources":["../../../../src/src/models/bank/antd_validator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,SACzB,UAAU,SACT,MAAM,GAAG,IAAI,GAAG,SAAS,KAC/B,OAAO,CAAC,IAAI,GAAG,SAAS,CAoB1B,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Bank } from "./bank.js";
|
|
2
|
+
/**
|
|
3
|
+
* Validator for SWIFT code field.
|
|
4
|
+
* Ensures the SWIFT code follows the correct format and is recognized in the list of valid codes.
|
|
5
|
+
* @param {RuleObject} rule The rule object for validation
|
|
6
|
+
* @param {string} value The value to validate.
|
|
7
|
+
* @throws Will throw an error if validation fails.
|
|
8
|
+
*/
|
|
9
|
+
export const SWIFT_CODE_VALIDATOR = (rule, value) => {
|
|
10
|
+
const code = value?.toString().trim().toUpperCase();
|
|
11
|
+
// If field is empty/undefined/null
|
|
12
|
+
if (!code) {
|
|
13
|
+
// Only throw if the field is required
|
|
14
|
+
if (rule.required) {
|
|
15
|
+
return Promise.reject(new Error("SWIFT code is required."));
|
|
16
|
+
}
|
|
17
|
+
// If field is not required and empty, validation passes
|
|
18
|
+
return Promise.resolve(undefined);
|
|
19
|
+
}
|
|
20
|
+
const bank = Bank.fromSWIFTCode(code);
|
|
21
|
+
if (!bank) {
|
|
22
|
+
const error = new Error("SWIFT code is not recognized.");
|
|
23
|
+
return Promise.reject(error);
|
|
24
|
+
}
|
|
25
|
+
return Promise.resolve(bank);
|
|
26
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"antd_validator.test.d.ts","sourceRoot":"","sources":["../../../../src/src/models/bank/antd_validator.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents a bank with essential details.
|
|
3
|
+
* @class Bank
|
|
4
|
+
*/
|
|
5
|
+
export declare class Bank {
|
|
6
|
+
private readonly _fullName;
|
|
7
|
+
private readonly _shortName;
|
|
8
|
+
private readonly _swiftCode;
|
|
9
|
+
/**
|
|
10
|
+
* Creates a new Bank instance.
|
|
11
|
+
* @param {string} _fullName - The full name of the bank
|
|
12
|
+
* @param {string} _shortName - The short name or abbreviated name of the bank
|
|
13
|
+
* @param {string} _swiftCode - The SWIFT code associated with the bank
|
|
14
|
+
*/
|
|
15
|
+
constructor(_fullName: string, _shortName: string, _swiftCode: string);
|
|
16
|
+
/**
|
|
17
|
+
* Gets the full name of the bank.
|
|
18
|
+
* @returns {string} The full name of the bank
|
|
19
|
+
*/
|
|
20
|
+
get fullName(): string;
|
|
21
|
+
/**
|
|
22
|
+
* Gets the short name of the bank.
|
|
23
|
+
* @returns {string} The short name of the bank
|
|
24
|
+
*/
|
|
25
|
+
get shortName(): string;
|
|
26
|
+
/**
|
|
27
|
+
* Gets the SWIFT code of the bank.
|
|
28
|
+
* @returns {string} The SWIFT code of the bank
|
|
29
|
+
*/
|
|
30
|
+
get swiftCode(): string;
|
|
31
|
+
/**
|
|
32
|
+
* Creates a string representation of the bank.
|
|
33
|
+
* @returns {string} String representation of the bank
|
|
34
|
+
*/
|
|
35
|
+
toString(): string;
|
|
36
|
+
/**
|
|
37
|
+
* Retrieves a bank by its SWIFT code.
|
|
38
|
+
* @param {string} swiftCode The SWIFT code of the bank.
|
|
39
|
+
* @returns {Bank | undefined} The bank corresponding to the SWIFT code or `undefined` if not found.
|
|
40
|
+
*/
|
|
41
|
+
static fromSWIFTCode(swiftCode: string): Bank | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* Retrieves a bank by its short or full name.
|
|
44
|
+
* @param {string} bankName The full name of the bank.
|
|
45
|
+
* @returns {Bank | undefined} The bank corresponding to the full name or `undefined` if not found.
|
|
46
|
+
*/
|
|
47
|
+
static fromBankName(bankName: string): Bank | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* Validates if a given SWIFT/BIC (Bank Identifier Code) is valid
|
|
50
|
+
*
|
|
51
|
+
* @param {string | null | undefined} swiftCode - The SWIFT/BIC code to validate.
|
|
52
|
+
* Should be in the format of 8 or 11 characters (e.g., 'NMIBTZTZ' or 'CRDBTZTZXXX').
|
|
53
|
+
*
|
|
54
|
+
* @returns {boolean} Returns true if:
|
|
55
|
+
* - The SWIFT code is not null/undefined
|
|
56
|
+
* - The SWIFT code successfully creates a valid Bank instance
|
|
57
|
+
* Returns false otherwise.
|
|
58
|
+
*/
|
|
59
|
+
static isValidSwiftCode(swiftCode?: string | null): boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Validates if a given bank name is valid
|
|
62
|
+
*
|
|
63
|
+
* @param {string | null | undefined} bankName - The bank name to validate.
|
|
64
|
+
* Should be either 'CRDB' or 'NMB'.
|
|
65
|
+
*
|
|
66
|
+
* @returns {boolean} Returns true if:
|
|
67
|
+
* - The bank name is not null/undefined
|
|
68
|
+
* - The bank name successfully creates a valid Bank instance
|
|
69
|
+
* Returns false otherwise.
|
|
70
|
+
*/
|
|
71
|
+
static isValidBankName(bankName?: string | null): boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Gets all banks from the JSON data.
|
|
74
|
+
* @returns {Bank[]} Array of all banks
|
|
75
|
+
*/
|
|
76
|
+
static getAll(): Bank[];
|
|
77
|
+
/**
|
|
78
|
+
* Checks the validity of the bank data
|
|
79
|
+
* @returns true if the bank information is available and valid
|
|
80
|
+
*/
|
|
81
|
+
validate(): boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Attempts to create a Bank instance from a bank name or SWIFT code
|
|
84
|
+
* First tries to create from bank name, then from SWIFT code if bank name fails
|
|
85
|
+
*
|
|
86
|
+
* @param {string} input - The bank name or SWIFT code
|
|
87
|
+
* @returns {Bank | undefined} A Bank instance if valid input, undefined otherwise
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* const bank = Bank.from('CORUTZTZ'); // From SWIFT code
|
|
91
|
+
* const sameBank = Bank.from('CRDB'); // From bank name
|
|
92
|
+
*/
|
|
93
|
+
static from(input: string): Bank | undefined;
|
|
94
|
+
/**
|
|
95
|
+
* Validates if the input can be used to construct a valid Bank instance
|
|
96
|
+
* Checks if the input resolves to the same bank via both name and SWIFT code
|
|
97
|
+
*
|
|
98
|
+
* @param {string | null | undefined} input - The bank name or SWIFT code to validate
|
|
99
|
+
* @returns {boolean} True if input can construct a valid bank, false otherwise
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* Bank.canConstruct('CORUTZTZ'); // true
|
|
103
|
+
* Bank.canConstruct(''); // false
|
|
104
|
+
* Bank.canConstruct(null); // false
|
|
105
|
+
*/
|
|
106
|
+
static canConstruct(input?: string | null): boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Checks if an unknown value is a Bank instance.
|
|
109
|
+
* Validates the structural integrity of a bank object.
|
|
110
|
+
*
|
|
111
|
+
* @param {unknown} obj - The value to validate
|
|
112
|
+
* @returns {obj is Bank} Type predicate indicating if the value is a valid Bank
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* const maybeBank = JSON.parse(someData);
|
|
116
|
+
* if (Bank.is(maybeBank)) {
|
|
117
|
+
* console.log(maybeBank.fullName); // maybeBank is typed as Bank
|
|
118
|
+
* }
|
|
119
|
+
*
|
|
120
|
+
* @see {@link Bank.fromSWIFTCode} for creating instances from SWIFT codes
|
|
121
|
+
* @see {@link Bank.fromBankName} for creating instances from bank names
|
|
122
|
+
*/
|
|
123
|
+
static is(obj: unknown): obj is Bank;
|
|
124
|
+
}
|
|
125
|
+
//# sourceMappingURL=bank.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bank.d.ts","sourceRoot":"","sources":["../../../../src/src/models/bank/bank.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,qBAAa,IAAI;IAQb,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,UAAU;IAT7B;;;;;OAKG;gBAEgB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM;IAGrC;;;OAGG;IACH,IAAI,QAAQ,IAAI,MAAM,CAErB;IAED;;;OAGG;IACH,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED;;;OAGG;IACH,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED;;;OAGG;IACH,QAAQ,IAAI,MAAM;IAIlB;;;;OAIG;IACH,MAAM,CAAC,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS;IAMzD;;;;OAIG;IACH,MAAM,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS;IAOvD;;;;;;;;;;OAUG;IACH,MAAM,CAAC,gBAAgB,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO;IAM3D;;;;;;;;;;OAUG;IACH,MAAM,CAAC,eAAe,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO;IAMzD;;;OAGG;IACH,MAAM,CAAC,MAAM,IAAI,IAAI,EAAE;IAWvB;;;OAGG;IACI,QAAQ,IAAI,OAAO;IAY1B;;;;;;;;;;OAUG;WACW,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS;IAYnD;;;;;;;;;;;OAWG;WACW,YAAY,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO;IAY1D;;;;;;;;;;;;;;;OAeG;WACW,EAAE,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,IAAI;CAwB5C"}
|