@arkyn/shared 3.0.1-beta.9 → 3.0.1-beta.90
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/README.md +452 -67
- package/dist/bundle.js +2337 -0
- package/dist/bundle.umd.cjs +6 -0
- package/dist/formats/formatToCapitalizeFirstWordLetter.d.ts +35 -0
- package/dist/formats/formatToCapitalizeFirstWordLetter.d.ts.map +1 -0
- package/dist/formats/formatToCapitalizeFirstWordLetter.js +42 -0
- package/dist/index.d.ts +2 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -8
- package/dist/services/isHtml.d.ts +22 -0
- package/dist/services/isHtml.d.ts.map +1 -0
- package/dist/services/isHtml.js +24 -0
- package/package.json +26 -6
- package/dist/validations/validateCep.d.ts +0 -24
- package/dist/validations/validateCep.d.ts.map +0 -1
- package/dist/validations/validateCep.js +0 -33
- package/dist/validations/validateCnpj.d.ts +0 -22
- package/dist/validations/validateCnpj.d.ts.map +0 -1
- package/dist/validations/validateCnpj.js +0 -52
- package/dist/validations/validateCpf.d.ts +0 -24
- package/dist/validations/validateCpf.d.ts.map +0 -1
- package/dist/validations/validateCpf.js +0 -54
- package/dist/validations/validateDate.d.ts +0 -34
- package/dist/validations/validateDate.d.ts.map +0 -1
- package/dist/validations/validateDate.js +0 -73
- package/dist/validations/validatePassword.d.ts +0 -21
- package/dist/validations/validatePassword.d.ts.map +0 -1
- package/dist/validations/validatePassword.js +0 -34
- package/dist/validations/validatePhone.d.ts +0 -29
- package/dist/validations/validatePhone.d.ts.map +0 -1
- package/dist/validations/validatePhone.js +0 -44
- package/dist/validations/validateRg.d.ts +0 -22
- package/dist/validations/validateRg.d.ts.map +0 -1
- package/dist/validations/validateRg.js +0 -31
- package/src/formats/formatDate.ts +0 -92
- package/src/formats/formatJsonObject.ts +0 -90
- package/src/formats/formatJsonString.ts +0 -50
- package/src/formats/formatToCep.ts +0 -39
- package/src/formats/formatToCnpj.ts +0 -40
- package/src/formats/formatToCpf.ts +0 -40
- package/src/formats/formatToCpfCnpj.ts +0 -38
- package/src/formats/formatToCurrency.ts +0 -63
- package/src/formats/formatToDate.ts +0 -70
- package/src/formats/formatToEllipsis.ts +0 -25
- package/src/formats/formatToHiddenDigits.ts +0 -92
- package/src/formats/formatToPhone.ts +0 -170
- package/src/generators/generateColorByString.ts +0 -33
- package/src/generators/generateId.ts +0 -61
- package/src/generators/generateSlug.ts +0 -31
- package/src/index.ts +0 -36
- package/src/services/calculateCardInstallment.ts +0 -73
- package/src/services/ensureQuotes.ts +0 -25
- package/src/services/maskSensitiveData.ts +0 -68
- package/src/services/removeCurrencySymbols.ts +0 -29
- package/src/services/removeNonNumeric.ts +0 -20
- package/src/services/stripHtmlTags.ts +0 -20
- package/src/services/truncateLargeFields.ts +0 -69
- package/src/validations/validateCep.ts +0 -41
- package/src/validations/validateCnpj.ts +0 -65
- package/src/validations/validateCpf.ts +0 -62
- package/src/validations/validateDate.ts +0 -86
- package/src/validations/validatePassword.ts +0 -41
- package/src/validations/validatePhone.ts +0 -50
- package/src/validations/validateRg.ts +0 -37
- package/tsconfig.json +0 -20
- package/vitest.config.ts +0 -5
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
type ValidateRgFunction = (rawRg: string) => boolean;
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Validates a Brazilian RG (Registro Geral) in a generic way.
|
|
5
|
-
*
|
|
6
|
-
* This function does a basic structure validation:
|
|
7
|
-
* - Removes non-alphanumeric characters.
|
|
8
|
-
* - Ensures length is reasonable (7–9 digits).
|
|
9
|
-
* - Optionally allows for a final letter (verifier).
|
|
10
|
-
*
|
|
11
|
-
* @param rawRg - RG string, possibly formatted.
|
|
12
|
-
* @returns `true` if format seems valid, otherwise `false`.
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* ```ts
|
|
16
|
-
* validateRg("12.345.678-9"); // true
|
|
17
|
-
* validateRg("MG-12.345.678"); // false (not supported)
|
|
18
|
-
* validateRg("12345678X"); // true
|
|
19
|
-
* ```
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
const validateRg: ValidateRgFunction = (rawRg) => {
|
|
23
|
-
if (!rawRg) return false;
|
|
24
|
-
|
|
25
|
-
const validFormat = /^[0-9a-zA-Z.-]+$/.test(rawRg);
|
|
26
|
-
if (!validFormat) return false;
|
|
27
|
-
|
|
28
|
-
const rg = rawRg.replace(/[^a-zA-Z0-9]/g, "");
|
|
29
|
-
|
|
30
|
-
if (rg.length < 7 || rg.length > 9) return false;
|
|
31
|
-
|
|
32
|
-
const isValidFormat = /^[0-9]{7,8}[0-9Xx]?$/.test(rg);
|
|
33
|
-
|
|
34
|
-
return isValidFormat;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export { validateRg };
|
package/tsconfig.json
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"declaration": true,
|
|
4
|
-
"declarationDir": "./dist",
|
|
5
|
-
"declarationMap": true,
|
|
6
|
-
"isolatedModules": true,
|
|
7
|
-
"lib": ["DOM", "DOM.Iterable", "ES2022"],
|
|
8
|
-
"module": "ESNext",
|
|
9
|
-
"moduleResolution": "node",
|
|
10
|
-
"outDir": "./dist",
|
|
11
|
-
"preserveWatchOutput": true,
|
|
12
|
-
"skipLibCheck": true,
|
|
13
|
-
"strict": true,
|
|
14
|
-
"target": "ESNext",
|
|
15
|
-
"types": ["bun-types"],
|
|
16
|
-
"verbatimModuleSyntax": true
|
|
17
|
-
},
|
|
18
|
-
"exclude": ["dist", "node_modules", "**/__test__"],
|
|
19
|
-
"include": ["src/**/*.ts", "src/**/*.ts"]
|
|
20
|
-
}
|