@cobre-npm/library-onboarding-core 0.4.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.
@@ -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;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
- export * from "./constants/fieldMaxLength";
2
- export * from "./constants/documentAutofillFields";
1
+ export * from "./constants/fieldValidations";
3
2
  export declare const locales: {
4
3
  Shared: {
5
4
  en: {
@@ -1099,10 +1098,6 @@ export declare const locales: {
1099
1098
  ZMB: string;
1100
1099
  ZWE: string;
1101
1100
  };
1102
- validation: {
1103
- required: string;
1104
- invalid: string;
1105
- };
1106
1101
  };
1107
1102
  es: {
1108
1103
  document: {
@@ -2201,10 +2196,6 @@ export declare const locales: {
2201
2196
  ZMB: string;
2202
2197
  ZWE: string;
2203
2198
  };
2204
- validation: {
2205
- required: string;
2206
- invalid: string;
2207
- };
2208
2199
  };
2209
2200
  };
2210
2201
  Summary: {
@@ -2419,6 +2410,14 @@ export declare const locales: {
2419
2410
  beneficial_owners: string;
2420
2411
  maximal_controllers: string;
2421
2412
  };
2413
+ validation: {
2414
+ required: string;
2415
+ invalid: string;
2416
+ nameFormat: string;
2417
+ nameMinLength: string;
2418
+ numericRange: string;
2419
+ emailFormat: string;
2420
+ };
2422
2421
  };
2423
2422
  es: {
2424
2423
  buttons: {
@@ -2483,6 +2482,14 @@ export declare const locales: {
2483
2482
  beneficial_owners: string;
2484
2483
  maximal_controllers: string;
2485
2484
  };
2485
+ validation: {
2486
+ required: string;
2487
+ invalid: string;
2488
+ nameFormat: string;
2489
+ nameMinLength: string;
2490
+ numericRange: string;
2491
+ emailFormat: string;
2492
+ };
2486
2493
  };
2487
2494
  };
2488
2495
  Host: {
package/dist/index.js CHANGED
@@ -26,8 +26,7 @@ const en_json_3 = __importDefault(require("./locales/Common/en.json"));
26
26
  const es_json_3 = __importDefault(require("./locales/Common/es.json"));
27
27
  const en_json_4 = __importDefault(require("./locales/Host/en.json"));
28
28
  const es_json_4 = __importDefault(require("./locales/Host/es.json"));
29
- __exportStar(require("./constants/fieldMaxLength"), exports);
30
- __exportStar(require("./constants/documentAutofillFields"), exports);
29
+ __exportStar(require("./constants/fieldValidations"), exports);
31
30
  exports.locales = {
32
31
  Shared: { en: en_json_1.default, es: es_json_1.default },
33
32
  Summary: { en: en_json_2.default, es: es_json_2.default },
@@ -60,5 +60,13 @@
60
60
  "legal_representatives": "Legal Representatives",
61
61
  "beneficial_owners": "Beneficial Owners",
62
62
  "maximal_controllers": "Maximal Controllers"
63
+ },
64
+ "validation": {
65
+ "required": "This field is required",
66
+ "invalid": "This field is invalid",
67
+ "nameFormat": "Enter a valid name (letters, spaces, apostrophes and hyphens only)",
68
+ "nameMinLength": "Name must be at least {min} characters",
69
+ "numericRange": "Enter a value between {min} and {max}",
70
+ "emailFormat": "Enter a valid email"
63
71
  }
64
72
  }
@@ -60,5 +60,13 @@
60
60
  "legal_representatives": "Representantes Legales",
61
61
  "beneficial_owners": "Beneficiarios Finales",
62
62
  "maximal_controllers": "Controladores Máximos"
63
+ },
64
+ "validation": {
65
+ "required": "Este campo es requerido",
66
+ "invalid": "Este campo es inválido",
67
+ "nameFormat": "Ingresa un nombre válido (solo letras, espacios, apóstrofes y guiones)",
68
+ "nameMinLength": "El nombre debe tener al menos {min} caracteres",
69
+ "numericRange": "Ingresa un valor entre {min} y {max}",
70
+ "emailFormat": "Ingresa un correo válido"
63
71
  }
64
72
  }
@@ -1094,10 +1094,6 @@
1094
1094
  "ZAF": "South Africa",
1095
1095
  "ZMB": "Zambia",
1096
1096
  "ZWE": "Zimbabwe"
