@cobre-npm/library-onboarding-core 0.3.0 → 0.5.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/dist/constants/fieldValidations.d.ts +23 -0
- package/dist/constants/fieldValidations.js +72 -0
- package/dist/index.d.ts +2706 -0
- package/dist/index.js +35 -0
- package/{src → dist}/locales/Common/en.json +8 -0
- package/{src → dist}/locales/Common/es.json +8 -0
- package/{src → dist}/locales/Shared/en.json +0 -4
- package/{src → dist}/locales/Shared/es.json +0 -4
- package/package.json +18 -8
- package/src/index.d.ts +0 -17
- package/src/index.js +0 -17
- /package/{src → dist}/locales/Host/en.json +0 -0
- /package/{src → dist}/locales/Host/es.json +0 -0
- /package/{src → dist}/locales/Summary/en.json +0 -0
- /package/{src → dist}/locales/Summary/es.json +0 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export declare const DEFAULT_MAX_LENGTH = 500;
|
|
2
|
+
export declare const DEFAULT_PHONE_MAX_LENGTH = 30;
|
|
3
|
+
export declare const DEFAULT_NAME_MIN_LENGTH = 2;
|
|
4
|
+
export type FieldValidationRule = {
|
|
5
|
+
readonly kind: "name";
|
|
6
|
+
readonly minLength: number;
|
|
7
|
+
} | {
|
|
8
|
+
readonly kind: "numericRange";
|
|
9
|
+
readonly min: number;
|
|
10
|
+
readonly max: number;
|
|
11
|
+
} | {
|
|
12
|
+
readonly kind: "pastDate";
|
|
13
|
+
readonly minAgeYears?: number;
|
|
14
|
+
};
|
|
15
|
+
export interface FieldValidation {
|
|
16
|
+
readonly maxLength?: number;
|
|
17
|
+
readonly rule?: FieldValidationRule;
|
|
18
|
+
}
|
|
19
|
+
export declare const FIELD_VALIDATIONS: Record<string, FieldValidation>;
|
|
20
|
+
export declare const getFieldValidation: (fieldName: string) => FieldValidation | undefined;
|
|
21
|
+
export declare const getFieldRule: (fieldName: string) => FieldValidationRule | undefined;
|
|
22
|
+
export declare const getFieldMaxLength: (fieldName: string, fallback?: number) => number;
|
|
23
|
+
export declare const hasFieldValidation: (fieldName: string) => boolean;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Single source of truth for per-field-name validation, keyed by data point name.
|
|
4
|
+
* Each entry declares everything the front enforces on a field — its max length
|
|
5
|
+
* AND its semantic rule (person-name format, numeric range, past-date cap).
|
|
6
|
+
*
|
|
7
|
+
* Replaces the former fieldMaxLength.ts: max lengths are now just one facet of a
|
|
8
|
+
* field's validation. Consumers turn these declarations into their own runtime
|
|
9
|
+
* (input validation, date bounds); this module holds data + pure lookups only.
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.hasFieldValidation = exports.getFieldMaxLength = exports.getFieldRule = exports.getFieldValidation = exports.FIELD_VALIDATIONS = exports.DEFAULT_NAME_MIN_LENGTH = exports.DEFAULT_PHONE_MAX_LENGTH = exports.DEFAULT_MAX_LENGTH = void 0;
|
|
13
|
+
// Fallback max length when a field declares none.
|
|
14
|
+
exports.DEFAULT_MAX_LENGTH = 500;
|
|
15
|
+
// Fallback max length for phone fields specifically.
|
|
16
|
+
exports.DEFAULT_PHONE_MAX_LENGTH = 30;
|
|
17
|
+
// A name must be at least this many characters when a rule omits its own.
|
|
18
|
+
exports.DEFAULT_NAME_MIN_LENGTH = 2;
|
|
19
|
+
exports.FIELD_VALIDATIONS = {
|
|
20
|
+
// Person names — max length + name-format rule. Never legal_name/dba_name (may carry digits/&).
|
|
21
|
+
full_name: { maxLength: 200, rule: { kind: "name", minLength: exports.DEFAULT_NAME_MIN_LENGTH } },
|
|
22
|
+
first_name: { maxLength: 100, rule: { kind: "name", minLength: exports.DEFAULT_NAME_MIN_LENGTH } },
|
|
23
|
+
middle_name: { maxLength: 100, rule: { kind: "name", minLength: exports.DEFAULT_NAME_MIN_LENGTH } },
|
|
24
|
+
last_name: { maxLength: 100, rule: { kind: "name", minLength: exports.DEFAULT_NAME_MIN_LENGTH } },
|
|
25
|
+
// Date rules — capped at today (or minAgeYears back for birth dates).
|
|
26
|
+
incorporation_date: { rule: { kind: "pastDate" } },
|
|
27
|
+
operations_start_date: { rule: { kind: "pastDate" } },
|
|
28
|
+
birth_date: { rule: { kind: "pastDate", minAgeYears: 18 } },
|
|
29
|
+
// Percentage KYC data points.
|
|
30
|
+
percentage_ownership: { rule: { kind: "numericRange", min: 1, max: 100 } },
|
|
31
|
+
cash_transaction_percentage: { rule: { kind: "numericRange", min: 0, max: 100 } },
|
|
32
|
+
// Length-only fields.
|
|
33
|
+
phone: { maxLength: exports.DEFAULT_PHONE_MAX_LENGTH },
|
|
34
|
+
legal_name: { maxLength: 300 },
|
|
35
|
+
dba_name: { maxLength: 300 },
|
|
36
|
+
tax_id_number: { maxLength: 50 },
|
|
37
|
+
e_sign_number: { maxLength: 50 },
|
|
38
|
+
incorporation_state: { maxLength: 100 },
|
|
39
|
+
incorporation_city: { maxLength: 100 },
|
|
40
|
+
business_description: { maxLength: 2000 },
|
|
41
|
+
website: { maxLength: 500 },
|
|
42
|
+
line_1: { maxLength: 200 },
|
|
43
|
+
line_2: { maxLength: 200 },
|
|
44
|
+
city: { maxLength: 100 },
|
|
45
|
+
state: { maxLength: 100 },
|
|
46
|
+
postal_code: { maxLength: 20 },
|
|
47
|
+
tax_id_type: { maxLength: 50 },
|
|
48
|
+
curp: { maxLength: 18 },
|
|
49
|
+
migration_status: { maxLength: 100 },
|
|
50
|
+
migration_form_number: { maxLength: 50 },
|
|
51
|
+
nationality: { maxLength: 100 },
|
|
52
|
+
birth_country: { maxLength: 100 },
|
|
53
|
+
country_of_birth: { maxLength: 100 },
|
|
54
|
+
country_of_residence: { maxLength: 100 },
|
|
55
|
+
state_of_birth: { maxLength: 100 },
|
|
56
|
+
occupation: { maxLength: 200 },
|
|
57
|
+
number: { maxLength: 50 },
|
|
58
|
+
company_relationship: { maxLength: 200 },
|
|
59
|
+
public_office_position: { maxLength: 500 },
|
|
60
|
+
legal_proceedings_description: { maxLength: 5000 },
|
|
61
|
+
funds_source_other_description: { maxLength: 1000 },
|
|
62
|
+
monthly_counterparties_count: { maxLength: 100 },
|
|
63
|
+
third_party_id: { maxLength: 100 },
|
|
64
|
+
};
|
|
65
|
+
const getFieldValidation = (fieldName) => exports.FIELD_VALIDATIONS[fieldName];
|
|
66
|
+
exports.getFieldValidation = getFieldValidation;
|
|
67
|
+
const getFieldRule = (fieldName) => exports.FIELD_VALIDATIONS[fieldName]?.rule;
|
|
68
|
+
exports.getFieldRule = getFieldRule;
|
|
69
|
+
const getFieldMaxLength = (fieldName, fallback = exports.DEFAULT_MAX_LENGTH) => exports.FIELD_VALIDATIONS[fieldName]?.maxLength ?? fallback;
|
|
70
|
+
exports.getFieldMaxLength = getFieldMaxLength;
|
|
71
|
+
const hasFieldValidation = (fieldName) => (0, exports.getFieldValidation)(fieldName) !== undefined;
|
|
72
|
+
exports.hasFieldValidation = hasFieldValidation;
|