@arkyn/server 3.0.1-beta.117 → 3.0.1-beta.119
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/bundle.js +721 -734
- package/dist/bundle.umd.cjs +5 -10
- package/dist/{api/arkynLogRequest.d.ts → http/api/_logRequest.d.ts} +22 -19
- package/dist/{api/arkynLogRequest.d.ts.map → http/api/_logRequest.d.ts.map} +1 -1
- package/dist/{api/arkynLogRequest.js → http/api/_logRequest.js} +30 -30
- package/dist/http/api/_makeRequest.d.ts +61 -0
- package/dist/http/api/_makeRequest.d.ts.map +1 -0
- package/dist/{api/makeRequest.js → http/api/_makeRequest.js} +29 -20
- package/dist/http/api/deleteRequest.d.ts +17 -0
- package/dist/http/api/deleteRequest.d.ts.map +1 -0
- package/dist/http/api/deleteRequest.js +18 -0
- package/dist/http/api/getRequest.d.ts +16 -0
- package/dist/http/api/getRequest.d.ts.map +1 -0
- package/dist/http/api/getRequest.js +17 -0
- package/dist/http/api/patchRequest.d.ts +17 -0
- package/dist/http/api/patchRequest.d.ts.map +1 -0
- package/dist/http/api/patchRequest.js +18 -0
- package/dist/http/api/postRequest.d.ts +17 -0
- package/dist/http/api/postRequest.d.ts.map +1 -0
- package/dist/http/api/postRequest.js +18 -0
- package/dist/http/api/putRequest.d.ts +17 -0
- package/dist/http/api/putRequest.d.ts.map +1 -0
- package/dist/http/api/putRequest.js +18 -0
- package/dist/http/badResponses/_badResponse.d.ts +18 -7
- package/dist/http/badResponses/_badResponse.d.ts.map +1 -1
- package/dist/http/badResponses/_badResponse.js +44 -13
- package/dist/http/badResponses/badGateway.d.ts +4 -8
- package/dist/http/badResponses/badGateway.d.ts.map +1 -1
- package/dist/http/badResponses/badGateway.js +9 -17
- package/dist/http/badResponses/badRequest.d.ts +4 -8
- package/dist/http/badResponses/badRequest.d.ts.map +1 -1
- package/dist/http/badResponses/badRequest.js +9 -17
- package/dist/http/badResponses/conflict.d.ts +4 -8
- package/dist/http/badResponses/conflict.d.ts.map +1 -1
- package/dist/http/badResponses/conflict.js +9 -17
- package/dist/http/badResponses/forbidden.d.ts +4 -8
- package/dist/http/badResponses/forbidden.d.ts.map +1 -1
- package/dist/http/badResponses/forbidden.js +9 -17
- package/dist/http/badResponses/notFound.d.ts +4 -8
- package/dist/http/badResponses/notFound.d.ts.map +1 -1
- package/dist/http/badResponses/notFound.js +9 -17
- package/dist/http/badResponses/notImplemented.d.ts +4 -8
- package/dist/http/badResponses/notImplemented.d.ts.map +1 -1
- package/dist/http/badResponses/notImplemented.js +9 -17
- package/dist/http/badResponses/serverError.d.ts +4 -8
- package/dist/http/badResponses/serverError.d.ts.map +1 -1
- package/dist/http/badResponses/serverError.js +9 -17
- package/dist/http/badResponses/unauthorized.d.ts +2 -6
- package/dist/http/badResponses/unauthorized.d.ts.map +1 -1
- package/dist/http/badResponses/unauthorized.js +7 -15
- package/dist/http/badResponses/unprocessableEntity.d.ts +13 -18
- package/dist/http/badResponses/unprocessableEntity.d.ts.map +1 -1
- package/dist/http/badResponses/unprocessableEntity.js +14 -22
- package/dist/http/successResponses/_successResponse.d.ts +18 -7
- package/dist/http/successResponses/_successResponse.d.ts.map +1 -1
- package/dist/http/successResponses/_successResponse.js +50 -21
- package/dist/http/successResponses/created.d.ts +8 -22
- package/dist/http/successResponses/created.d.ts.map +1 -1
- package/dist/http/successResponses/created.js +13 -25
- package/dist/http/successResponses/found.d.ts +9 -26
- package/dist/http/successResponses/found.d.ts.map +1 -1
- package/dist/http/successResponses/found.js +14 -29
- package/dist/http/successResponses/noContent.d.ts +4 -12
- package/dist/http/successResponses/noContent.d.ts.map +1 -1
- package/dist/http/successResponses/noContent.js +9 -17
- package/dist/http/successResponses/success.d.ts +8 -22
- package/dist/http/successResponses/success.d.ts.map +1 -1
- package/dist/http/successResponses/success.js +13 -25
- package/dist/http/successResponses/updated.d.ts +8 -22
- package/dist/http/successResponses/updated.d.ts.map +1 -1
- package/dist/http/successResponses/updated.js +13 -25
- package/dist/index.d.ts +9 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -12
- package/dist/services/apiService.d.ts +7 -28
- package/dist/services/apiService.d.ts.map +1 -1
- package/dist/services/apiService.js +36 -42
- package/dist/services/debugService.d.ts +16 -1
- package/dist/services/debugService.d.ts.map +1 -1
- package/dist/services/debugService.js +58 -1
- package/dist/services/logMapperService.d.ts +86 -0
- package/dist/services/logMapperService.d.ts.map +1 -0
- package/dist/services/logMapperService.js +68 -0
- package/dist/services/logService.d.ts +38 -0
- package/dist/services/logService.d.ts.map +1 -0
- package/dist/services/logService.js +40 -0
- package/dist/{services → utilities}/decodeRequestBody.d.ts +3 -4
- package/dist/utilities/decodeRequestBody.d.ts.map +1 -0
- package/dist/{services → utilities}/decodeRequestBody.js +5 -5
- package/dist/{services/decodeErrorMessageFromRequest.d.ts → utilities/decodeRequestErrorMessage.d.ts} +6 -6
- package/dist/utilities/decodeRequestErrorMessage.d.ts.map +1 -0
- package/dist/{services/decodeErrorMessageFromRequest.js → utilities/decodeRequestErrorMessage.js} +5 -5
- package/dist/utilities/errorHandler.d.ts +50 -0
- package/dist/utilities/errorHandler.d.ts.map +1 -0
- package/dist/{services → utilities}/errorHandler.js +34 -28
- package/dist/utilities/flushDebugLogs.d.ts +46 -0
- package/dist/utilities/flushDebugLogs.d.ts.map +1 -0
- package/dist/utilities/flushDebugLogs.js +59 -0
- package/dist/{services → utilities}/formAsyncParse.d.ts +3 -3
- package/dist/utilities/formAsyncParse.d.ts.map +1 -0
- package/dist/{services → utilities}/formAsyncParse.js +3 -3
- package/dist/{services → utilities}/formParse.d.ts +3 -3
- package/dist/utilities/formParse.d.ts.map +1 -0
- package/dist/{services → utilities}/formParse.js +3 -3
- package/dist/{services → utilities}/getScopedParams.d.ts +3 -4
- package/dist/utilities/getScopedParams.d.ts.map +1 -0
- package/dist/{services → utilities}/getScopedParams.js +4 -4
- package/dist/{services → utilities}/schemaValidator.d.ts +3 -15
- package/dist/utilities/schemaValidator.d.ts.map +1 -0
- package/dist/{services → utilities}/schemaValidator.js +3 -19
- package/dist/validations/validateCep.d.ts +7 -12
- package/dist/validations/validateCep.d.ts.map +1 -1
- package/dist/validations/validateCep.js +9 -15
- package/dist/validations/validateCnpj.d.ts +4 -5
- package/dist/validations/validateCnpj.d.ts.map +1 -1
- package/dist/validations/validateCnpj.js +12 -5
- package/dist/validations/validateCpf.d.ts +3 -4
- package/dist/validations/validateCpf.d.ts.map +1 -1
- package/dist/validations/validateCpf.js +11 -4
- package/dist/validations/validateDate.d.ts +16 -23
- package/dist/validations/validateDate.d.ts.map +1 -1
- package/dist/validations/validateDate.js +38 -56
- package/dist/validations/validateEmail.d.ts +3 -4
- package/dist/validations/validateEmail.d.ts.map +1 -1
- package/dist/validations/validateEmail.js +23 -35
- package/dist/validations/validatePassword.d.ts +3 -4
- package/dist/validations/validatePassword.d.ts.map +1 -1
- package/dist/validations/validatePassword.js +5 -5
- package/dist/validations/validatePhone.d.ts +3 -4
- package/dist/validations/validatePhone.d.ts.map +1 -1
- package/dist/validations/validatePhone.js +4 -4
- package/dist/validations/validateRg.d.ts +3 -4
- package/dist/validations/validateRg.d.ts.map +1 -1
- package/dist/validations/validateRg.js +4 -4
- package/package.json +1 -1
- package/dist/api/deleteRequest.d.ts +0 -13
- package/dist/api/deleteRequest.d.ts.map +0 -1
- package/dist/api/deleteRequest.js +0 -14
- package/dist/api/getRequest.d.ts +0 -12
- package/dist/api/getRequest.d.ts.map +0 -1
- package/dist/api/getRequest.js +0 -13
- package/dist/api/makeRequest.d.ts +0 -38
- package/dist/api/makeRequest.d.ts.map +0 -1
- package/dist/api/patchRequest.d.ts +0 -13
- package/dist/api/patchRequest.d.ts.map +0 -1
- package/dist/api/patchRequest.js +0 -14
- package/dist/api/postRequest.d.ts +0 -13
- package/dist/api/postRequest.d.ts.map +0 -1
- package/dist/api/postRequest.js +0 -14
- package/dist/api/putRequest.d.ts +0 -13
- package/dist/api/putRequest.d.ts.map +0 -1
- package/dist/api/putRequest.js +0 -14
- package/dist/mapper/arkynLogRequestMapper.d.ts +0 -30
- package/dist/mapper/arkynLogRequestMapper.d.ts.map +0 -1
- package/dist/mapper/arkynLogRequestMapper.js +0 -44
- package/dist/services/arkynLogService.d.ts +0 -44
- package/dist/services/arkynLogService.d.ts.map +0 -1
- package/dist/services/arkynLogService.js +0 -46
- package/dist/services/decodeErrorMessageFromRequest.d.ts.map +0 -1
- package/dist/services/decodeRequestBody.d.ts.map +0 -1
- package/dist/services/errorHandler.d.ts +0 -44
- package/dist/services/errorHandler.d.ts.map +0 -1
- package/dist/services/flushDebugLogs.d.ts +0 -8
- package/dist/services/flushDebugLogs.d.ts.map +0 -1
- package/dist/services/flushDebugLogs.js +0 -20
- package/dist/services/formAsyncParse.d.ts.map +0 -1
- package/dist/services/formParse.d.ts.map +0 -1
- package/dist/services/getCaller.d.ts +0 -17
- package/dist/services/getCaller.d.ts.map +0 -1
- package/dist/services/getCaller.js +0 -60
- package/dist/services/getScopedParams.d.ts.map +0 -1
- package/dist/services/measureRouteExecution.d.ts +0 -3
- package/dist/services/measureRouteExecution.d.ts.map +0 -1
- package/dist/services/measureRouteExecution.js +0 -24
- package/dist/services/schemaValidator.d.ts.map +0 -1
- package/dist/types/ApiResponseDTO.d.ts +0 -17
- package/dist/types/ApiResponseDTO.d.ts.map +0 -1
- package/dist/types/ApiResponseDTO.js +0 -1
|
@@ -1,33 +1,27 @@
|
|
|
1
1
|
import { removeNonNumeric } from "@arkyn/shared";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
* @param cep - Raw CEP string.
|
|
5
|
-
* @returns Only numeric characters.
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Validates a Brazilian CEP (Código de Endereçamento Postal).
|
|
3
|
+
* Validates a Brazilian CEP (postal code).
|
|
9
4
|
*
|
|
10
|
-
* A valid CEP
|
|
5
|
+
* A valid CEP must contain exactly 8 numeric digits,
|
|
6
|
+
* optionally formatted as "12345-678".
|
|
11
7
|
*
|
|
12
|
-
* @param rawCep - CEP
|
|
13
|
-
* @returns `true` if the CEP is valid, otherwise `false`.
|
|
8
|
+
* @param {string} rawCep - CEP value, with or without formatting.
|
|
9
|
+
* @returns {boolean} `true` if the CEP is valid, otherwise `false`.
|
|
14
10
|
*
|
|
15
11
|
* @example
|
|
16
|
-
* ```
|
|
12
|
+
* ```typescript
|
|
17
13
|
* validateCep("12345-678"); // true
|
|
18
14
|
* validateCep("12345678"); // true
|
|
19
15
|
* validateCep("ABCDE-123"); // false
|
|
20
16
|
* ```
|
|
21
17
|
*/
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return false;
|
|
25
|
-
const validFormat = /^[0-9-]+$/.test(rawCep);
|
|
18
|
+
function validateCep(rawCep) {
|
|
19
|
+
const validFormat = /^\d{5}-\d{3}$/.test(rawCep) || /^\d{8}$/.test(rawCep);
|
|
26
20
|
if (!validFormat)
|
|
27
21
|
return false;
|
|
28
22
|
const cep = removeNonNumeric(rawCep);
|
|
29
23
|
const CEP_LENGTH = 8;
|
|
30
24
|
const isOnlyDigits = /^\d{8}$/.test(cep);
|
|
31
25
|
return cep.length === CEP_LENGTH && isOnlyDigits;
|
|
32
|
-
}
|
|
26
|
+
}
|
|
33
27
|
export { validateCep };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
type ValidateCnpjFunction = (rawCnpj: string) => boolean;
|
|
2
1
|
/**
|
|
3
2
|
* Validates a Brazilian CNPJ (Cadastro Nacional da Pessoa Jurídica) number.
|
|
4
3
|
*
|
|
@@ -8,15 +7,15 @@ type ValidateCnpjFunction = (rawCnpj: string) => boolean;
|
|
|
8
7
|
* - Repeating digits check (invalid if all digits are the same).
|
|
9
8
|
* - Verifies the two check digits with the proper weights.
|
|
10
9
|
*
|
|
11
|
-
* @param rawCnpj - CNPJ string, possibly formatted.
|
|
12
|
-
* @returns `true` if valid, otherwise `false`.
|
|
10
|
+
* @param {string} rawCnpj - CNPJ string, possibly formatted.
|
|
11
|
+
* @returns {boolean} `true` if valid, otherwise `false`.
|
|
13
12
|
*
|
|
14
13
|
* @example
|
|
15
|
-
* ```
|
|
14
|
+
* ```typescript
|
|
16
15
|
* validateCnpj("12.345.678/0001-95"); // false
|
|
17
16
|
* validateCnpj("11.444.777/0001-61"); // true
|
|
18
17
|
* ```
|
|
19
18
|
*/
|
|
20
|
-
declare
|
|
19
|
+
declare function validateCnpj(rawCnpj: string): boolean;
|
|
21
20
|
export { validateCnpj };
|
|
22
21
|
//# sourceMappingURL=validateCnpj.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validateCnpj.d.ts","sourceRoot":"","sources":["../../src/validations/validateCnpj.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validateCnpj.d.ts","sourceRoot":"","sources":["../../src/validations/validateCnpj.ts"],"names":[],"mappings":"AAyBA;;;;;;;;;;;;;;;;;GAiBG;AAEH,iBAAS,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAqB9C;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
|
|
@@ -27,18 +27,25 @@ function extractDigit(cnpj) {
|
|
|
27
27
|
* - Repeating digits check (invalid if all digits are the same).
|
|
28
28
|
* - Verifies the two check digits with the proper weights.
|
|
29
29
|
*
|
|
30
|
-
* @param rawCnpj - CNPJ string, possibly formatted.
|
|
31
|
-
* @returns `true` if valid, otherwise `false`.
|
|
30
|
+
* @param {string} rawCnpj - CNPJ string, possibly formatted.
|
|
31
|
+
* @returns {boolean} `true` if valid, otherwise `false`.
|
|
32
32
|
*
|
|
33
33
|
* @example
|
|
34
|
-
* ```
|
|
34
|
+
* ```typescript
|
|
35
35
|
* validateCnpj("12.345.678/0001-95"); // false
|
|
36
36
|
* validateCnpj("11.444.777/0001-61"); // true
|
|
37
37
|
* ```
|
|
38
38
|
*/
|
|
39
|
-
|
|
39
|
+
function validateCnpj(rawCnpj) {
|
|
40
40
|
if (!rawCnpj)
|
|
41
41
|
return false;
|
|
42
|
+
if (rawCnpj.length > 18)
|
|
43
|
+
return false;
|
|
44
|
+
if (rawCnpj.length < 14)
|
|
45
|
+
return false;
|
|
46
|
+
const hasSpaces = /\s/.test(rawCnpj);
|
|
47
|
+
if (hasSpaces)
|
|
48
|
+
return false;
|
|
42
49
|
const cnpj = removeNonNumeric(rawCnpj);
|
|
43
50
|
if (isInvalidLength(cnpj))
|
|
44
51
|
return false;
|
|
@@ -48,5 +55,5 @@ const validateCnpj = (rawCnpj) => {
|
|
|
48
55
|
const digit1 = calculateDigit(base, [5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2]);
|
|
49
56
|
const digit2 = calculateDigit(base + digit1, [6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2]);
|
|
50
57
|
return extractDigit(cnpj) === `${digit1}${digit2}`;
|
|
51
|
-
}
|
|
58
|
+
}
|
|
52
59
|
export { validateCnpj };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
type ValidateCpfFunction = (rawCpf: string) => boolean;
|
|
2
1
|
/**
|
|
3
2
|
* Validates a Brazilian CPF (Cadastro de Pessoas Físicas) number.
|
|
4
3
|
*
|
|
@@ -10,8 +9,8 @@ type ValidateCpfFunction = (rawCpf: string) => boolean;
|
|
|
10
9
|
* - Calculates the first and second verification digits using the CPF algorithm.
|
|
11
10
|
* - Compares the calculated verification digits with the ones provided in the CPF.
|
|
12
11
|
*
|
|
13
|
-
* @param rawCpf - The raw CPF string, which may include formatting characters (e.g., dots or dashes).
|
|
14
|
-
* @returns `true` if the CPF is valid, otherwise `false`.
|
|
12
|
+
* @param {string} rawCpf - The raw CPF string, which may include formatting characters (e.g., dots or dashes).
|
|
13
|
+
* @returns {boolean} `true` if the CPF is valid, otherwise `false`.
|
|
15
14
|
*
|
|
16
15
|
* @example
|
|
17
16
|
* ```typescript
|
|
@@ -19,6 +18,6 @@ type ValidateCpfFunction = (rawCpf: string) => boolean;
|
|
|
19
18
|
* validateCpf("111.444.777-35"); // true
|
|
20
19
|
* ```
|
|
21
20
|
*/
|
|
22
|
-
declare
|
|
21
|
+
declare function validateCpf(rawCpf: string): boolean;
|
|
23
22
|
export { validateCpf };
|
|
24
23
|
//# sourceMappingURL=validateCpf.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validateCpf.d.ts","sourceRoot":"","sources":["../../src/validations/validateCpf.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validateCpf.d.ts","sourceRoot":"","sources":["../../src/validations/validateCpf.ts"],"names":[],"mappings":"AAyBA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,iBAAS,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAiB5C;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -30,8 +30,8 @@ function extractDigit(cpf) {
|
|
|
30
30
|
* - Calculates the first and second verification digits using the CPF algorithm.
|
|
31
31
|
* - Compares the calculated verification digits with the ones provided in the CPF.
|
|
32
32
|
*
|
|
33
|
-
* @param rawCpf - The raw CPF string, which may include formatting characters (e.g., dots or dashes).
|
|
34
|
-
* @returns `true` if the CPF is valid, otherwise `false`.
|
|
33
|
+
* @param {string} rawCpf - The raw CPF string, which may include formatting characters (e.g., dots or dashes).
|
|
34
|
+
* @returns {boolean} `true` if the CPF is valid, otherwise `false`.
|
|
35
35
|
*
|
|
36
36
|
* @example
|
|
37
37
|
* ```typescript
|
|
@@ -39,9 +39,16 @@ function extractDigit(cpf) {
|
|
|
39
39
|
* validateCpf("111.444.777-35"); // true
|
|
40
40
|
* ```
|
|
41
41
|
*/
|
|
42
|
-
|
|
42
|
+
function validateCpf(rawCpf) {
|
|
43
43
|
if (!rawCpf)
|
|
44
44
|
return false;
|
|
45
|
+
if (rawCpf.length > 14)
|
|
46
|
+
return false;
|
|
47
|
+
if (rawCpf.length < 11)
|
|
48
|
+
return false;
|
|
49
|
+
const hasSpaces = /\s/.test(rawCpf);
|
|
50
|
+
if (hasSpaces)
|
|
51
|
+
return false;
|
|
45
52
|
const cpf = removeNonNumeric(rawCpf);
|
|
46
53
|
if (isInvalidLength(cpf))
|
|
47
54
|
return false;
|
|
@@ -50,5 +57,5 @@ const validateCpf = (rawCpf) => {
|
|
|
50
57
|
const digit1 = calculateDigit(cpf, 10);
|
|
51
58
|
const digit2 = calculateDigit(cpf, 11);
|
|
52
59
|
return extractDigit(cpf) === `${digit1}${digit2}`;
|
|
53
|
-
}
|
|
60
|
+
}
|
|
54
61
|
export { validateCpf };
|
|
@@ -1,34 +1,27 @@
|
|
|
1
|
-
type ValidateDateConfig = {
|
|
2
|
-
inputFormat?: "DD/MM/YYYY" | "MM-DD-YYYY" | "YYYY-MM-DD";
|
|
3
|
-
minYear?: number;
|
|
4
|
-
maxYear?: number;
|
|
5
|
-
};
|
|
6
|
-
type ValidateDateFunction = (rawDate: string, config?: ValidateDateConfig) => boolean;
|
|
7
1
|
/**
|
|
8
2
|
* Validates a date string based on the provided format and configuration.
|
|
9
3
|
*
|
|
10
|
-
* @param
|
|
11
|
-
* @param config - Optional configuration object to customize validation.
|
|
12
|
-
* @param config.
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* @
|
|
16
|
-
* @param config.maxYear - The maximum allowed year for the date. Defaults to 3000.
|
|
17
|
-
*
|
|
18
|
-
* @returns `true` if the date is valid according to the specified format and configuration, otherwise `false`.
|
|
19
|
-
*
|
|
20
|
-
* @throws {Error} If an invalid date format is provided in the configuration.
|
|
4
|
+
* @param {string} date - The date string to validate.
|
|
5
|
+
* @param {object} config - Optional configuration object to customize validation.
|
|
6
|
+
* @param {number} config.minYear - The minimum allowed year for the date. Defaults to 1900.
|
|
7
|
+
* @param {number} config.maxYear - The maximum allowed year for the date. Defaults to 3000.
|
|
8
|
+
* @throws {Error} If an invalid input format is provided.
|
|
9
|
+
* @returns {boolean} `true` if the date is valid according to the specified format and configuration, otherwise `false`.
|
|
21
10
|
*
|
|
22
11
|
* @example
|
|
23
12
|
* ```typescript
|
|
24
13
|
* validateDate("31/12/2023"); // true
|
|
25
|
-
* validateDate("12-31-2023", { inputFormat: "
|
|
26
|
-
* validateDate("2023-12-31", { inputFormat: "
|
|
27
|
-
* validateDate("29/02/2024", { inputFormat: "
|
|
28
|
-
* validateDate("29/02/2023", { inputFormat: "
|
|
29
|
-
* validateDate("31/04/2023", { inputFormat: "
|
|
14
|
+
* validateDate("12-31-2023", { inputFormat: "isoDate" }); // true
|
|
15
|
+
* validateDate("2023-12-31", { inputFormat: "timestamp", minYear: 2000, maxYear: 2100 }); // true
|
|
16
|
+
* validateDate("29/02/2024", { inputFormat: "brazilianDate" }); // true (leap year)
|
|
17
|
+
* validateDate("29/02/2023", { inputFormat: "brazilianDate" }); // false (not a leap year)
|
|
18
|
+
* validateDate("31/04/2023", { inputFormat: "brazilianDate" }); // false (April has 30 days)
|
|
30
19
|
* ```
|
|
31
20
|
*/
|
|
32
|
-
declare
|
|
21
|
+
declare function validateDate(date: string, config?: {
|
|
22
|
+
inputFormat?: "brazilianDate" | "isoDate" | "timestamp";
|
|
23
|
+
minYear?: number;
|
|
24
|
+
maxYear?: number;
|
|
25
|
+
}): boolean;
|
|
33
26
|
export { validateDate };
|
|
34
27
|
//# sourceMappingURL=validateDate.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validateDate.d.ts","sourceRoot":"","sources":["../../src/validations/validateDate.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validateDate.d.ts","sourceRoot":"","sources":["../../src/validations/validateDate.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,iBAAS,YAAY,CACnB,IAAI,EAAE,MAAM,EACZ,MAAM,CAAC,EAAE;IACP,WAAW,CAAC,EAAE,eAAe,GAAG,SAAS,GAAG,WAAW,CAAC;IACxD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,GACA,OAAO,CAiCT;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
|
|
@@ -1,73 +1,55 @@
|
|
|
1
|
+
import { ValidateDateService } from "@arkyn/shared";
|
|
1
2
|
/**
|
|
2
3
|
* Validates a date string based on the provided format and configuration.
|
|
3
4
|
*
|
|
4
|
-
* @param
|
|
5
|
-
* @param config - Optional configuration object to customize validation.
|
|
6
|
-
* @param config.
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* @
|
|
10
|
-
* @param config.maxYear - The maximum allowed year for the date. Defaults to 3000.
|
|
11
|
-
*
|
|
12
|
-
* @returns `true` if the date is valid according to the specified format and configuration, otherwise `false`.
|
|
13
|
-
*
|
|
14
|
-
* @throws {Error} If an invalid date format is provided in the configuration.
|
|
5
|
+
* @param {string} date - The date string to validate.
|
|
6
|
+
* @param {object} config - Optional configuration object to customize validation.
|
|
7
|
+
* @param {number} config.minYear - The minimum allowed year for the date. Defaults to 1900.
|
|
8
|
+
* @param {number} config.maxYear - The maximum allowed year for the date. Defaults to 3000.
|
|
9
|
+
* @throws {Error} If an invalid input format is provided.
|
|
10
|
+
* @returns {boolean} `true` if the date is valid according to the specified format and configuration, otherwise `false`.
|
|
15
11
|
*
|
|
16
12
|
* @example
|
|
17
13
|
* ```typescript
|
|
18
14
|
* validateDate("31/12/2023"); // true
|
|
19
|
-
* validateDate("12-31-2023", { inputFormat: "
|
|
20
|
-
* validateDate("2023-12-31", { inputFormat: "
|
|
21
|
-
* validateDate("29/02/2024", { inputFormat: "
|
|
22
|
-
* validateDate("29/02/2023", { inputFormat: "
|
|
23
|
-
* validateDate("31/04/2023", { inputFormat: "
|
|
15
|
+
* validateDate("12-31-2023", { inputFormat: "isoDate" }); // true
|
|
16
|
+
* validateDate("2023-12-31", { inputFormat: "timestamp", minYear: 2000, maxYear: 2100 }); // true
|
|
17
|
+
* validateDate("29/02/2024", { inputFormat: "brazilianDate" }); // true (leap year)
|
|
18
|
+
* validateDate("29/02/2023", { inputFormat: "brazilianDate" }); // false (not a leap year)
|
|
19
|
+
* validateDate("31/04/2023", { inputFormat: "brazilianDate" }); // false (April has 30 days)
|
|
24
20
|
* ```
|
|
25
21
|
*/
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const inputFormat = config?.inputFormat || "DD/MM/YYYY";
|
|
22
|
+
function validateDate(date, config) {
|
|
23
|
+
const inputFormat = config?.inputFormat || "brazilianDate";
|
|
29
24
|
const minYear = config?.minYear || 1900;
|
|
30
25
|
const maxYear = config?.maxYear || 3000;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
else if (inputFormat === "MM-DD-YYYY") {
|
|
38
|
-
const dateRegex = /^(\d{2})-(\d{2})-(\d{4})$/;
|
|
39
|
-
if (!dateRegex.test(rawDate))
|
|
40
|
-
return false;
|
|
41
|
-
[, month, day, year] = rawDate.match(dateRegex) || [];
|
|
42
|
-
}
|
|
43
|
-
else if (inputFormat === "YYYY-MM-DD") {
|
|
44
|
-
const dateRegex = /^(\d{4})-(\d{2})-(\d{2})$/;
|
|
45
|
-
if (!dateRegex.test(rawDate))
|
|
46
|
-
return false;
|
|
47
|
-
[, year, month, day] = rawDate.match(dateRegex) || [];
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
throw new Error("Invalid date format");
|
|
51
|
-
}
|
|
52
|
-
const dayNum = parseInt(day, 10);
|
|
53
|
-
const monthNum = parseInt(month, 10);
|
|
54
|
-
const yearNum = parseInt(year, 10);
|
|
55
|
-
if (dayNum < 1 || dayNum > 31)
|
|
56
|
-
return false;
|
|
57
|
-
if (monthNum < 1 || monthNum > 12)
|
|
26
|
+
const validateDateService = new ValidateDateService();
|
|
27
|
+
validateDateService.validateInputFormat(inputFormat);
|
|
28
|
+
let day, month, year;
|
|
29
|
+
const dateParts = date.split(/[-/]/).map(Number);
|
|
30
|
+
if (dateParts.length !== 3)
|
|
58
31
|
return false;
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
32
|
+
try {
|
|
33
|
+
switch (inputFormat) {
|
|
34
|
+
case "brazilianDate":
|
|
35
|
+
[day, month, year] = dateParts;
|
|
36
|
+
validateDateService.validateDateParts(year, month, day);
|
|
37
|
+
break;
|
|
38
|
+
case "isoDate":
|
|
39
|
+
[month, day, year] = dateParts;
|
|
40
|
+
validateDateService.validateDateParts(year, month, day);
|
|
41
|
+
break;
|
|
42
|
+
case "timestamp":
|
|
43
|
+
[year, month, day] = dateParts;
|
|
44
|
+
validateDateService.validateDateParts(year, month, day);
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
if (year < minYear || year > maxYear)
|
|
63
48
|
return false;
|
|
49
|
+
return true;
|
|
64
50
|
}
|
|
65
|
-
|
|
51
|
+
catch {
|
|
66
52
|
return false;
|
|
67
53
|
}
|
|
68
|
-
|
|
69
|
-
return false;
|
|
70
|
-
const isValidDate = new Date(yearNum, monthNum - 1, dayNum).getDate() === dayNum;
|
|
71
|
-
return isValidDate;
|
|
72
|
-
};
|
|
54
|
+
}
|
|
73
55
|
export { validateDate };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
type ValidateEmailFunction = (rawEmail: string) => Promise<boolean>;
|
|
2
1
|
/**
|
|
3
2
|
* Validates if an email address is valid in all possible ways, including DNS validation.
|
|
4
3
|
*
|
|
@@ -7,8 +6,8 @@ type ValidateEmailFunction = (rawEmail: string) => Promise<boolean>;
|
|
|
7
6
|
* - Validating advanced RFC 5322 compliance rules
|
|
8
7
|
* - Verifying that the domain has valid MX or A records in DNS
|
|
9
8
|
*
|
|
10
|
-
* @param rawEmail - The email address string to validate
|
|
11
|
-
* @returns A promise that resolves to `true` if the email is valid (including DNS), otherwise `false`
|
|
9
|
+
* @param {string} rawEmail - The email address string to validate
|
|
10
|
+
* @returns {Promise<boolean>} A promise that resolves to `true` if the email is valid (including DNS), otherwise `false`
|
|
12
11
|
*
|
|
13
12
|
* @example
|
|
14
13
|
* ```typescript
|
|
@@ -17,6 +16,6 @@ type ValidateEmailFunction = (rawEmail: string) => Promise<boolean>;
|
|
|
17
16
|
* await validateEmail("invalid-email"); // false (invalid format)
|
|
18
17
|
* ```
|
|
19
18
|
*/
|
|
20
|
-
declare
|
|
19
|
+
declare function validateEmail(rawEmail: string): Promise<boolean>;
|
|
21
20
|
export { validateEmail };
|
|
22
21
|
//# sourceMappingURL=validateEmail.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validateEmail.d.ts","sourceRoot":"","sources":["../../src/validations/validateEmail.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validateEmail.d.ts","sourceRoot":"","sources":["../../src/validations/validateEmail.ts"],"names":[],"mappings":"AAwFA;;;;;;;;;;;;;;;;;GAiBG;AAEH,iBAAe,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAW/D;AAED,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import dns from "node:dns";
|
|
2
|
-
// const resolveDns = dns.promises.resolve;
|
|
3
|
-
// Validates basic email format using a comprehensive regex pattern
|
|
4
2
|
function isValidBasicFormat(email) {
|
|
5
|
-
const emailRegex = /^[a-zA-Z0-9
|
|
3
|
+
const emailRegex = /^[a-zA-Z0-9.!$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
|
|
6
4
|
return emailRegex.test(email);
|
|
7
5
|
}
|
|
8
|
-
// Validates the local part of email (before @)
|
|
9
6
|
function isValidLocalPart(localPart) {
|
|
10
7
|
if (localPart.length === 0 || localPart.length > 64)
|
|
11
8
|
return false;
|
|
@@ -18,7 +15,6 @@ function isValidLocalPart(localPart) {
|
|
|
18
15
|
return false;
|
|
19
16
|
return true;
|
|
20
17
|
}
|
|
21
|
-
// Validates a single domain label
|
|
22
18
|
function isValidDomainLabel(label) {
|
|
23
19
|
if (label.length === 0 || label.length > 63)
|
|
24
20
|
return false;
|
|
@@ -28,7 +24,6 @@ function isValidDomainLabel(label) {
|
|
|
28
24
|
return false;
|
|
29
25
|
return true;
|
|
30
26
|
}
|
|
31
|
-
// Validates the domain part of email (after @)
|
|
32
27
|
function isValidDomainPart(domainPart) {
|
|
33
28
|
if (domainPart.length === 0 || domainPart.length > 253)
|
|
34
29
|
return false;
|
|
@@ -49,7 +44,6 @@ function isValidDomainPart(domainPart) {
|
|
|
49
44
|
return false;
|
|
50
45
|
return true;
|
|
51
46
|
}
|
|
52
|
-
// Performs advanced syntax validation beyond basic regex
|
|
53
47
|
function isValidAdvancedSyntax(email) {
|
|
54
48
|
const parts = email.split("@");
|
|
55
49
|
if (parts.length !== 2)
|
|
@@ -61,33 +55,28 @@ function isValidAdvancedSyntax(email) {
|
|
|
61
55
|
return false;
|
|
62
56
|
return true;
|
|
63
57
|
}
|
|
64
|
-
// Extracts the domain from email address
|
|
65
58
|
function extractDomain(email) {
|
|
66
59
|
const parts = email.split("@");
|
|
67
60
|
return parts.length === 2 ? parts[1].toLowerCase() : null;
|
|
68
61
|
}
|
|
69
|
-
// DNS record types to check for domain validation
|
|
70
62
|
const DNS_RECORD_TYPES = ["MX", "A", "AAAA"];
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
// }
|
|
89
|
-
// return false;
|
|
90
|
-
// }
|
|
63
|
+
async function tryResolveDnsRecord(domain, recordType) {
|
|
64
|
+
try {
|
|
65
|
+
await dns?.promises?.resolve(domain, recordType);
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
async function isValidDns(domain) {
|
|
73
|
+
for (const recordType of DNS_RECORD_TYPES) {
|
|
74
|
+
const hasRecord = await tryResolveDnsRecord(domain, recordType);
|
|
75
|
+
if (hasRecord)
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
91
80
|
/**
|
|
92
81
|
* Validates if an email address is valid in all possible ways, including DNS validation.
|
|
93
82
|
*
|
|
@@ -96,8 +85,8 @@ const DNS_RECORD_TYPES = ["MX", "A", "AAAA"];
|
|
|
96
85
|
* - Validating advanced RFC 5322 compliance rules
|
|
97
86
|
* - Verifying that the domain has valid MX or A records in DNS
|
|
98
87
|
*
|
|
99
|
-
* @param rawEmail - The email address string to validate
|
|
100
|
-
* @returns A promise that resolves to `true` if the email is valid (including DNS), otherwise `false`
|
|
88
|
+
* @param {string} rawEmail - The email address string to validate
|
|
89
|
+
* @returns {Promise<boolean>} A promise that resolves to `true` if the email is valid (including DNS), otherwise `false`
|
|
101
90
|
*
|
|
102
91
|
* @example
|
|
103
92
|
* ```typescript
|
|
@@ -106,7 +95,7 @@ const DNS_RECORD_TYPES = ["MX", "A", "AAAA"];
|
|
|
106
95
|
* await validateEmail("invalid-email"); // false (invalid format)
|
|
107
96
|
* ```
|
|
108
97
|
*/
|
|
109
|
-
|
|
98
|
+
async function validateEmail(rawEmail) {
|
|
110
99
|
if (!rawEmail || typeof rawEmail !== "string")
|
|
111
100
|
return false;
|
|
112
101
|
const email = rawEmail.trim();
|
|
@@ -117,7 +106,6 @@ const validateEmail = async (rawEmail) => {
|
|
|
117
106
|
const domain = extractDomain(email);
|
|
118
107
|
if (!domain)
|
|
119
108
|
return false;
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
};
|
|
109
|
+
return await isValidDns(domain);
|
|
110
|
+
}
|
|
123
111
|
export { validateEmail };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
type ValidatePasswordFunction = (rawPassword: string) => boolean;
|
|
2
1
|
/**
|
|
3
2
|
* Validates a password based on the following rules:
|
|
4
3
|
* - At least 8 characters
|
|
@@ -7,8 +6,8 @@ type ValidatePasswordFunction = (rawPassword: string) => boolean;
|
|
|
7
6
|
* - At least 1 number
|
|
8
7
|
* - At least 1 special character
|
|
9
8
|
*
|
|
10
|
-
* @param rawPassword - The raw password string.
|
|
11
|
-
* @returns `true` if password is valid, otherwise `false`.
|
|
9
|
+
* @param {string} rawPassword - The raw password string.
|
|
10
|
+
* @returns {boolean} `true` if password is valid, otherwise `false`.
|
|
12
11
|
*
|
|
13
12
|
* @example
|
|
14
13
|
* ```ts
|
|
@@ -16,6 +15,6 @@ type ValidatePasswordFunction = (rawPassword: string) => boolean;
|
|
|
16
15
|
* validatePassword("senha123"); // false (no uppercase, no special char)
|
|
17
16
|
* ```
|
|
18
17
|
*/
|
|
19
|
-
declare
|
|
18
|
+
declare function validatePassword(rawPassword: string): boolean;
|
|
20
19
|
export { validatePassword };
|
|
21
20
|
//# sourceMappingURL=validatePassword.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validatePassword.d.ts","sourceRoot":"","sources":["../../src/validations/validatePassword.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"validatePassword.d.ts","sourceRoot":"","sources":["../../src/validations/validatePassword.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,iBAAS,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAkBtD;AAED,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
* - At least 1 number
|
|
7
7
|
* - At least 1 special character
|
|
8
8
|
*
|
|
9
|
-
* @param rawPassword - The raw password string.
|
|
10
|
-
* @returns `true` if password is valid, otherwise `false`.
|
|
9
|
+
* @param {string} rawPassword - The raw password string.
|
|
10
|
+
* @returns {boolean} `true` if password is valid, otherwise `false`.
|
|
11
11
|
*
|
|
12
12
|
* @example
|
|
13
13
|
* ```ts
|
|
@@ -15,14 +15,14 @@
|
|
|
15
15
|
* validatePassword("senha123"); // false (no uppercase, no special char)
|
|
16
16
|
* ```
|
|
17
17
|
*/
|
|
18
|
-
|
|
18
|
+
function validatePassword(rawPassword) {
|
|
19
19
|
if (!rawPassword)
|
|
20
20
|
return false;
|
|
21
21
|
const hasMinLength = rawPassword.length >= 8;
|
|
22
22
|
const hasUppercase = /[A-Z]/.test(rawPassword);
|
|
23
23
|
const hasLetter = /[a-z]/.test(rawPassword);
|
|
24
24
|
const hasNumber = /\d/.test(rawPassword);
|
|
25
|
-
const hasSpecialChar = /[!@#$%^&*(),.?"
|
|
25
|
+
const hasSpecialChar = /[!@#$%^&*(),.?":;{}|<>_\-+=~`[\]\\\/]/.test(rawPassword);
|
|
26
26
|
return [
|
|
27
27
|
hasMinLength,
|
|
28
28
|
hasUppercase,
|
|
@@ -30,5 +30,5 @@ const validatePassword = (rawPassword) => {
|
|
|
30
30
|
hasNumber,
|
|
31
31
|
hasSpecialChar,
|
|
32
32
|
].every((condition) => condition);
|
|
33
|
-
}
|
|
33
|
+
}
|
|
34
34
|
export { validatePassword };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
type ValidatePhoneFunction = (rawPhone: string) => boolean;
|
|
2
1
|
/**
|
|
3
2
|
* Validates a phone number against a list of country-specific formats.
|
|
4
3
|
*
|
|
@@ -10,8 +9,8 @@ type ValidatePhoneFunction = (rawPhone: string) => boolean;
|
|
|
10
9
|
* Special handling is applied for Brazilian phone numbers (ISO code "BR"), which
|
|
11
10
|
* allows for an optional ninth digit.
|
|
12
11
|
*
|
|
13
|
-
* @param rawPhone - The phone number to validate as a string.
|
|
14
|
-
* @returns `true` if the phone number matches any country's format, otherwise `false`.
|
|
12
|
+
* @param {string} rawPhone - The phone number to validate as a string.
|
|
13
|
+
* @returns {boolean} `true` if the phone number matches any country's format, otherwise `false`.
|
|
15
14
|
*
|
|
16
15
|
* @example
|
|
17
16
|
* ```typescript
|
|
@@ -24,6 +23,6 @@ type ValidatePhoneFunction = (rawPhone: string) => boolean;
|
|
|
24
23
|
* validatePhone("+55 1234567890"); // false for an invalid Brazilian phone number
|
|
25
24
|
* ```
|
|
26
25
|
*/
|
|
27
|
-
declare
|
|
26
|
+
declare function validatePhone(rawPhone: string): boolean;
|
|
28
27
|
export { validatePhone };
|
|
29
28
|
//# sourceMappingURL=validatePhone.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validatePhone.d.ts","sourceRoot":"","sources":["../../src/validations/validatePhone.ts"],"names":[],"mappings":"AAEA,
|
|
1
|
+
{"version":3,"file":"validatePhone.d.ts","sourceRoot":"","sources":["../../src/validations/validatePhone.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,iBAAS,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAiBhD;AAED,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -10,8 +10,8 @@ import { countries } from "@arkyn/templates";
|
|
|
10
10
|
* Special handling is applied for Brazilian phone numbers (ISO code "BR"), which
|
|
11
11
|
* allows for an optional ninth digit.
|
|
12
12
|
*
|
|
13
|
-
* @param rawPhone - The phone number to validate as a string.
|
|
14
|
-
* @returns `true` if the phone number matches any country's format, otherwise `false`.
|
|
13
|
+
* @param {string} rawPhone - The phone number to validate as a string.
|
|
14
|
+
* @returns {boolean} `true` if the phone number matches any country's format, otherwise `false`.
|
|
15
15
|
*
|
|
16
16
|
* @example
|
|
17
17
|
* ```typescript
|
|
@@ -24,7 +24,7 @@ import { countries } from "@arkyn/templates";
|
|
|
24
24
|
* validatePhone("+55 1234567890"); // false for an invalid Brazilian phone number
|
|
25
25
|
* ```
|
|
26
26
|
*/
|
|
27
|
-
|
|
27
|
+
function validatePhone(rawPhone) {
|
|
28
28
|
for (const country of countries) {
|
|
29
29
|
const countryCode = country.code;
|
|
30
30
|
const prefix = country.prefix ? `-${country.prefix}` : "";
|
|
@@ -40,5 +40,5 @@ const validatePhone = (rawPhone) => {
|
|
|
40
40
|
return true;
|
|
41
41
|
}
|
|
42
42
|
return false;
|
|
43
|
-
}
|
|
43
|
+
}
|
|
44
44
|
export { validatePhone };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
type ValidateRgFunction = (rawRg: string) => boolean;
|
|
2
1
|
/**
|
|
3
2
|
* Validates a Brazilian RG (Registro Geral) in a generic way.
|
|
4
3
|
*
|
|
@@ -7,8 +6,8 @@ type ValidateRgFunction = (rawRg: string) => boolean;
|
|
|
7
6
|
* - Ensures length is reasonable (7–9 digits).
|
|
8
7
|
* - Optionally allows for a final letter (verifier).
|
|
9
8
|
*
|
|
10
|
-
* @param rawRg - RG string, possibly formatted.
|
|
11
|
-
* @returns `true` if format seems valid, otherwise `false`.
|
|
9
|
+
* @param {string} rawRg - RG string, possibly formatted.
|
|
10
|
+
* @returns {boolean} `true` if format seems valid, otherwise `false`.
|
|
12
11
|
*
|
|
13
12
|
* @example
|
|
14
13
|
* ```ts
|
|
@@ -17,6 +16,6 @@ type ValidateRgFunction = (rawRg: string) => boolean;
|
|
|
17
16
|
* validateRg("12345678X"); // true
|
|
18
17
|
* ```
|
|
19
18
|
*/
|
|
20
|
-
declare
|
|
19
|
+
declare function validateRg(rawRg: string): boolean;
|
|
21
20
|
export { validateRg };
|
|
22
21
|
//# sourceMappingURL=validateRg.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validateRg.d.ts","sourceRoot":"","sources":["../../src/validations/validateRg.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"validateRg.d.ts","sourceRoot":"","sources":["../../src/validations/validateRg.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,iBAAS,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAa1C;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
|