1097
- },
1098
- "validation": {
1099
- "required": "This field is required",
1100
- "invalid": "This field is invalid"
1101
1097
  }
1102
1098
  }
1103
1099
 
@@ -1094,10 +1094,6 @@
1094
1094
  "ZAF": "Sudáfrica",
1095
1095
  "ZMB": "Zambia",
1096
1096
  "ZWE": "Zimbabue"
1097
- },
1098
- "validation": {
1099
- "required": "Este campo es requerido",
1100
- "invalid": "Este campo es inválido"
1101
1097
  }
1102
1098
  }
1103
1099
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cobre-npm/library-onboarding-core",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Shared configurations and resources for onboarding MFEs",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -1 +0,0 @@
1
- export declare const DOCUMENT_AUTOFILL_FIELDS: Record<string, string[]>;
@@ -1,36 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DOCUMENT_AUTOFILL_FIELDS = void 0;
4
- exports.DOCUMENT_AUTOFILL_FIELDS = {
5
- certificate_of_incorporation: [
6
- "legal_name", "dba_name", "entity_type", "tax_id_type", "tax_id_number",
7
- "incorporation_date", "incorporation_country", "incorporation_state",
8
- "incorporation_city", "economic_activity", "business_description",
9
- "website", "email", "phone", "registered_address", "operational_address",
10
- ],
11
- tax_id_documentation: [
12
- "tax_id_type", "tax_id_number", "legal_name", "entity_type", "dba_name",
13
- "operations_start_date", "economic_activity", "registered_address",
14
- ],
15
- articles_of_incorporation: [
16
- "legal_name", "entity_type", "dba_name", "incorporation_date",
17
- "incorporation_country", "incorporation_state", "incorporation_city",
18
- "economic_activity", "business_description", "website", "email",
19
- "phone", "registered_address", "operational_address",
20
- ],
21
- shareholder_structure: [
22
- "beneficial_owner[].full_name", "beneficial_owner[].percentage_ownership",
23
- ],
24
- legal_rep_power_of_attorney: [
25
- "legal_representative[].full_name", "legal_representative[].identification[]",
26
- ],
27
- control_documents: [
28
- "beneficial_owner[].full_name", "beneficial_owner[].identification[]",
29
- "beneficial_owner[].birth_date", "beneficial_owner[].country_of_birth",
30
- "beneficial_owner[].nationality", "beneficial_owner[].country_of_residence",
31
- "beneficial_owner[].address", "beneficial_owner[].tax_id_type",
32
- "beneficial_owner[].tax_id_number", "beneficial_owner[].email",
33
- "beneficial_owner[].percentage_ownership",
34
- ],
35
- bank_certificate_30_days: [],
36
- };
@@ -1,3 +0,0 @@
1
- export declare const DEFAULT_MAX_LENGTH = 500;
2
- export declare const DEFAULT_PHONE_MAX_LENGTH = 30;
3
- export declare const FIELD_MAX_LENGTH: Record<string, number>;
@@ -1,42 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FIELD_MAX_LENGTH = exports.DEFAULT_PHONE_MAX_LENGTH = exports.DEFAULT_MAX_LENGTH = void 0;
4
- exports.DEFAULT_MAX_LENGTH = 500;
5
- exports.DEFAULT_PHONE_MAX_LENGTH = 30;
6
- exports.FIELD_MAX_LENGTH = {
7
- full_name: 200,
8
- phone: 30,
9
- legal_name: 300,
10
- dba_name: 300,
11
- tax_id_number: 50,
12
- e_sign_number: 50,
13
- incorporation_state: 100,
14
- incorporation_city: 100,
15
- business_description: 2000,
16
- website: 500,
17
- line_1: 200,
18
- line_2: 200,
19
- city: 100,
20
- state: 100,
21
- postal_code: 20,
22
- tax_id_type: 50,
23
- curp: 18,
24
- migration_status: 100,
25
- migration_form_number: 50,
26
- nationality: 100,
27
- birth_country: 100,
28
- country_of_birth: 100,
29
- country_of_residence: 100,
30
- state_of_birth: 100,
31
- occupation: 200,
32
- number: 50,
33
- first_name: 100,
34
- middle_name: 100,
35
- last_name: 100,
36
- company_relationship: 200,
37
- public_office_position: 500,
38
- legal_proceedings_description: 5000,
39
- funds_source_other_description: 1000,
40
- monthly_counterparties_count: 100,
41
- third_party_id: 100,
42
- };