@arkyn/server 3.0.1-beta.99 → 3.0.2
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/LICENSE.txt +184 -1
- package/README.md +277 -224
- package/dist/http/api/_deleteRequest.d.ts +17 -0
- package/dist/http/api/_deleteRequest.d.ts.map +1 -0
- package/dist/http/api/_getRequest.d.ts +16 -0
- package/dist/http/api/_getRequest.d.ts.map +1 -0
- package/dist/http/api/_logMapperService.d.ts +86 -0
- package/dist/http/api/_logMapperService.d.ts.map +1 -0
- 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/http/api/_makeRequest.d.ts +61 -0
- package/dist/http/api/_makeRequest.d.ts.map +1 -0
- package/dist/http/api/_patchRequest.d.ts +17 -0
- package/dist/http/api/_patchRequest.d.ts.map +1 -0
- package/dist/http/api/_postRequest.d.ts +17 -0
- package/dist/http/api/_postRequest.d.ts.map +1 -0
- package/dist/http/api/_putRequest.d.ts +17 -0
- package/dist/http/api/_putRequest.d.ts.map +1 -0
- package/dist/http/badResponses/_badResponse.d.ts +21 -7
- package/dist/http/badResponses/_badResponse.d.ts.map +1 -1
- package/dist/http/badResponses/badGateway.d.ts +12 -23
- package/dist/http/badResponses/badGateway.d.ts.map +1 -1
- package/dist/http/badResponses/badRequest.d.ts +10 -23
- package/dist/http/badResponses/badRequest.d.ts.map +1 -1
- package/dist/http/badResponses/conflict.d.ts +10 -23
- package/dist/http/badResponses/conflict.d.ts.map +1 -1
- package/dist/http/badResponses/forbidden.d.ts +10 -23
- package/dist/http/badResponses/forbidden.d.ts.map +1 -1
- package/dist/http/badResponses/notFound.d.ts +10 -23
- package/dist/http/badResponses/notFound.d.ts.map +1 -1
- package/dist/http/badResponses/notImplemented.d.ts +10 -23
- package/dist/http/badResponses/notImplemented.d.ts.map +1 -1
- package/dist/http/badResponses/serverError.d.ts +10 -23
- package/dist/http/badResponses/serverError.d.ts.map +1 -1
- package/dist/http/badResponses/unauthorized.d.ts +10 -23
- package/dist/http/badResponses/unauthorized.d.ts.map +1 -1
- package/dist/http/badResponses/unprocessableEntity.d.ts +23 -33
- package/dist/http/badResponses/unprocessableEntity.d.ts.map +1 -1
- package/dist/http/successResponses/_successResponse.d.ts +21 -7
- package/dist/http/successResponses/_successResponse.d.ts.map +1 -1
- package/dist/http/successResponses/created.d.ts +11 -29
- package/dist/http/successResponses/created.d.ts.map +1 -1
- package/dist/http/successResponses/found.d.ts +11 -32
- package/dist/http/successResponses/found.d.ts.map +1 -1
- package/dist/http/successResponses/noContent.d.ts +10 -16
- package/dist/http/successResponses/noContent.d.ts.map +1 -1
- package/dist/http/successResponses/success.d.ts +11 -29
- package/dist/http/successResponses/success.d.ts.map +1 -1
- package/dist/http/successResponses/updated.d.ts +12 -29
- package/dist/http/successResponses/updated.d.ts.map +1 -1
- package/dist/index.d.ts +9 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1069 -38
- package/dist/index.js.map +1 -0
- package/dist/modules/http/api/_deleteRequest.js +15 -0
- package/dist/modules/http/api/_deleteRequest.js.map +1 -0
- package/dist/modules/http/api/_getRequest.js +14 -0
- package/dist/modules/http/api/_getRequest.js.map +1 -0
- package/dist/modules/http/api/_logMapperService.js +33 -0
- package/dist/modules/http/api/_logMapperService.js.map +1 -0
- package/dist/modules/http/api/_logRequest.js +58 -0
- package/dist/modules/http/api/_logRequest.js.map +1 -0
- package/dist/modules/http/api/_makeRequest.js +72 -0
- package/dist/modules/http/api/_makeRequest.js.map +1 -0
- package/dist/modules/http/api/_patchRequest.js +15 -0
- package/dist/modules/http/api/_patchRequest.js.map +1 -0
- package/dist/modules/http/api/_postRequest.js +15 -0
- package/dist/modules/http/api/_postRequest.js.map +1 -0
- package/dist/modules/http/api/_putRequest.js +15 -0
- package/dist/modules/http/api/_putRequest.js.map +1 -0
- package/dist/modules/http/badResponses/_badResponse.js +65 -0
- package/dist/modules/http/badResponses/_badResponse.js.map +1 -0
- package/dist/modules/http/badResponses/badGateway.js +26 -0
- package/dist/modules/http/badResponses/badGateway.js.map +1 -0
- package/dist/modules/http/badResponses/badRequest.js +26 -0
- package/dist/modules/http/badResponses/badRequest.js.map +1 -0
- package/dist/modules/http/badResponses/conflict.js +26 -0
- package/dist/modules/http/badResponses/conflict.js.map +1 -0
- package/dist/modules/http/badResponses/forbidden.js +26 -0
- package/dist/modules/http/badResponses/forbidden.js.map +1 -0
- package/dist/modules/http/badResponses/notFound.js +26 -0
- package/dist/modules/http/badResponses/notFound.js.map +1 -0
- package/dist/modules/http/badResponses/notImplemented.js +26 -0
- package/dist/modules/http/badResponses/notImplemented.js.map +1 -0
- package/dist/modules/http/badResponses/serverError.js +26 -0
- package/dist/modules/http/badResponses/serverError.js.map +1 -0
- package/dist/modules/http/badResponses/unauthorized.js +26 -0
- package/dist/modules/http/badResponses/unauthorized.js.map +1 -0
- package/dist/modules/http/badResponses/unprocessableEntity.js +30 -0
- package/dist/modules/http/badResponses/unprocessableEntity.js.map +1 -0
- package/dist/modules/http/successResponses/_successResponse.js +64 -0
- package/dist/modules/http/successResponses/_successResponse.js.map +1 -0
- package/dist/modules/http/successResponses/created.js +26 -0
- package/dist/modules/http/successResponses/created.js.map +1 -0
- package/dist/modules/http/successResponses/found.js +26 -0
- package/dist/modules/http/successResponses/found.js.map +1 -0
- package/dist/modules/http/successResponses/noContent.js +19 -0
- package/dist/modules/http/successResponses/noContent.js.map +1 -0
- package/dist/modules/http/successResponses/success.js +26 -0
- package/dist/modules/http/successResponses/success.js.map +1 -0
- package/dist/modules/http/successResponses/updated.js +26 -0
- package/dist/modules/http/successResponses/updated.js.map +1 -0
- package/dist/modules/services/apiService.js +111 -0
- package/dist/modules/services/apiService.js.map +1 -0
- package/dist/modules/services/debugService.js +38 -0
- package/dist/modules/services/debugService.js.map +1 -0
- package/dist/modules/services/logService.js +23 -0
- package/dist/modules/services/logService.js.map +1 -0
- package/dist/modules/utilities/decodeRequestBody.js +22 -0
- package/dist/modules/utilities/decodeRequestBody.js.map +1 -0
- package/dist/modules/utilities/decodeRequestErrorMessage.js +8 -0
- package/dist/modules/utilities/decodeRequestErrorMessage.js.map +1 -0
- package/dist/modules/utilities/errorHandler.js +41 -0
- package/dist/modules/utilities/errorHandler.js.map +1 -0
- package/dist/modules/utilities/flushDebugLogs.js +18 -0
- package/dist/modules/utilities/flushDebugLogs.js.map +1 -0
- package/dist/modules/utilities/formAsyncParse.js +16 -0
- package/dist/modules/utilities/formAsyncParse.js.map +1 -0
- package/dist/modules/utilities/formParse.js +16 -0
- package/dist/modules/utilities/formParse.js.map +1 -0
- package/dist/modules/utilities/getScopedParams.js +11 -0
- package/dist/modules/utilities/getScopedParams.js.map +1 -0
- package/dist/modules/utilities/schemaValidator.js +57 -0
- package/dist/modules/utilities/schemaValidator.js.map +1 -0
- package/dist/modules/validations/validateCep.js +11 -0
- package/dist/modules/validations/validateCep.js.map +1 -0
- package/dist/modules/validations/validateCnpj.js +56 -0
- package/dist/modules/validations/validateCnpj.js.map +1 -0
- package/dist/modules/validations/validateCpf.js +29 -0
- package/dist/modules/validations/validateCpf.js.map +1 -0
- package/dist/modules/validations/validateDate.js +28 -0
- package/dist/modules/validations/validateDate.js.map +1 -0
- package/dist/modules/validations/validateEmail.js +56 -0
- package/dist/modules/validations/validateEmail.js.map +1 -0
- package/dist/modules/validations/validatePassword.js +14 -0
- package/dist/modules/validations/validatePassword.js.map +1 -0
- package/dist/modules/validations/validatePhone.js +12 -0
- package/dist/modules/validations/validatePhone.js.map +1 -0
- package/dist/modules/validations/validateRg.js +10 -0
- package/dist/modules/validations/validateRg.js.map +1 -0
- package/dist/services/apiService.d.ts +25 -26
- package/dist/services/apiService.d.ts.map +1 -1
- package/dist/services/debugService.d.ts +15 -32
- package/dist/services/debugService.d.ts.map +1 -1
- package/dist/services/logService.d.ts +33 -0
- package/dist/services/logService.d.ts.map +1 -0
- package/dist/utilities/decodeRequestBody.d.ts +18 -0
- package/dist/utilities/decodeRequestBody.d.ts.map +1 -0
- package/dist/utilities/decodeRequestErrorMessage.d.ts +19 -0
- package/dist/utilities/decodeRequestErrorMessage.d.ts.map +1 -0
- package/dist/utilities/errorHandler.d.ts +25 -0
- package/dist/utilities/errorHandler.d.ts.map +1 -0
- package/dist/utilities/flushDebugLogs.d.ts +24 -0
- package/dist/utilities/flushDebugLogs.d.ts.map +1 -0
- package/dist/utilities/formAsyncParse.d.ts +38 -0
- package/dist/utilities/formAsyncParse.d.ts.map +1 -0
- package/dist/utilities/formParse.d.ts +38 -0
- package/dist/utilities/formParse.d.ts.map +1 -0
- package/dist/utilities/getScopedParams.d.ts +19 -0
- package/dist/utilities/getScopedParams.d.ts.map +1 -0
- package/dist/utilities/schemaValidator.d.ts +75 -0
- package/dist/utilities/schemaValidator.d.ts.map +1 -0
- package/dist/validations/validateCep.d.ts +6 -11
- package/dist/validations/validateCep.d.ts.map +1 -1
- package/dist/validations/validateCnpj.d.ts +2 -3
- package/dist/validations/validateCnpj.d.ts.map +1 -1
- package/dist/validations/validateCpf.d.ts +4 -12
- package/dist/validations/validateCpf.d.ts.map +1 -1
- package/dist/validations/validateDate.d.ts +13 -24
- package/dist/validations/validateDate.d.ts.map +1 -1
- package/dist/validations/validateEmail.d.ts +3 -4
- package/dist/validations/validateEmail.d.ts.map +1 -1
- package/dist/validations/validatePassword.d.ts +3 -4
- package/dist/validations/validatePassword.d.ts.map +1 -1
- package/dist/validations/validatePhone.d.ts +7 -20
- package/dist/validations/validatePhone.d.ts.map +1 -1
- package/dist/validations/validateRg.d.ts +1 -2
- package/dist/validations/validateRg.d.ts.map +1 -1
- package/package.json +317 -15
- package/dist/api/arkynLogRequest.js +0 -88
- 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/makeRequest.js +0 -107
- 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/bundle.js +0 -1507
- package/dist/bundle.umd.cjs +0 -10
- package/dist/http/badResponses/_badResponse.js +0 -20
- package/dist/http/badResponses/badGateway.js +0 -58
- package/dist/http/badResponses/badRequest.js +0 -58
- package/dist/http/badResponses/conflict.js +0 -58
- package/dist/http/badResponses/forbidden.js +0 -58
- package/dist/http/badResponses/notFound.js +0 -58
- package/dist/http/badResponses/notImplemented.js +0 -58
- package/dist/http/badResponses/serverError.js +0 -58
- package/dist/http/badResponses/unauthorized.js +0 -58
- package/dist/http/badResponses/unprocessableEntity.js +0 -65
- package/dist/http/successResponses/_successResponse.js +0 -37
- package/dist/http/successResponses/created.js +0 -57
- package/dist/http/successResponses/found.js +0 -60
- package/dist/http/successResponses/noContent.js +0 -38
- package/dist/http/successResponses/success.js +0 -57
- package/dist/http/successResponses/updated.js +0 -57
- 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/apiService.js +0 -133
- 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/debugService.js +0 -57
- package/dist/services/decodeErrorMessageFromRequest.d.ts +0 -17
- package/dist/services/decodeErrorMessageFromRequest.d.ts.map +0 -1
- package/dist/services/decodeErrorMessageFromRequest.js +0 -30
- package/dist/services/decodeRequestBody.d.ts +0 -17
- package/dist/services/decodeRequestBody.d.ts.map +0 -1
- package/dist/services/decodeRequestBody.js +0 -38
- package/dist/services/errorHandler.d.ts +0 -44
- package/dist/services/errorHandler.d.ts.map +0 -1
- package/dist/services/errorHandler.js +0 -93
- 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 +0 -59
- package/dist/services/formAsyncParse.d.ts.map +0 -1
- package/dist/services/formAsyncParse.js +0 -58
- package/dist/services/formParse.d.ts +0 -59
- package/dist/services/formParse.d.ts.map +0 -1
- package/dist/services/formParse.js +0 -58
- 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 +0 -28
- package/dist/services/getScopedParams.d.ts.map +0 -1
- package/dist/services/getScopedParams.js +0 -34
- 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 +0 -158
- package/dist/services/schemaValidator.d.ts.map +0 -1
- package/dist/services/schemaValidator.js +0 -207
- package/dist/types/ApiResponseDTO.d.ts +0 -17
- package/dist/types/ApiResponseDTO.d.ts.map +0 -1
- package/dist/types/ApiResponseDTO.js +0 -1
- package/dist/validations/validateCep.js +0 -33
- package/dist/validations/validateCnpj.js +0 -52
- package/dist/validations/validateCpf.js +0 -54
- package/dist/validations/validateDate.js +0 -73
- package/dist/validations/validateEmail.js +0 -123
- package/dist/validations/validatePassword.js +0 -34
- package/dist/validations/validatePhone.js +0 -44
- package/dist/validations/validateRg.js +0 -31
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { ZodType, z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Wraps a Zod schema with convenience validation methods suited for server-side use:
|
|
4
|
+
* - `isValid` — boolean check, no throws
|
|
5
|
+
* - `safeValidate` — raw Zod result, no throws
|
|
6
|
+
* - `validate` — throws `ServerError` on failure (for trusted/internal data)
|
|
7
|
+
* - `formValidate` / `formAsyncValidate` — throws `UnprocessableEntity` on failure (for user-submitted forms)
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* const validator = new SchemaValidator(z.object({ email: z.string().email() }));
|
|
12
|
+
*
|
|
13
|
+
* // Inside a Remix action:
|
|
14
|
+
* const body = validator.formValidate(await decodeRequestBody(request));
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
declare class SchemaValidator<T extends ZodType> {
|
|
18
|
+
readonly schema: T;
|
|
19
|
+
/**
|
|
20
|
+
* @param schema - The Zod schema used for all validation methods on this instance.
|
|
21
|
+
*/
|
|
22
|
+
constructor(schema: T);
|
|
23
|
+
/**
|
|
24
|
+
* Returns `true` if the data satisfies the schema, `false` otherwise. Never throws.
|
|
25
|
+
*
|
|
26
|
+
* @param data - The value to check.
|
|
27
|
+
*/
|
|
28
|
+
isValid(data: any): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Validates data and returns the raw Zod `safeParseResult` without throwing.
|
|
31
|
+
* Useful when you need access to the full error details.
|
|
32
|
+
*
|
|
33
|
+
* @param data - The value to validate.
|
|
34
|
+
*/
|
|
35
|
+
safeValidate(data: any): z.ZodSafeParseResult<z.infer<T>>;
|
|
36
|
+
/**
|
|
37
|
+
* Validates data and returns the typed result, throwing `ServerError` on failure.
|
|
38
|
+
* Use for validating internal/trusted data (e.g. env vars, config objects).
|
|
39
|
+
*
|
|
40
|
+
* @param data - The value to validate.
|
|
41
|
+
* @throws `ServerError` with a formatted field-by-field error message.
|
|
42
|
+
*/
|
|
43
|
+
validate(data: any): z.infer<T>;
|
|
44
|
+
/**
|
|
45
|
+
* Validates form data and returns the typed result, throwing `UnprocessableEntity` on failure.
|
|
46
|
+
* The error includes `fieldErrors`, `fields`, and `data.scrollTo` (first failing field name).
|
|
47
|
+
*
|
|
48
|
+
* @param data - The raw form data to validate.
|
|
49
|
+
* @param message - Optional human-readable error message for the 422 response.
|
|
50
|
+
* @throws `UnprocessableEntity` with structured field errors for client-side form handling.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```typescript
|
|
54
|
+
* const validator = new SchemaValidator(registerSchema);
|
|
55
|
+
* const body = validator.formValidate(await decodeRequestBody(request));
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
formValidate(data: any, message?: string): z.infer<T>;
|
|
59
|
+
/**
|
|
60
|
+
* Async version of `formValidate` for schemas with async refinements (e.g. uniqueness checks).
|
|
61
|
+
*
|
|
62
|
+
* @param data - The raw form data to validate.
|
|
63
|
+
* @param message - Optional human-readable error message for the 422 response.
|
|
64
|
+
* @throws `UnprocessableEntity` with structured field errors for client-side form handling.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```typescript
|
|
68
|
+
* const validator = new SchemaValidator(registerSchema);
|
|
69
|
+
* const body = await validator.formAsyncValidate(await decodeRequestBody(request));
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
formAsyncValidate(data: any, message?: string): Promise<z.infer<T>>;
|
|
73
|
+
}
|
|
74
|
+
export { SchemaValidator };
|
|
75
|
+
//# sourceMappingURL=schemaValidator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemaValidator.d.ts","sourceRoot":"","sources":["../../src/utilities/schemaValidator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAgBtC;;;;;;;;;;;;;;GAcG;AACH,cAAM,eAAe,CAAC,CAAC,SAAS,OAAO;IAI1B,QAAQ,CAAC,MAAM,EAAE,CAAC;IAH9B;;OAEG;gBACkB,MAAM,EAAE,CAAC;IAE9B;;;;OAIG;IAEH,OAAO,CAAC,IAAI,EAAE,GAAG,GAAG,OAAO;IAI3B;;;;;OAKG;IAEH,YAAY,CAAC,IAAI,EAAE,GAAG,GAAG,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAIzD;;;;;;OAMG;IAEH,QAAQ,CAAC,IAAI,EAAE,GAAG,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;IAQ/B;;;;;;;;;;;;;OAaG;IAEH,YAAY,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;IAiBrD;;;;;;;;;;;;OAYG;IAEG,iBAAiB,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;CAgBzE;AAED,OAAO,EAAE,eAAe,EAAE,CAAC"}
|
|
@@ -1,24 +1,19 @@
|
|
|
1
|
-
type ValidateCepFunction = (rawCep: string) => boolean;
|
|
2
1
|
/**
|
|
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).
|
|
2
|
+
* Validates a Brazilian CEP (postal code).
|
|
9
3
|
*
|
|
10
|
-
* A valid CEP
|
|
4
|
+
* A valid CEP must contain exactly 8 numeric digits,
|
|
5
|
+
* optionally formatted as "12345-678".
|
|
11
6
|
*
|
|
12
|
-
* @param rawCep - CEP
|
|
7
|
+
* @param rawCep - CEP value, with or without formatting.
|
|
13
8
|
* @returns `true` if the CEP is valid, otherwise `false`.
|
|
14
9
|
*
|
|
15
10
|
* @example
|
|
16
|
-
* ```
|
|
11
|
+
* ```typescript
|
|
17
12
|
* validateCep("12345-678"); // true
|
|
18
13
|
* validateCep("12345678"); // true
|
|
19
14
|
* validateCep("ABCDE-123"); // false
|
|
20
15
|
* ```
|
|
21
16
|
*/
|
|
22
|
-
declare
|
|
17
|
+
declare function validateCep(rawCep: string): boolean;
|
|
23
18
|
export { validateCep };
|
|
24
19
|
//# sourceMappingURL=validateCep.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validateCep.d.ts","sourceRoot":"","sources":["../../src/validations/validateCep.ts"],"names":[],"mappings":"AAEA,
|
|
1
|
+
{"version":3,"file":"validateCep.d.ts","sourceRoot":"","sources":["../../src/validations/validateCep.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;GAeG;AAEH,iBAAS,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAU5C;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -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
|
*
|
|
@@ -12,11 +11,11 @@ type ValidateCnpjFunction = (rawCnpj: string) => boolean;
|
|
|
12
11
|
* @returns `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"}
|
|
@@ -1,16 +1,8 @@
|
|
|
1
|
-
type ValidateCpfFunction = (rawCpf: string) => boolean;
|
|
2
1
|
/**
|
|
3
|
-
* Validates a Brazilian CPF
|
|
2
|
+
* Validates a Brazilian CPF number. Strips formatting, checks length, rejects
|
|
3
|
+
* repeated-digit sequences, and verifies both check digits with the CPF algorithm.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
* This function checks if the provided CPF is valid by performing the following steps:
|
|
7
|
-
* - Removes any non-digit characters from the input.
|
|
8
|
-
* - Verifies if the CPF has the correct length (11 digits).
|
|
9
|
-
* - Ensures that all digits are not the same (e.g., "111.111.111-11" is invalid).
|
|
10
|
-
* - Calculates the first and second verification digits using the CPF algorithm.
|
|
11
|
-
* - Compares the calculated verification digits with the ones provided in the CPF.
|
|
12
|
-
*
|
|
13
|
-
* @param rawCpf - The raw CPF string, which may include formatting characters (e.g., dots or dashes).
|
|
5
|
+
* @param rawCpf - CPF string, with or without formatting (dots and dashes).
|
|
14
6
|
* @returns `true` if the CPF is valid, otherwise `false`.
|
|
15
7
|
*
|
|
16
8
|
* @example
|
|
@@ -19,6 +11,6 @@ type ValidateCpfFunction = (rawCpf: string) => boolean;
|
|
|
19
11
|
* validateCpf("111.444.777-35"); // true
|
|
20
12
|
* ```
|
|
21
13
|
*/
|
|
22
|
-
declare
|
|
14
|
+
declare function validateCpf(rawCpf: string): boolean;
|
|
23
15
|
export { validateCpf };
|
|
24
16
|
//# 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;;;;;;;;;;;;GAYG;AAEH,iBAAS,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAiB5C;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -1,34 +1,23 @@
|
|
|
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
|
-
* Validates a date string
|
|
9
|
-
*
|
|
10
|
-
* @param rawDate - The date string to validate.
|
|
11
|
-
* @param config - Optional configuration object to customize validation.
|
|
12
|
-
* @param config.inputFormat - The expected format of the input date.
|
|
13
|
-
* Supported formats are "DD/MM/YYYY", "MM-DD-YYYY", and "YYYY-MM-DD".
|
|
14
|
-
* Defaults to "DD/MM/YYYY".
|
|
15
|
-
* @param config.minYear - The minimum allowed year for the date. Defaults to 1900.
|
|
16
|
-
* @param config.maxYear - The maximum allowed year for the date. Defaults to 3000.
|
|
2
|
+
* Validates a date string against a format and optional year bounds.
|
|
17
3
|
*
|
|
18
|
-
* @
|
|
19
|
-
*
|
|
20
|
-
* @
|
|
4
|
+
* @param date - The date string to validate.
|
|
5
|
+
* @param config.inputFormat - Parsing format: `"brazilianDate"` (DD/MM/YYYY, default), `"isoDate"` (MM-DD-YYYY), or `"timestamp"` (YYYY-MM-DD).
|
|
6
|
+
* @param config.minYear - Minimum allowed year. Defaults to 1900.
|
|
7
|
+
* @param config.maxYear - Maximum allowed year. Defaults to 3000.
|
|
8
|
+
* @returns `true` if the date is valid according to the format and bounds, otherwise `false`.
|
|
21
9
|
*
|
|
22
10
|
* @example
|
|
23
11
|
* ```typescript
|
|
24
12
|
* validateDate("31/12/2023"); // true
|
|
25
|
-
* validateDate("12-31
|
|
26
|
-
* validateDate("2023
|
|
27
|
-
* validateDate("29/02/2024", { inputFormat: "DD/MM/YYYY" }); // true (leap year)
|
|
28
|
-
* validateDate("29/02/2023", { inputFormat: "DD/MM/YYYY" }); // false (not a leap year)
|
|
29
|
-
* validateDate("31/04/2023", { inputFormat: "DD/MM/YYYY" }); // false (April has 30 days)
|
|
13
|
+
* validateDate("2023-12-31", { inputFormat: "timestamp", minYear: 2000, maxYear: 2100 }); // true
|
|
14
|
+
* validateDate("29/02/2023"); // false (not a leap year)
|
|
30
15
|
* ```
|
|
31
16
|
*/
|
|
32
|
-
declare
|
|
17
|
+
declare function validateDate(date: string, config?: {
|
|
18
|
+
inputFormat?: "brazilianDate" | "isoDate" | "timestamp";
|
|
19
|
+
minYear?: number;
|
|
20
|
+
maxYear?: number;
|
|
21
|
+
}): boolean;
|
|
33
22
|
export { validateDate };
|
|
34
23
|
//# 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;;;;;;;;;;;;;;;GAeG;AAEH,iBAAS,YAAY,CACpB,IAAI,EAAE,MAAM,EACZ,MAAM,CAAC,EAAE;IACR,WAAW,CAAC,EAAE,eAAe,GAAG,SAAS,GAAG,WAAW,CAAC;IACxD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB,GACC,OAAO,CAiCT;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
|
|
@@ -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
|
|
11
|
-
* @returns
|
|
9
|
+
* @param rawEmail - The email address to validate.
|
|
10
|
+
* @returns `true` if the email passes format checks and its domain resolves in 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,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
|
|
11
|
-
* @returns `true` if password
|
|
9
|
+
* @param rawPassword - The password string to validate.
|
|
10
|
+
* @returns `true` if the password meets all rules, 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"}
|
|
@@ -1,29 +1,16 @@
|
|
|
1
|
-
type ValidatePhoneFunction = (rawPhone: string) => boolean;
|
|
2
1
|
/**
|
|
3
|
-
* Validates
|
|
2
|
+
* Validates an international phone number using `libphonenumber-js`, then confirms
|
|
3
|
+
* the parsed country code is present in the supported countries list.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* regular expressions to validate the phone number based on the country's code,
|
|
8
|
-
* prefix, and mask.
|
|
9
|
-
*
|
|
10
|
-
* Special handling is applied for Brazilian phone numbers (ISO code "BR"), which
|
|
11
|
-
* allows for an optional ninth digit.
|
|
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`.
|
|
5
|
+
* @param rawPhone - Phone number in E.164 format (e.g. `"+5532912345678"`).
|
|
6
|
+
* @returns `true` if the number is valid and the country is supported, otherwise `false`.
|
|
15
7
|
*
|
|
16
8
|
* @example
|
|
17
9
|
* ```typescript
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* validatePhone("+55 32912345678"); // true for a valid Brazilian phone number
|
|
21
|
-
* validatePhone("+55 3212345678"); // true for a valid Brazilian phone number
|
|
22
|
-
* validatePhone("+1-684 1234567"); // true for a valid American Samoa phone number
|
|
23
|
-
* validatePhone("+5532912345678"); // false for an invalid Brazilian phone number
|
|
24
|
-
* validatePhone("+55 1234567890"); // false for an invalid Brazilian phone number
|
|
10
|
+
* validatePhone("+5532912345678"); // true (Brazil)
|
|
11
|
+
* validatePhone("+55329123456178"); // false (invalid)
|
|
25
12
|
* ```
|
|
26
13
|
*/
|
|
27
|
-
declare
|
|
14
|
+
declare function validatePhone(rawPhone: string): boolean;
|
|
28
15
|
export { validatePhone };
|
|
29
16
|
//# sourceMappingURL=validatePhone.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validatePhone.d.ts","sourceRoot":"","sources":["../../src/validations/validatePhone.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validatePhone.d.ts","sourceRoot":"","sources":["../../src/validations/validatePhone.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;GAYG;AAEH,iBAAS,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAYhD;AAED,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -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
|
*
|
|
@@ -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"}
|