@cobre-npm/library-onboarding-core 0.7.4 → 0.7.5
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.
|
@@ -14,6 +14,7 @@ export type FieldValidationRule = {
|
|
|
14
14
|
};
|
|
15
15
|
export interface FieldValidation {
|
|
16
16
|
readonly maxLength?: number;
|
|
17
|
+
readonly minLength?: number;
|
|
17
18
|
readonly rule?: FieldValidationRule;
|
|
18
19
|
readonly noSpaces?: boolean;
|
|
19
20
|
}
|
|
@@ -21,5 +22,6 @@ export declare const FIELD_VALIDATIONS: Record<string, FieldValidation>;
|
|
|
21
22
|
export declare const getFieldValidation: (fieldName: string) => FieldValidation | undefined;
|
|
22
23
|
export declare const getFieldRule: (fieldName: string) => FieldValidationRule | undefined;
|
|
23
24
|
export declare const getFieldMaxLength: (fieldName: string, fallback?: number) => number;
|
|
25
|
+
export declare const getFieldMinLength: (fieldName: string) => number | undefined;
|
|
24
26
|
export declare const disallowsSpaces: (fieldName: string) => boolean;
|
|
25
27
|
export declare const hasFieldValidation: (fieldName: string) => boolean;
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* (input validation, date bounds); this module holds data + pure lookups only.
|
|
10
10
|
*/
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.hasFieldValidation = exports.disallowsSpaces = 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;
|
|
12
|
+
exports.hasFieldValidation = exports.disallowsSpaces = exports.getFieldMinLength = 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
13
|
// Fallback max length when a field declares none.
|
|
14
14
|
exports.DEFAULT_MAX_LENGTH = 500;
|
|
15
15
|
// Fallback max length for phone fields specifically.
|
|
@@ -39,7 +39,7 @@ exports.FIELD_VALIDATIONS = {
|
|
|
39
39
|
third_party_id: { maxLength: 100, noSpaces: true },
|
|
40
40
|
email: { noSpaces: true },
|
|
41
41
|
// Length-only fields.
|
|
42
|
-
phone: { maxLength: exports.DEFAULT_PHONE_MAX_LENGTH },
|
|
42
|
+
phone: { minLength: 2, maxLength: exports.DEFAULT_PHONE_MAX_LENGTH },
|
|
43
43
|
legal_name: { maxLength: 300 },
|
|
44
44
|
dba_name: { maxLength: 300 },
|
|
45
45
|
incorporation_state: { maxLength: 100 },
|
|
@@ -70,6 +70,9 @@ const getFieldRule = (fieldName) => exports.FIELD_VALIDATIONS[fieldName]?.rule;
|
|
|
70
70
|
exports.getFieldRule = getFieldRule;
|
|
71
71
|
const getFieldMaxLength = (fieldName, fallback = exports.DEFAULT_MAX_LENGTH) => exports.FIELD_VALIDATIONS[fieldName]?.maxLength ?? fallback;
|
|
72
72
|
exports.getFieldMaxLength = getFieldMaxLength;
|
|
73
|
+
// Undefined when the field declares no floor — consumers skip the check entirely.
|
|
74
|
+
const getFieldMinLength = (fieldName) => exports.FIELD_VALIDATIONS[fieldName]?.minLength;
|
|
75
|
+
exports.getFieldMinLength = getFieldMinLength;
|
|
73
76
|
const disallowsSpaces = (fieldName) => exports.FIELD_VALIDATIONS[fieldName]?.noSpaces === true;
|
|
74
77
|
exports.disallowsSpaces = disallowsSpaces;
|
|
75
78
|
const hasFieldValidation = (fieldName) => (0, exports.getFieldValidation)(fieldName) !== undefined;
|
package/dist/index.d.ts
CHANGED
|
@@ -2419,8 +2419,14 @@ export declare const locales: {
|
|
|
2419
2419
|
invalid: string;
|
|
2420
2420
|
nameFormat: string;
|
|
2421
2421
|
nameMinLength: string;
|
|
2422
|
+
numericOnly: string;
|
|
2422
2423
|
numericRange: string;
|
|
2424
|
+
alphanumericOnly: string;
|
|
2425
|
+
minLength: string;
|
|
2426
|
+
maxLength: string;
|
|
2423
2427
|
emailFormat: string;
|
|
2428
|
+
urlFormat: string;
|
|
2429
|
+
phoneFormat: string;
|
|
2424
2430
|
};
|
|
2425
2431
|
};
|
|
2426
2432
|
es: {
|
|
@@ -2493,8 +2499,14 @@ export declare const locales: {
|
|
|
2493
2499
|
invalid: string;
|
|
2494
2500
|
nameFormat: string;
|
|
2495
2501
|
nameMinLength: string;
|
|
2502
|
+
numericOnly: string;
|
|
2496
2503
|
numericRange: string;
|
|
2504
|
+
alphanumericOnly: string;
|
|
2505
|
+
minLength: string;
|
|
2506
|
+
maxLength: string;
|
|
2497
2507
|
emailFormat: string;
|
|
2508
|
+
urlFormat: string;
|
|
2509
|
+
phoneFormat: string;
|
|
2498
2510
|
};
|
|
2499
2511
|
};
|
|
2500
2512
|
};
|
|
@@ -66,9 +66,15 @@
|
|
|
66
66
|
"validation": {
|
|
67
67
|
"required": "This field is required",
|
|
68
68
|
"invalid": "This field is invalid",
|
|
69
|
-
"nameFormat": "
|
|
69
|
+
"nameFormat": "Use only letters, spaces, apostrophes and hyphens",
|
|
70
70
|
"nameMinLength": "Name must be at least {min} characters",
|
|
71
|
+
"numericOnly": "Use digits only, no letters or symbols",
|
|
71
72
|
"numericRange": "Enter a value between {min} and {max}",
|
|
72
|
-
"
|
|
73
|
+
"alphanumericOnly": "Use letters and numbers only",
|
|
74
|
+
"minLength": "Must be at least {min} characters",
|
|
75
|
+
"maxLength": "Cannot exceed {max} characters",
|
|
76
|
+
"emailFormat": "Enter a valid email (e.g. name@company.com)",
|
|
77
|
+
"urlFormat": "Enter a valid website (e.g. company.com)",
|
|
78
|
+
"phoneFormat": "Use digits only for the phone number"
|
|
73
79
|
}
|
|
74
80
|
}
|
|
@@ -66,9 +66,15 @@
|
|
|
66
66
|
"validation": {
|
|
67
67
|
"required": "Este campo es requerido",
|
|
68
68
|
"invalid": "Este campo es inválido",
|
|
69
|
-
"nameFormat": "
|
|
69
|
+
"nameFormat": "Usa solo letras, espacios, apóstrofes y guiones",
|
|
70
70
|
"nameMinLength": "El nombre debe tener al menos {min} caracteres",
|
|
71
|
+
"numericOnly": "Usa solo números, sin letras ni símbolos",
|
|
71
72
|
"numericRange": "Ingresa un valor entre {min} y {max}",
|
|
72
|
-
"
|
|
73
|
+
"alphanumericOnly": "Usa solo letras y números",
|
|
74
|
+
"minLength": "Debe tener al menos {min} caracteres",
|
|
75
|
+
"maxLength": "No puede tener más de {max} caracteres",
|
|
76
|
+
"emailFormat": "Ingresa un correo válido (ej. nombre@empresa.com)",
|
|
77
|
+
"urlFormat": "Ingresa un sitio web válido (ej. empresa.com)",
|
|
78
|
+
"phoneFormat": "Usa solo números en el teléfono"
|
|
73
79
|
}
|
|
74
80
|
}
|