@pedidopago/ui 1.5.19 → 1.5.20
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/components/Icon/data/dash.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -0
- package/dist/shared/types/credit-card.d.ts +6 -0
- package/dist/shared/types/credit-card.d.ts.map +1 -0
- package/dist/shared/types/credit-card.js +1 -0
- package/dist/shared/types/file.d.ts +12 -0
- package/dist/shared/types/file.d.ts.map +1 -0
- package/dist/shared/types/file.js +1 -0
- package/dist/shared/types/name.d.ts +4 -0
- package/dist/shared/types/name.d.ts.map +1 -0
- package/dist/shared/types/name.js +1 -0
- package/dist/utils/file.d.ts +27 -0
- package/dist/utils/file.d.ts.map +1 -0
- package/dist/utils/file.js +160 -0
- package/dist/utils/formatters/bytes.d.ts +8 -0
- package/dist/utils/formatters/bytes.d.ts.map +1 -0
- package/dist/utils/formatters/bytes.js +22 -0
- package/dist/utils/formatters/capitalize.d.ts +7 -0
- package/dist/utils/formatters/capitalize.d.ts.map +1 -0
- package/dist/utils/formatters/capitalize.js +15 -0
- package/dist/utils/formatters/cep.d.ts +13 -0
- package/dist/utils/formatters/cep.d.ts.map +1 -0
- package/dist/utils/formatters/cep.js +26 -0
- package/dist/utils/formatters/cnpj.d.ts +19 -0
- package/dist/utils/formatters/cnpj.d.ts.map +1 -0
- package/dist/utils/formatters/cnpj.js +54 -0
- package/dist/utils/formatters/color.d.ts +16 -0
- package/dist/utils/formatters/color.d.ts.map +1 -0
- package/dist/utils/formatters/color.js +111 -0
- package/dist/utils/formatters/cpf.d.ts +19 -0
- package/dist/utils/formatters/cpf.d.ts.map +1 -0
- package/dist/utils/formatters/cpf.js +101 -0
- package/dist/utils/formatters/credit-card.d.ts +27 -0
- package/dist/utils/formatters/credit-card.d.ts.map +1 -0
- package/dist/utils/formatters/credit-card.js +80 -0
- package/dist/utils/formatters/email.d.ts +2 -0
- package/dist/utils/formatters/email.d.ts.map +1 -0
- package/dist/utils/formatters/email.js +8 -0
- package/dist/utils/formatters/index.d.ts +16 -0
- package/dist/utils/formatters/index.d.ts.map +1 -0
- package/dist/utils/formatters/index.js +200 -0
- package/dist/utils/formatters/name.d.ts +21 -0
- package/dist/utils/formatters/name.d.ts.map +1 -0
- package/dist/utils/formatters/name.js +46 -0
- package/dist/utils/formatters/number.d.ts +7 -0
- package/dist/utils/formatters/number.d.ts.map +1 -0
- package/dist/utils/formatters/number.js +18 -0
- package/dist/utils/formatters/passport.d.ts +25 -0
- package/dist/utils/formatters/passport.d.ts.map +1 -0
- package/dist/utils/formatters/passport.js +49 -0
- package/dist/utils/formatters/phone.d.ts +60 -0
- package/dist/utils/formatters/phone.d.ts.map +1 -0
- package/dist/utils/formatters/phone.js +209 -0
- package/dist/utils/formatters/price.d.ts +12 -0
- package/dist/utils/formatters/price.d.ts.map +1 -0
- package/dist/utils/formatters/price.js +28 -0
- package/dist/utils/formatters/rg.d.ts +13 -0
- package/dist/utils/formatters/rg.d.ts.map +1 -0
- package/dist/utils/formatters/rg.js +26 -0
- package/dist/utils/formatters/strings.d.ts +20 -0
- package/dist/utils/formatters/strings.d.ts.map +1 -0
- package/dist/utils/formatters/strings.js +42 -0
- package/package.json +4 -3
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.formatCPF = formatCPF;
|
|
7
|
+
exports.sanitizeCPF = sanitizeCPF;
|
|
8
|
+
exports.validateCPF = validateCPF;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Formats a CPF string to a standard format.
|
|
12
|
+
* @param {string} cpf - The CPF string to format.
|
|
13
|
+
* @returns {string} The formatted CPF string.
|
|
14
|
+
*/
|
|
15
|
+
function formatCPF(cpf) {
|
|
16
|
+
// Initialize an empty string to store the formatted CPF
|
|
17
|
+
var result = ''; // Check if a CPF string was provided
|
|
18
|
+
|
|
19
|
+
if (cpf) {
|
|
20
|
+
// Remove any non-numeric characters from the string and take the first 11 digits
|
|
21
|
+
var sanitizedCpf = cpf.replace(/[^\d*]/g, '').substring(0, 11); // Loop through the sanitized CPF string and add formatting characters in the appropriate positions
|
|
22
|
+
|
|
23
|
+
for (var i = 0, n = Math.min(sanitizedCpf.length, 11); i < n; i++) {
|
|
24
|
+
result += sanitizedCpf[i];
|
|
25
|
+
|
|
26
|
+
if (i + 1 < n) {
|
|
27
|
+
if (i === 2 || i === 5) result += '.';else if (i === 8) result += '-';
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
} // Return the formatted CPF string
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
return result;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Sanitizes a CPF string by removing all non-numeric characters and taking only the first 11 digits.
|
|
37
|
+
* @param {string} cpf - The CPF string to sanitize.
|
|
38
|
+
* @returns {string} The sanitized CPF string.
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
function sanitizeCPF(cpf) {
|
|
43
|
+
// Return an empty string if no CPF was provided
|
|
44
|
+
if (!cpf) {
|
|
45
|
+
return '';
|
|
46
|
+
} // Remove all non-numeric characters from the string and take the first 11 digits
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
return cpf.replace(/\D/g, '').substring(0, 11);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Validates a CPF string using the Brazilian CPF algorithm.
|
|
53
|
+
* @param {string} cpf - The CPF string to validate.
|
|
54
|
+
* @returns {boolean} True if the CPF is valid, false otherwise.
|
|
55
|
+
*/
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
function validateCPF(cpf) {
|
|
59
|
+
// Sanitize the CPF string by removing all non-numeric characters and taking only the first 11 digits
|
|
60
|
+
var sanitizedCpf = sanitizeCPF(cpf); // Return true if no CPF was provided
|
|
61
|
+
|
|
62
|
+
if (sanitizedCpf.length === 0) {
|
|
63
|
+
return true;
|
|
64
|
+
} // Check if all digits in the CPF are the same
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
if (/^(\d)\1+$/.test(sanitizedCpf)) {
|
|
68
|
+
return false;
|
|
69
|
+
} // Validate the CPF using the Brazilian CPF algorithm
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
if (sanitizedCpf.length === 11) {
|
|
73
|
+
var digits = [0, 0];
|
|
74
|
+
|
|
75
|
+
for (var i = 0; i < 9; i++) {
|
|
76
|
+
digits[0] += Number(sanitizedCpf[i]) * (10 - i);
|
|
77
|
+
digits[1] += Number(sanitizedCpf[i]) * (11 - i);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
digits[0] = digits[0] % 11;
|
|
81
|
+
|
|
82
|
+
if (digits[0] > 1) {
|
|
83
|
+
digits[0] = 11 - digits[0];
|
|
84
|
+
} else {
|
|
85
|
+
digits[0] = 0;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
digits[1] = (digits[1] + digits[0] * 2) % 11;
|
|
89
|
+
|
|
90
|
+
if (digits[1] > 1) {
|
|
91
|
+
digits[1] = 11 - digits[1];
|
|
92
|
+
} else {
|
|
93
|
+
digits[1] = 0;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return sanitizedCpf[9] === digits[0].toString() && sanitizedCpf[10] === digits[1].toString();
|
|
97
|
+
} // Return false if the CPF is not valid
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { CreditCardOptions } from 'src/shared/types/credit-card';
|
|
2
|
+
/**
|
|
3
|
+
* Format a credit card number by adding spaces after every four digits, up to a maximum of 19 characters.
|
|
4
|
+
* @param {string} creditCardNumber - The credit card number to format
|
|
5
|
+
* @returns {string} The formatted credit card number
|
|
6
|
+
*/
|
|
7
|
+
export declare function formatCreditCardNumber(creditCardNumber: string): string;
|
|
8
|
+
/**
|
|
9
|
+
* Sanitize a credit card number by removing all non-numeric characters and leading zeros.
|
|
10
|
+
* @param {string} creditCardNumber - The credit card number to sanitize
|
|
11
|
+
* @returns {string} The sanitized credit card number
|
|
12
|
+
*/
|
|
13
|
+
export declare function sanitizeCreditCardNumber(creditCardNumber: string): string;
|
|
14
|
+
/**
|
|
15
|
+
* Format a credit card expiration date by adding a slash between the month and year components.
|
|
16
|
+
* @param {string} value - The expiration date to format
|
|
17
|
+
* @returns {string} The formatted expiration date
|
|
18
|
+
*/
|
|
19
|
+
export declare function formatCreditCardExpirationDate(value: string): string;
|
|
20
|
+
/**
|
|
21
|
+
* Validate a credit card expiration date by checking if it is a valid date in the future.
|
|
22
|
+
* @param {string} value - The expiration date to validate
|
|
23
|
+
* @param {CreditCardOptions} options - An object containing the following properties: monthErrorMessage, yearErrorMessage, dateErrorMessage
|
|
24
|
+
* @returns {boolean | string} true if the expiration date is valid, or an error message otherwise
|
|
25
|
+
*/
|
|
26
|
+
export declare function validateCreditCardExpirationDate(value: string, { monthErrorMessage, yearErrorMessage, dateErrorMessage, }: CreditCardOptions): boolean | string;
|
|
27
|
+
//# sourceMappingURL=credit-card.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credit-card.d.ts","sourceRoot":"","sources":["../../../src/utils/formatters/credit-card.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAEjE;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,gBAAgB,EAAE,MAAM,GAAG,MAAM,CAKvE;AACD;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,gBAAgB,EAAE,MAAM,GAAG,MAAM,CAEzE;AACD;;;;GAIG;AACH,wBAAgB,8BAA8B,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAIpE;AAED;;;;;GAKG;AACH,wBAAgB,gCAAgC,CAC9C,KAAK,EAAE,MAAM,EACb,EACE,iBAAgD,EAChD,gBAA8C,EAC9C,gBAA8C,GAC/C,EAAE,iBAAiB,GACnB,OAAO,GAAG,MAAM,CAuBlB"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.formatCreditCardExpirationDate = formatCreditCardExpirationDate;
|
|
7
|
+
exports.formatCreditCardNumber = formatCreditCardNumber;
|
|
8
|
+
exports.sanitizeCreditCardNumber = sanitizeCreditCardNumber;
|
|
9
|
+
exports.validateCreditCardExpirationDate = validateCreditCardExpirationDate;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Format a credit card number by adding spaces after every four digits, up to a maximum of 19 characters.
|
|
13
|
+
* @param {string} creditCardNumber - The credit card number to format
|
|
14
|
+
* @returns {string} The formatted credit card number
|
|
15
|
+
*/
|
|
16
|
+
function formatCreditCardNumber(creditCardNumber) {
|
|
17
|
+
return creditCardNumber.replace(/\D/g, '').replace(/(\d{4})(\d)/g, '$1 $2').substring(0, 19);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Sanitize a credit card number by removing all non-numeric characters and leading zeros.
|
|
21
|
+
* @param {string} creditCardNumber - The credit card number to sanitize
|
|
22
|
+
* @returns {string} The sanitized credit card number
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
function sanitizeCreditCardNumber(creditCardNumber) {
|
|
27
|
+
return creditCardNumber ? creditCardNumber.replace(/\D/g, '').replace(/^0+/, '') : '';
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Format a credit card expiration date by adding a slash between the month and year components.
|
|
31
|
+
* @param {string} value - The expiration date to format
|
|
32
|
+
* @returns {string} The formatted expiration date
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
function formatCreditCardExpirationDate(value) {
|
|
37
|
+
var month = value.replace(/\D/g, '').substring(0, 2);
|
|
38
|
+
var year = value.replace(/\D/g, '').substring(2, 6);
|
|
39
|
+
return month + (value.length > 2 ? '/' : '') + year;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Validate a credit card expiration date by checking if it is a valid date in the future.
|
|
43
|
+
* @param {string} value - The expiration date to validate
|
|
44
|
+
* @param {CreditCardOptions} options - An object containing the following properties: monthErrorMessage, yearErrorMessage, dateErrorMessage
|
|
45
|
+
* @returns {boolean | string} true if the expiration date is valid, or an error message otherwise
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
function validateCreditCardExpirationDate(value, _ref) {
|
|
50
|
+
var _ref$monthErrorMessag = _ref.monthErrorMessage,
|
|
51
|
+
monthErrorMessage = _ref$monthErrorMessag === void 0 ? 'Please enter a valid month' : _ref$monthErrorMessag,
|
|
52
|
+
_ref$yearErrorMessage = _ref.yearErrorMessage,
|
|
53
|
+
yearErrorMessage = _ref$yearErrorMessage === void 0 ? 'Please enter a valid year' : _ref$yearErrorMessage,
|
|
54
|
+
_ref$dateErrorMessage = _ref.dateErrorMessage,
|
|
55
|
+
dateErrorMessage = _ref$dateErrorMessage === void 0 ? 'Please enter a valid date' : _ref$dateErrorMessage;
|
|
56
|
+
|
|
57
|
+
if (value.length === 0) {
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
var month = value.substring(0, 2);
|
|
62
|
+
var year = value.substring(3, 7);
|
|
63
|
+
|
|
64
|
+
if (month.length === 2 && (Number(month) < 1 || Number(month) > 12)) {
|
|
65
|
+
return monthErrorMessage;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (year.length === 0 || year.length < 4 && Number(year) < new Date().getFullYear()) {
|
|
69
|
+
return yearErrorMessage;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
var validateDate = new Date(Number(year), Number(month) - 1, 1);
|
|
73
|
+
var today = new Date();
|
|
74
|
+
|
|
75
|
+
if (validateDate < today && validateDate.getMonth() !== today.getMonth()) {
|
|
76
|
+
return dateErrorMessage;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email.d.ts","sourceRoot":"","sources":["../../../src/utils/formatters/email.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,QAA8C,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export * from './bytes';
|
|
2
|
+
export * from './capitalize';
|
|
3
|
+
export * from './cep';
|
|
4
|
+
export * from './cnpj';
|
|
5
|
+
export * from './color';
|
|
6
|
+
export * from './cpf';
|
|
7
|
+
export * from './credit-card';
|
|
8
|
+
export * from './email';
|
|
9
|
+
export * from './name';
|
|
10
|
+
export * from './number';
|
|
11
|
+
export * from './passport';
|
|
12
|
+
export * from './phone';
|
|
13
|
+
export * from './price';
|
|
14
|
+
export * from './rg';
|
|
15
|
+
export * from './strings';
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/formatters/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,MAAM,CAAC;AACrB,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
var _bytes = require("./bytes");
|
|
8
|
+
|
|
9
|
+
Object.keys(_bytes).forEach(function (key) {
|
|
10
|
+
if (key === "default" || key === "__esModule") return;
|
|
11
|
+
if (key in exports && exports[key] === _bytes[key]) return;
|
|
12
|
+
Object.defineProperty(exports, key, {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function get() {
|
|
15
|
+
return _bytes[key];
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
var _capitalize = require("./capitalize");
|
|
21
|
+
|
|
22
|
+
Object.keys(_capitalize).forEach(function (key) {
|
|
23
|
+
if (key === "default" || key === "__esModule") return;
|
|
24
|
+
if (key in exports && exports[key] === _capitalize[key]) return;
|
|
25
|
+
Object.defineProperty(exports, key, {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function get() {
|
|
28
|
+
return _capitalize[key];
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
var _cep = require("./cep");
|
|
34
|
+
|
|
35
|
+
Object.keys(_cep).forEach(function (key) {
|
|
36
|
+
if (key === "default" || key === "__esModule") return;
|
|
37
|
+
if (key in exports && exports[key] === _cep[key]) return;
|
|
38
|
+
Object.defineProperty(exports, key, {
|
|
39
|
+
enumerable: true,
|
|
40
|
+
get: function get() {
|
|
41
|
+
return _cep[key];
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
var _cnpj = require("./cnpj");
|
|
47
|
+
|
|
48
|
+
Object.keys(_cnpj).forEach(function (key) {
|
|
49
|
+
if (key === "default" || key === "__esModule") return;
|
|
50
|
+
if (key in exports && exports[key] === _cnpj[key]) return;
|
|
51
|
+
Object.defineProperty(exports, key, {
|
|
52
|
+
enumerable: true,
|
|
53
|
+
get: function get() {
|
|
54
|
+
return _cnpj[key];
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
var _color = require("./color");
|
|
60
|
+
|
|
61
|
+
Object.keys(_color).forEach(function (key) {
|
|
62
|
+
if (key === "default" || key === "__esModule") return;
|
|
63
|
+
if (key in exports && exports[key] === _color[key]) return;
|
|
64
|
+
Object.defineProperty(exports, key, {
|
|
65
|
+
enumerable: true,
|
|
66
|
+
get: function get() {
|
|
67
|
+
return _color[key];
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
var _cpf = require("./cpf");
|
|
73
|
+
|
|
74
|
+
Object.keys(_cpf).forEach(function (key) {
|
|
75
|
+
if (key === "default" || key === "__esModule") return;
|
|
76
|
+
if (key in exports && exports[key] === _cpf[key]) return;
|
|
77
|
+
Object.defineProperty(exports, key, {
|
|
78
|
+
enumerable: true,
|
|
79
|
+
get: function get() {
|
|
80
|
+
return _cpf[key];
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
var _creditCard = require("./credit-card");
|
|
86
|
+
|
|
87
|
+
Object.keys(_creditCard).forEach(function (key) {
|
|
88
|
+
if (key === "default" || key === "__esModule") return;
|
|
89
|
+
if (key in exports && exports[key] === _creditCard[key]) return;
|
|
90
|
+
Object.defineProperty(exports, key, {
|
|
91
|
+
enumerable: true,
|
|
92
|
+
get: function get() {
|
|
93
|
+
return _creditCard[key];
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
var _email = require("./email");
|
|
99
|
+
|
|
100
|
+
Object.keys(_email).forEach(function (key) {
|
|
101
|
+
if (key === "default" || key === "__esModule") return;
|
|
102
|
+
if (key in exports && exports[key] === _email[key]) return;
|
|
103
|
+
Object.defineProperty(exports, key, {
|
|
104
|
+
enumerable: true,
|
|
105
|
+
get: function get() {
|
|
106
|
+
return _email[key];
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
var _name = require("./name");
|
|
112
|
+
|
|
113
|
+
Object.keys(_name).forEach(function (key) {
|
|
114
|
+
if (key === "default" || key === "__esModule") return;
|
|
115
|
+
if (key in exports && exports[key] === _name[key]) return;
|
|
116
|
+
Object.defineProperty(exports, key, {
|
|
117
|
+
enumerable: true,
|
|
118
|
+
get: function get() {
|
|
119
|
+
return _name[key];
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
var _number = require("./number");
|
|
125
|
+
|
|
126
|
+
Object.keys(_number).forEach(function (key) {
|
|
127
|
+
if (key === "default" || key === "__esModule") return;
|
|
128
|
+
if (key in exports && exports[key] === _number[key]) return;
|
|
129
|
+
Object.defineProperty(exports, key, {
|
|
130
|
+
enumerable: true,
|
|
131
|
+
get: function get() {
|
|
132
|
+
return _number[key];
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
var _passport = require("./passport");
|
|
138
|
+
|
|
139
|
+
Object.keys(_passport).forEach(function (key) {
|
|
140
|
+
if (key === "default" || key === "__esModule") return;
|
|
141
|
+
if (key in exports && exports[key] === _passport[key]) return;
|
|
142
|
+
Object.defineProperty(exports, key, {
|
|
143
|
+
enumerable: true,
|
|
144
|
+
get: function get() {
|
|
145
|
+
return _passport[key];
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
var _phone = require("./phone");
|
|
151
|
+
|
|
152
|
+
Object.keys(_phone).forEach(function (key) {
|
|
153
|
+
if (key === "default" || key === "__esModule") return;
|
|
154
|
+
if (key in exports && exports[key] === _phone[key]) return;
|
|
155
|
+
Object.defineProperty(exports, key, {
|
|
156
|
+
enumerable: true,
|
|
157
|
+
get: function get() {
|
|
158
|
+
return _phone[key];
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
var _price = require("./price");
|
|
164
|
+
|
|
165
|
+
Object.keys(_price).forEach(function (key) {
|
|
166
|
+
if (key === "default" || key === "__esModule") return;
|
|
167
|
+
if (key in exports && exports[key] === _price[key]) return;
|
|
168
|
+
Object.defineProperty(exports, key, {
|
|
169
|
+
enumerable: true,
|
|
170
|
+
get: function get() {
|
|
171
|
+
return _price[key];
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
var _rg = require("./rg");
|
|
177
|
+
|
|
178
|
+
Object.keys(_rg).forEach(function (key) {
|
|
179
|
+
if (key === "default" || key === "__esModule") return;
|
|
180
|
+
if (key in exports && exports[key] === _rg[key]) return;
|
|
181
|
+
Object.defineProperty(exports, key, {
|
|
182
|
+
enumerable: true,
|
|
183
|
+
get: function get() {
|
|
184
|
+
return _rg[key];
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
var _strings = require("./strings");
|
|
190
|
+
|
|
191
|
+
Object.keys(_strings).forEach(function (key) {
|
|
192
|
+
if (key === "default" || key === "__esModule") return;
|
|
193
|
+
if (key in exports && exports[key] === _strings[key]) return;
|
|
194
|
+
Object.defineProperty(exports, key, {
|
|
195
|
+
enumerable: true,
|
|
196
|
+
get: function get() {
|
|
197
|
+
return _strings[key];
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { NameOptions } from 'src/shared/types/name';
|
|
2
|
+
/**
|
|
3
|
+
* Remove spaces at the start and end of the string
|
|
4
|
+
* @param {string} name - The name to remove spaces from
|
|
5
|
+
* @returns {string} The name without spaces at the start and end
|
|
6
|
+
*/
|
|
7
|
+
export declare function removeSpaces(name: string): string;
|
|
8
|
+
/**
|
|
9
|
+
* Remove excessive spaces from the name
|
|
10
|
+
* @param {string} name - The name to format
|
|
11
|
+
* @returns {string} The formatted name
|
|
12
|
+
*/
|
|
13
|
+
export declare function formatName(name: string): string;
|
|
14
|
+
/**
|
|
15
|
+
* Validate the name and check if it only contains letters, spaces, or apostrophes
|
|
16
|
+
* @param {string} name - The name to validate
|
|
17
|
+
* @param {NameOptions} options - An object containing the following properties: characterErrorMessage (default: 'The character(s) "{0}" is(are) not allowed.')
|
|
18
|
+
* @returns {boolean|string} true if the name is valid, otherwise an error message
|
|
19
|
+
*/
|
|
20
|
+
export declare function nameIsValid(name: string, { errorMessage }: NameOptions): boolean | string;
|
|
21
|
+
//# sourceMappingURL=name.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"name.d.ts","sourceRoot":"","sources":["../../../src/utils/formatters/name.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEjD;AACD;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAG/C;AACD;;;;;GAKG;AACH,wBAAgB,WAAW,CACzB,IAAI,EAAE,MAAM,EACZ,EAAE,YAA4D,EAAE,EAAE,WAAW,GAC5E,OAAO,GAAG,MAAM,CASlB"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.formatName = formatName;
|
|
7
|
+
exports.nameIsValid = nameIsValid;
|
|
8
|
+
exports.removeSpaces = removeSpaces;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Remove spaces at the start and end of the string
|
|
12
|
+
* @param {string} name - The name to remove spaces from
|
|
13
|
+
* @returns {string} The name without spaces at the start and end
|
|
14
|
+
*/
|
|
15
|
+
function removeSpaces(name) {
|
|
16
|
+
return name.trimStart().trimEnd();
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Remove excessive spaces from the name
|
|
20
|
+
* @param {string} name - The name to format
|
|
21
|
+
* @returns {string} The formatted name
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
function formatName(name) {
|
|
26
|
+
if (!name) return '';
|
|
27
|
+
return String(name).replace(/\s+/g, ' ');
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Validate the name and check if it only contains letters, spaces, or apostrophes
|
|
31
|
+
* @param {string} name - The name to validate
|
|
32
|
+
* @param {NameOptions} options - An object containing the following properties: characterErrorMessage (default: 'The character(s) "{0}" is(are) not allowed.')
|
|
33
|
+
* @returns {boolean|string} true if the name is valid, otherwise an error message
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
function nameIsValid(name, _ref) {
|
|
38
|
+
var _ref$errorMessage = _ref.errorMessage,
|
|
39
|
+
errorMessage = _ref$errorMessage === void 0 ? 'The character(s) "{0}" is(are) not allowed.' : _ref$errorMessage;
|
|
40
|
+
if (name.length === 1 && name.match(/[\u0300-\u036f]/)) return false;
|
|
41
|
+
var regex = /([a-zA-Z]|[à-ü]|[À-Ü]|\s|')/g;
|
|
42
|
+
var match = name.match(regex);
|
|
43
|
+
if ((match === null || match === void 0 ? void 0 : match.length) === name.length) return true;
|
|
44
|
+
var notAllowedCharacters = name.replace(regex, '');
|
|
45
|
+
return errorMessage.replace('{0}', notAllowedCharacters);
|
|
46
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sanitizes the input number string by removing non-numeric characters, converting commas to dots for decimal separation, and removing excess dots
|
|
3
|
+
* @param {string} number - Input string to sanitize
|
|
4
|
+
* @returns {string} - Sanitized number string
|
|
5
|
+
*/
|
|
6
|
+
export declare function sanitizeNumber(number: string): string;
|
|
7
|
+
//# sourceMappingURL=number.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"number.d.ts","sourceRoot":"","sources":["../../../src/utils/formatters/number.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAOrD"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.sanitizeNumber = sanitizeNumber;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Sanitizes the input number string by removing non-numeric characters, converting commas to dots for decimal separation, and removing excess dots
|
|
10
|
+
* @param {string} number - Input string to sanitize
|
|
11
|
+
* @returns {string} - Sanitized number string
|
|
12
|
+
*/
|
|
13
|
+
function sanitizeNumber(number) {
|
|
14
|
+
return number ? number.replace(/[^\d.,]/g, '') // Remove non-numeric characters
|
|
15
|
+
.replace(/(.|,)(?=\d(.|,))/g, '') // Remove excess dots
|
|
16
|
+
.replace(/,(\d*)$/, '.$1') // Replace last comma with dot for decimal separation
|
|
17
|
+
: '';
|
|
18
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Formats passport document string to upper case.
|
|
3
|
+
* @param {string} passport - Passport document string.
|
|
4
|
+
* @returns {string} - Formatted passport document string.
|
|
5
|
+
*/
|
|
6
|
+
export declare function formatPassportDocument(passport: string): string;
|
|
7
|
+
/**
|
|
8
|
+
* Formats passport document string by removing non-alphanumeric characters and limits length to 20.
|
|
9
|
+
* @param {string} passport - Passport document string.
|
|
10
|
+
* @returns {string} - Formatted passport string.
|
|
11
|
+
*/
|
|
12
|
+
export declare function formatPassport(passport: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* Sanitizes passport document string by removing non-alphanumeric characters and limits length to 20.
|
|
15
|
+
* @param {string} passport - Passport document string.
|
|
16
|
+
* @returns {string} - Sanitized passport document string.
|
|
17
|
+
*/
|
|
18
|
+
export declare function sanitizePassport(passport: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* Validates passport document string by checking if it starts with 2 letters followed by any number of digits.
|
|
21
|
+
* @param {string} passport - Passport document string.
|
|
22
|
+
* @returns {boolean} - Returns true if passport document is valid, otherwise returns false.
|
|
23
|
+
*/
|
|
24
|
+
export declare function validatePassport(passport: string): boolean;
|
|
25
|
+
//# sourceMappingURL=passport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"passport.d.ts","sourceRoot":"","sources":["../../../src/utils/formatters/passport.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAG/D;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAKvD;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAKzD;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAE1D"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.formatPassport = formatPassport;
|
|
7
|
+
exports.formatPassportDocument = formatPassportDocument;
|
|
8
|
+
exports.sanitizePassport = sanitizePassport;
|
|
9
|
+
exports.validatePassport = validatePassport;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Formats passport document string to upper case.
|
|
13
|
+
* @param {string} passport - Passport document string.
|
|
14
|
+
* @returns {string} - Formatted passport document string.
|
|
15
|
+
*/
|
|
16
|
+
function formatPassportDocument(passport) {
|
|
17
|
+
if (!passport) return '';
|
|
18
|
+
return passport.toUpperCase();
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Formats passport document string by removing non-alphanumeric characters and limits length to 20.
|
|
22
|
+
* @param {string} passport - Passport document string.
|
|
23
|
+
* @returns {string} - Formatted passport string.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
function formatPassport(passport) {
|
|
28
|
+
return passport.replace(/[^\dA-Za-z]/g, '').substring(0, 20).toUpperCase();
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Sanitizes passport document string by removing non-alphanumeric characters and limits length to 20.
|
|
32
|
+
* @param {string} passport - Passport document string.
|
|
33
|
+
* @returns {string} - Sanitized passport document string.
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
function sanitizePassport(passport) {
|
|
38
|
+
return passport.replace(/[^\dA-Za-z]/g, '').substring(0, 20).toUpperCase();
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Validates passport document string by checking if it starts with 2 letters followed by any number of digits.
|
|
42
|
+
* @param {string} passport - Passport document string.
|
|
43
|
+
* @returns {boolean} - Returns true if passport document is valid, otherwise returns false.
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
function validatePassport(passport) {
|
|
48
|
+
return /^[a-zA-Z]{2}\d*$/.test(passport);
|
|
49
|
+
}
|