validation-br 1.5.2 → 2.0.0-next-1

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.
Files changed (197) hide show
  1. package/.prettierrc +9 -0
  2. package/dist/jest.config.d.ts +8 -0
  3. package/dist/jest.config.d.ts.map +1 -0
  4. package/dist/jest.config.js +154 -0
  5. package/dist/jest.config.js.map +1 -0
  6. package/dist/test/_helpers/array_random.spec.d.ts +2 -0
  7. package/dist/test/_helpers/array_random.spec.d.ts.map +1 -0
  8. package/dist/test/_helpers/array_random.spec.js +13 -0
  9. package/dist/test/_helpers/array_random.spec.js.map +1 -0
  10. package/dist/test/_helpers/crc.spec.d.ts +2 -0
  11. package/dist/test/_helpers/crc.spec.d.ts.map +1 -0
  12. package/dist/test/_helpers/crc.spec.js +11 -0
  13. package/dist/test/_helpers/crc.spec.js.map +1 -0
  14. package/dist/test/carplate.spec.d.ts +2 -0
  15. package/dist/test/carplate.spec.d.ts.map +1 -0
  16. package/dist/test/carplate.spec.js +141 -0
  17. package/dist/test/carplate.spec.js.map +1 -0
  18. package/dist/test/cnh.spec.d.ts +2 -0
  19. package/dist/test/cnh.spec.d.ts.map +1 -0
  20. package/dist/test/cnh.spec.js +60 -0
  21. package/dist/test/cnh.spec.js.map +1 -0
  22. package/dist/test/cnpj.spec.d.ts +2 -0
  23. package/dist/test/cnpj.spec.d.ts.map +1 -0
  24. package/dist/test/cnpj.spec.js +105 -0
  25. package/dist/test/cnpj.spec.js.map +1 -0
  26. package/dist/test/cpf.spec.d.ts +2 -0
  27. package/dist/test/cpf.spec.d.ts.map +1 -0
  28. package/dist/test/cpf.spec.js +66 -0
  29. package/dist/test/cpf.spec.js.map +1 -0
  30. package/dist/test/index.test.d.ts +2 -0
  31. package/dist/test/index.test.d.ts.map +1 -0
  32. package/dist/test/index.test.js +77 -0
  33. package/dist/test/index.test.js.map +1 -0
  34. package/dist/test/judicial-process.spec.d.ts +2 -0
  35. package/dist/test/judicial-process.spec.d.ts.map +1 -0
  36. package/dist/test/judicial-process.spec.js +101 -0
  37. package/dist/test/judicial-process.spec.js.map +1 -0
  38. package/dist/test/nup17.spec.d.ts +2 -0
  39. package/dist/test/nup17.spec.d.ts.map +1 -0
  40. package/dist/test/nup17.spec.js +70 -0
  41. package/dist/test/nup17.spec.js.map +1 -0
  42. package/dist/test/phone.spec.d.ts +2 -0
  43. package/dist/test/phone.spec.d.ts.map +1 -0
  44. package/dist/test/phone.spec.js +67 -0
  45. package/dist/test/phone.spec.js.map +1 -0
  46. package/dist/test/pis-pasep.spec.d.ts +2 -0
  47. package/dist/test/pis-pasep.spec.d.ts.map +1 -0
  48. package/dist/test/pis-pasep.spec.js +65 -0
  49. package/dist/test/pis-pasep.spec.js.map +1 -0
  50. package/dist/test/pix-copy-paste.spec.d.ts +2 -0
  51. package/dist/test/pix-copy-paste.spec.d.ts.map +1 -0
  52. package/dist/test/pix-copy-paste.spec.js +31 -0
  53. package/dist/test/pix-copy-paste.spec.js.map +1 -0
  54. package/dist/test/pix-key.spec.d.ts +2 -0
  55. package/dist/test/pix-key.spec.d.ts.map +1 -0
  56. package/dist/test/pix-key.spec.js +36 -0
  57. package/dist/test/pix-key.spec.js.map +1 -0
  58. package/dist/test/postal-track-code.test.d.ts +2 -0
  59. package/dist/test/postal-track-code.test.d.ts.map +1 -0
  60. package/dist/test/postal-track-code.test.js +75 -0
  61. package/dist/test/postal-track-code.test.js.map +1 -0
  62. package/dist/test/renavam.spec.d.ts +2 -0
  63. package/dist/test/renavam.spec.d.ts.map +1 -0
  64. package/dist/test/renavam.spec.js +63 -0
  65. package/dist/test/renavam.spec.js.map +1 -0
  66. package/dist/test/tituloEleitor.spec.d.ts +2 -0
  67. package/dist/test/tituloEleitor.spec.d.ts.map +1 -0
  68. package/dist/test/tituloEleitor.spec.js +68 -0
  69. package/dist/test/tituloEleitor.spec.js.map +1 -0
  70. package/dist/test/utils-applyMask.test.d.ts +2 -0
  71. package/dist/test/utils-applyMask.test.d.ts.map +1 -0
  72. package/dist/test/utils-applyMask.test.js +18 -0
  73. package/dist/test/utils-applyMask.test.js.map +1 -0
  74. package/dist/test/utils-checkRepeatedSequence.test.d.ts +2 -0
  75. package/dist/test/utils-checkRepeatedSequence.test.d.ts.map +1 -0
  76. package/dist/test/utils-checkRepeatedSequence.test.js +18 -0
  77. package/dist/test/utils-checkRepeatedSequence.test.js.map +1 -0
  78. package/dist/test/utils-clearValue.test.d.ts +2 -0
  79. package/dist/test/utils-clearValue.test.d.ts.map +1 -0
  80. package/dist/test/utils-clearValue.test.js +74 -0
  81. package/dist/test/utils-clearValue.test.js.map +1 -0
  82. package/dist/test/utils-fakeNumber.test.d.ts +2 -0
  83. package/dist/test/utils-fakeNumber.test.d.ts.map +1 -0
  84. package/dist/test/utils-fakeNumber.test.js +24 -0
  85. package/dist/test/utils-fakeNumber.test.js.map +1 -0
  86. package/dist/test/utils-insertAtPosition.test.d.ts +2 -0
  87. package/dist/test/utils-insertAtPosition.test.d.ts.map +1 -0
  88. package/dist/test/utils-insertAtPosition.test.js +16 -0
  89. package/dist/test/utils-insertAtPosition.test.js.map +1 -0
  90. package/dist/test/utils-randomLetter.test.d.ts +2 -0
  91. package/dist/test/utils-randomLetter.test.d.ts.map +1 -0
  92. package/dist/test/utils-randomLetter.test.js +14 -0
  93. package/dist/test/utils-randomLetter.test.js.map +1 -0
  94. package/dist/test/utils-removeFromPosition.test.d.ts +2 -0
  95. package/dist/test/utils-removeFromPosition.test.d.ts.map +1 -0
  96. package/dist/test/utils-removeFromPosition.test.js +16 -0
  97. package/dist/test/utils-removeFromPosition.test.js.map +1 -0
  98. package/dist/test/utils-sumElementsByMultipliers.test.d.ts +2 -0
  99. package/dist/test/utils-sumElementsByMultipliers.test.d.ts.map +1 -0
  100. package/dist/test/utils-sumElementsByMultipliers.test.js +23 -0
  101. package/dist/test/utils-sumElementsByMultipliers.test.js.map +1 -0
  102. package/dist/test/utils-sumToDV.test.d.ts +2 -0
  103. package/dist/test/utils-sumToDV.test.d.ts.map +1 -0
  104. package/dist/test/utils-sumToDV.test.js +17 -0
  105. package/dist/test/utils-sumToDV.test.js.map +1 -0
  106. package/dist/tsconfig.tsbuildinfo +1 -0
  107. package/eslint.config.mjs +11 -0
  108. package/jest.config.ts +210 -0
  109. package/package.json +3 -3
  110. package/readme.md +3 -2
  111. package/test/_helpers/array_random.spec.ts +12 -0
  112. package/test/_helpers/crc.spec.ts +13 -0
  113. package/test/carplate.spec.ts +161 -0
  114. package/test/cnh.spec.ts +71 -0
  115. package/test/cnpj.spec.ts +127 -0
  116. package/test/cpf.spec.ts +76 -0
  117. package/test/index.test.ts +112 -0
  118. package/test/judicial-process.spec.ts +131 -0
  119. package/test/nup17.spec.ts +79 -0
  120. package/test/phone.spec.ts +75 -0
  121. package/test/pis-pasep.spec.ts +73 -0
  122. package/test/pix-copy-paste.spec.ts +37 -0
  123. package/test/pix-key.spec.ts +41 -0
  124. package/test/postal-track-code.test.ts +83 -0
  125. package/test/renavam.spec.ts +71 -0
  126. package/test/tituloEleitor.spec.ts +72 -0
  127. package/test/utils-applyMask.test.ts +17 -0
  128. package/test/utils-checkRepeatedSequence.test.ts +17 -0
  129. package/test/utils-clearValue.test.ts +85 -0
  130. package/test/utils-fakeNumber.test.ts +28 -0
  131. package/test/utils-insertAtPosition.test.ts +15 -0
  132. package/test/utils-randomLetter.test.ts +14 -0
  133. package/test/utils-removeFromPosition.test.ts +15 -0
  134. package/test/utils-sumElementsByMultipliers.test.ts +24 -0
  135. package/test/utils-sumToDV.test.ts +16 -0
  136. package/todo.md +18 -0
  137. package/tsconfig.json +103 -23
  138. package/.github/workflows/test.yml +0 -39
  139. package/.prettierrc.js +0 -7
  140. package/dist/cnh.d.ts +0 -91
  141. package/dist/cnh.js +0 -139
  142. package/dist/cnh.js.map +0 -1
  143. package/dist/cnh.test.d.ts +0 -1
  144. package/dist/cnpj.d.ts +0 -114
  145. package/dist/cnpj.js +0 -180
  146. package/dist/cnpj.js.map +0 -1
  147. package/dist/cnpj.test.d.ts +0 -1
  148. package/dist/cpf.d.ts +0 -99
  149. package/dist/cpf.js +0 -147
  150. package/dist/cpf.js.map +0 -1
  151. package/dist/cpf.test.d.ts +0 -1
  152. package/dist/data/ValidationBRError.d.ts +0 -6
  153. package/dist/data/ValidationBRError.js +0 -10
  154. package/dist/data/ValidationBRError.js.map +0 -1
  155. package/dist/index.d.ts +0 -21
  156. package/dist/index.js +0 -42
  157. package/dist/index.js.map +0 -1
  158. package/dist/index.test.d.ts +0 -1
  159. package/dist/judicialProcess.d.ts +0 -126
  160. package/dist/judicialProcess.js +0 -190
  161. package/dist/judicialProcess.js.map +0 -1
  162. package/dist/judicialProcess.test.d.ts +0 -1
  163. package/dist/nup17.d.ts +0 -102
  164. package/dist/nup17.js +0 -155
  165. package/dist/nup17.js.map +0 -1
  166. package/dist/nup17.test.d.ts +0 -1
  167. package/dist/pisPasep.d.ts +0 -81
  168. package/dist/pisPasep.js +0 -126
  169. package/dist/pisPasep.js.map +0 -1
  170. package/dist/pisPasep.test.d.ts +0 -1
  171. package/dist/postalCode.d.ts +0 -83
  172. package/dist/postalCode.js +0 -136
  173. package/dist/postalCode.js.map +0 -1
  174. package/dist/postalCode.test.d.ts +0 -1
  175. package/dist/renavam.d.ts +0 -75
  176. package/dist/renavam.js +0 -122
  177. package/dist/renavam.js.map +0 -1
  178. package/dist/renavam.test.d.ts +0 -1
  179. package/dist/tituloEleitor.d.ts +0 -93
  180. package/dist/tituloEleitor.js +0 -143
  181. package/dist/tituloEleitor.js.map +0 -1
  182. package/dist/tituloEleitor.test.d.ts +0 -1
  183. package/dist/utils-applyMask.test.d.ts +0 -1
  184. package/dist/utils-checkRepeatedSequence.test.d.ts +0 -1
  185. package/dist/utils-clearValue.test.d.ts +0 -1
  186. package/dist/utils-fakeNumber.test.d.ts +0 -1
  187. package/dist/utils-insertAtPosition.test.d.ts +0 -1
  188. package/dist/utils-invalidListGenerator.test.d.ts +0 -1
  189. package/dist/utils-randomLetter.test.d.ts +0 -1
  190. package/dist/utils-removeFromPosition.test.d.ts +0 -1
  191. package/dist/utils-sumElementsByMultipliers.test.d.ts +0 -1
  192. package/dist/utils-sumToDV.test.d.ts +0 -1
  193. package/dist/utils.d.ts +0 -131
  194. package/dist/utils.js +0 -190
  195. package/dist/utils.js.map +0 -1
  196. package/eslint.config.js +0 -82
  197. package/jest.config.js +0 -11
package/tsconfig.json CHANGED
@@ -1,25 +1,105 @@
1
1
  {
2
2
  "compilerOptions": {
3
- "baseUrl": "src",
4
- "module": "commonjs",
5
- "esModuleInterop": true,
6
- "target": "ES2018",
7
- "moduleResolution": "node",
8
- "sourceMap": true,
9
- "outDir": "./dist",
10
- "declaration": true,
11
- "noImplicitAny": true,
12
- "noImplicitReturns": true,
13
- "noImplicitThis": true,
14
- "strict": true,
15
- "allowJs": true,
16
- "types": ["node", "jest"],
17
- "typeRoots": ["node_modules/@types", "index.d.ts"],
18
- "lib": ["ES2018"],
19
- "paths": {
20
- "*": ["node_modules/*"]
21
- }
22
- },
23
- "exclude": ["./tsconfig.json"],
24
- "include": ["./src/**/*"]
25
- }
3
+ /* Visit https://aka.ms/tsconfig to read more about this file */
4
+ /* Projects */
5
+ "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
6
+ // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
7
+ // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
8
+ // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
9
+ // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
10
+ // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
11
+ /* Language and Environment */
12
+ "target": "ES2022", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
13
+ // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
14
+ // "jsx": "preserve", /* Specify what JSX code is generated. */
15
+ // "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
16
+ // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
17
+ // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
18
+ // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
19
+ // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
20
+ // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
21
+ // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
22
+ // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
23
+ // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
24
+ /* Modules */
25
+ "module": "commonjs", /* Specify what module code is generated. */
26
+ // "rootDir": "./src", /* Specify the root folder within your source files. */
27
+ // "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
28
+ // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
29
+ // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
30
+ "rootDirs": [
31
+ "./src",
32
+ "./test",
33
+ ], /* Allow multiple folders to be treated as one when resolving modules. */
34
+ // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
35
+ // "types": [], /* Specify type package names to be included without being referenced in a source file. */
36
+ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
37
+ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
38
+ // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
39
+ // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
40
+ // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
41
+ // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
42
+ // "noUncheckedSideEffectImports": true, /* Check side effect imports. */
43
+ // "resolveJsonModule": true, /* Enable importing .json files. */
44
+ // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
45
+ // "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
46
+ /* JavaScript Support */
47
+ // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
48
+ // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
49
+ // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
50
+ /* Emit */
51
+ "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
52
+ "declarationMap": true, /* Create sourcemaps for d.ts files. */
53
+ // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
54
+ "sourceMap": true, /* Create source map files for emitted JavaScript files. */
55
+ // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
56
+ // "noEmit": true, /* Disable emitting files from a compilation. */
57
+ // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
58
+ "outDir": "./dist", /* Specify an output folder for all emitted files. */
59
+ // "removeComments": true, /* Disable emitting comments. */
60
+ // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
61
+ // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
62
+ // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
63
+ // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
64
+ // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
65
+ // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
66
+ // "newLine": "crlf", /* Set the newline character for emitting files. */
67
+ // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
68
+ // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
69
+ // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
70
+ // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
71
+ // "declarationDir": "./", /* Specify the output directory for generated declaration files. */
72
+ /* Interop Constraints */
73
+ // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
74
+ // "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
75
+ // "isolatedDeclarations": true, /* Require sufficient annotation on exports so other tools can trivially generate declaration files. */
76
+ // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
77
+ "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
78
+ // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
79
+ "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
80
+ /* Type Checking */
81
+ "strict": true, /* Enable all strict type-checking options. */
82
+ "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
83
+ "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
84
+ // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
85
+ // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
86
+ // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
87
+ // "strictBuiltinIteratorReturn": true, /* Built-in iterators are instantiated with a 'TReturn' type of 'undefined' instead of 'any'. */
88
+ // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
89
+ // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
90
+ // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
91
+ // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
92
+ // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
93
+ // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
94
+ "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
95
+ // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
96
+ // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
97
+ // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
98
+ // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
99
+ // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
100
+ // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
101
+ /* Completeness */
102
+ // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
103
+ "skipLibCheck": true /* Skip type checking all .d.ts files. */
104
+ }
105
+ }
@@ -1,39 +0,0 @@
1
- name: Tests
2
-
3
- # on: [push]
4
- on:
5
- push:
6
- branches: [main, dev]
7
- pull_request:
8
- branches: [main, dev]
9
-
10
- jobs:
11
- build:
12
- runs-on: ubuntu-latest
13
-
14
- strategy:
15
- matrix:
16
- node-version: [18.x, 20.x, 22.x]
17
- # See supported Node.js release schedule at https://nodejs.org/en/about/releases/
18
-
19
- steps:
20
- # Checks-out the repository under $GITHUB_WORKSPACE
21
- - uses: actions/checkout@v2
22
-
23
- # Install Node Js
24
- - name: Use Node.js ${{ matrix.node-version }}
25
- uses: actions/setup-node@v2
26
- with:
27
- node-version: ${{ matrix.node-version }}
28
-
29
- # Install Node Modules
30
- - name: Install Node Modules
31
- run: npm install
32
-
33
- # Runs a set of commands using the runners shell
34
- - name: Build typescript code
35
- run: npm run build
36
-
37
- # Runs a set of commands using the runners shell
38
- - name: Runs Unit Tests
39
- run: npm run test
package/.prettierrc.js DELETED
@@ -1,7 +0,0 @@
1
- module.exports = {
2
- semi: true,
3
- trailingComma: 'all',
4
- singleQuote: true,
5
- printWidth: 100,
6
- tabWidth: 2,
7
- }
package/dist/cnh.d.ts DELETED
@@ -1,91 +0,0 @@
1
- /**
2
- * isCNH()
3
- * Calcula se uma CNH é válida
4
- *
5
- * @doc
6
- * CNH deve possuir 11 caracteres
7
- *
8
- * - Os caracteres 1 a 9 são números sequenciais.
9
- *
10
- *
11
- * - Os caracteres 10 e 11 são dígitos verificadores.
12
- *
13
- * 1) Partes do número
14
- * ____________________________ ______
15
- * | Número | D V |
16
- * | 5 8 3 1 6 7 9 4 5 3 4 |
17
- * |____________________________|_____|
18
- *
19
- * 2) Cálculo do primeiro DV.
20
- *
21
- * - Soma-se o produto das algarismos 1 a 9 pelos números 2, 3, 4, 5, 6, 7, 8, 9, 10.
22
- *
23
- * 5 8 3 1 6 7 9 4 5
24
- * x x x x x x x x x
25
- * 2 3 4 5 6 7 8 9 10
26
- * = 10 +24 +12 +5 +36 +49 +72 +36 +50 = 294
27
- *
28
- * - O somatório encontrado é dividido por 11. O DV1 é 11 subtraído do resto da divisão. Se o
29
- * resto for 10, o DV1 é 0.
30
- *
31
- * 2.1) 294 / 11 tem resto igual a 8. 11-7 = 3
32
- * DV1 = 3
33
- *
34
- * 3) Cálculo do segundo DV
35
- *
36
- * - Soma-se o produto das algarismos 1 a 9 juntamente com o 10 caractere
37
- * que é o DV1, pelos números 3, 4, 5, 6, 7, 8, 9, 10, 11, 2. O DV1 será
38
- * multiplicado por 2 e ficará no final.
39
- *
40
- * 5 8 3 1 6 7 9 4 5 3
41
- * x x x x x x x x x x
42
- * 3 4 5 6 7 8 9 10 11 2
43
- * = 10 +24 +12 +5 +36 +49 +72 +36 +50 +6 = 348
44
- *
45
- * 3.1) 348 / 11 tem resto igual a 7. 11 - 7 = 4.
46
- * DV2 = 4
47
- *
48
- * - O somatório encontrado é dividido por 11. O DV2 é 11 subtraído do resto da divisão. Se o
49
- * resto for 10, o DV2 é 0.
50
- *
51
- * Fonte: https://www.devmedia.com.br/forum/validacao-de-cnh/372972
52
- *
53
- * @param {String} value Título eleitoral
54
- * @returns {Boolean}
55
- */
56
- /**
57
- * Calcula o Dígito Verificador de um RENAVAM informado
58
- *
59
- * @returns String Número fake de um cnh válido
60
- */
61
- export declare const dv: (value: string | number) => string;
62
- /**
63
- * validateOrFail()
64
- * Valida se um número é válido e
65
- * retorna uma exceção se não estiver
66
- *
67
- * @param {String|Number} value Número a ser validado
68
- * @returns {Boolean}
69
- */
70
- export declare const validateOrFail: (value: string | number) => boolean;
71
- /**
72
- * validate()
73
- * Valida se um número é válido
74
- *
75
- * @param {String|Number} value Número a ser validado
76
- * @returns {Boolean}
77
- */
78
- export declare const validate: (value: string | number) => boolean;
79
- /**
80
- * Aplica uma máscara a uma string
81
- *
82
- * @returns String string com a máscara aplicada
83
- */
84
- export declare const mask: (value: string | number) => string;
85
- /**
86
- * Cria um número fake
87
- *
88
- * @returns String Número fake porém válido
89
- */
90
- export declare const fake: (withMask?: boolean) => string;
91
- export default validate;
package/dist/cnh.js DELETED
@@ -1,139 +0,0 @@
1
- "use strict";
2
- /**
3
- * isCNH()
4
- * Calcula se uma CNH é válida
5
- *
6
- * @doc
7
- * CNH deve possuir 11 caracteres
8
- *
9
- * - Os caracteres 1 a 9 são números sequenciais.
10
- *
11
- *
12
- * - Os caracteres 10 e 11 são dígitos verificadores.
13
- *
14
- * 1) Partes do número
15
- * ____________________________ ______
16
- * | Número | D V |
17
- * | 5 8 3 1 6 7 9 4 5 3 4 |
18
- * |____________________________|_____|
19
- *
20
- * 2) Cálculo do primeiro DV.
21
- *
22
- * - Soma-se o produto das algarismos 1 a 9 pelos números 2, 3, 4, 5, 6, 7, 8, 9, 10.
23
- *
24
- * 5 8 3 1 6 7 9 4 5
25
- * x x x x x x x x x
26
- * 2 3 4 5 6 7 8 9 10
27
- * = 10 +24 +12 +5 +36 +49 +72 +36 +50 = 294
28
- *
29
- * - O somatório encontrado é dividido por 11. O DV1 é 11 subtraído do resto da divisão. Se o
30
- * resto for 10, o DV1 é 0.
31
- *
32
- * 2.1) 294 / 11 tem resto igual a 8. 11-7 = 3
33
- * DV1 = 3
34
- *
35
- * 3) Cálculo do segundo DV
36
- *
37
- * - Soma-se o produto das algarismos 1 a 9 juntamente com o 10 caractere
38
- * que é o DV1, pelos números 3, 4, 5, 6, 7, 8, 9, 10, 11, 2. O DV1 será
39
- * multiplicado por 2 e ficará no final.
40
- *
41
- * 5 8 3 1 6 7 9 4 5 3
42
- * x x x x x x x x x x
43
- * 3 4 5 6 7 8 9 10 11 2
44
- * = 10 +24 +12 +5 +36 +49 +72 +36 +50 +6 = 348
45
- *
46
- * 3.1) 348 / 11 tem resto igual a 7. 11 - 7 = 4.
47
- * DV2 = 4
48
- *
49
- * - O somatório encontrado é dividido por 11. O DV2 é 11 subtraído do resto da divisão. Se o
50
- * resto for 10, o DV2 é 0.
51
- *
52
- * Fonte: https://www.devmedia.com.br/forum/validacao-de-cnh/372972
53
- *
54
- * @param {String} value Título eleitoral
55
- * @returns {Boolean}
56
- */
57
- var __importDefault = (this && this.__importDefault) || function (mod) {
58
- return (mod && mod.__esModule) ? mod : { "default": mod };
59
- };
60
- Object.defineProperty(exports, "__esModule", { value: true });
61
- exports.fake = exports.mask = exports.validate = exports.validateOrFail = exports.dv = void 0;
62
- const ValidationBRError_1 = __importDefault(require("./data/ValidationBRError"));
63
- const utils_1 = require("./utils");
64
- /**
65
- * Calcula o Dígito Verificador de um RENAVAM informado
66
- *
67
- * @returns String Número fake de um cnh válido
68
- */
69
- const dv = (value) => {
70
- const cnh = (0, utils_1.clearValue)(value, 9, {
71
- trimAtRight: true,
72
- rejectEmpty: true,
73
- });
74
- const sum1 = (0, utils_1.sumElementsByMultipliers)(cnh.substring(0, 9), [2, 3, 4, 5, 6, 7, 8, 9, 10]);
75
- const dv1 = (0, utils_1.sumToDV)(sum1);
76
- const sum2 = (0, utils_1.sumElementsByMultipliers)(cnh.substring(0, 9) + dv1, [3, 4, 5, 6, 7, 8, 9, 10, 11, 2]);
77
- const dv2 = (0, utils_1.sumToDV)(sum2);
78
- return `${dv1}${dv2}`;
79
- };
80
- exports.dv = dv;
81
- /**
82
- * validateOrFail()
83
- * Valida se um número é válido e
84
- * retorna uma exceção se não estiver
85
- *
86
- * @param {String|Number} value Número a ser validado
87
- * @returns {Boolean}
88
- */
89
- const validateOrFail = (value) => {
90
- const cnh = (0, utils_1.clearValue)(value, 11, {
91
- fillZerosAtLeft: true,
92
- rejectEmpty: true,
93
- rejectHigherLength: true,
94
- rejectEqualSequence: true,
95
- });
96
- if ((0, exports.dv)(cnh) !== cnh.substring(9, 11)) {
97
- throw ValidationBRError_1.default.INVALID_DV;
98
- }
99
- return true;
100
- };
101
- exports.validateOrFail = validateOrFail;
102
- /**
103
- * validate()
104
- * Valida se um número é válido
105
- *
106
- * @param {String|Number} value Número a ser validado
107
- * @returns {Boolean}
108
- */
109
- const validate = (value) => {
110
- try {
111
- return (0, exports.validateOrFail)(value);
112
- }
113
- catch (error) {
114
- return false;
115
- }
116
- };
117
- exports.validate = validate;
118
- /**
119
- * Aplica uma máscara a uma string
120
- *
121
- * @returns String string com a máscara aplicada
122
- */
123
- const mask = (value) => (0, utils_1.applyMask)(value, '000000000-00');
124
- exports.mask = mask;
125
- /**
126
- * Cria um número fake
127
- *
128
- * @returns String Número fake porém válido
129
- */
130
- const fake = (withMask = false) => {
131
- const value = (0, utils_1.fakeNumber)(9, true);
132
- const cnh = `${value}${(0, exports.dv)(value)}`;
133
- if (withMask)
134
- return (0, exports.mask)(cnh);
135
- return cnh;
136
- };
137
- exports.fake = fake;
138
- exports.default = exports.validate;
139
- //# sourceMappingURL=cnh.js.map
package/dist/cnh.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"cnh.js","sourceRoot":"","sources":["../src/cnh.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;;;;;;AAEH,iFAAwD;AACxD,mCAA8F;AAE9F;;;;GAIG;AACI,MAAM,EAAE,GAAG,CAAC,KAAsB,EAAU,EAAE;IACnD,MAAM,GAAG,GAAG,IAAA,kBAAU,EAAC,KAAK,EAAE,CAAC,EAAE;QAC/B,WAAW,EAAE,IAAI;QACjB,WAAW,EAAE,IAAI;KAClB,CAAC,CAAA;IAEF,MAAM,IAAI,GAAG,IAAA,gCAAwB,EAAC,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAA;IACxF,MAAM,GAAG,GAAG,IAAA,eAAO,EAAC,IAAI,CAAC,CAAA;IAEzB,MAAM,IAAI,GAAG,IAAA,gCAAwB,EAAC,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,CAAA;IAClG,MAAM,GAAG,GAAG,IAAA,eAAO,EAAC,IAAI,CAAC,CAAA;IAEzB,OAAO,GAAG,GAAG,GAAG,GAAG,EAAE,CAAA;AACvB,CAAC,CAAA;AAbY,QAAA,EAAE,MAad;AAED;;;;;;;GAOG;AACI,MAAM,cAAc,GAAG,CAAC,KAAsB,EAAW,EAAE;IAChE,MAAM,GAAG,GAAG,IAAA,kBAAU,EAAC,KAAK,EAAE,EAAE,EAAE;QAChC,eAAe,EAAE,IAAI;QACrB,WAAW,EAAE,IAAI;QACjB,kBAAkB,EAAE,IAAI;QACxB,mBAAmB,EAAE,IAAI;KAC1B,CAAC,CAAA;IAEF,IAAI,IAAA,UAAE,EAAC,GAAG,CAAC,KAAK,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC;QACrC,MAAM,2BAAiB,CAAC,UAAU,CAAA;IACpC,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AAbY,QAAA,cAAc,kBAa1B;AAED;;;;;;GAMG;AACI,MAAM,QAAQ,GAAG,CAAC,KAAsB,EAAW,EAAE;IAC1D,IAAI,CAAC;QACH,OAAO,IAAA,sBAAc,EAAC,KAAK,CAAC,CAAA;IAC9B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,KAAK,CAAA;IACd,CAAC;AACH,CAAC,CAAA;AANY,QAAA,QAAQ,YAMpB;AAED;;;;GAIG;AACI,MAAM,IAAI,GAAG,CAAC,KAAsB,EAAU,EAAE,CAAC,IAAA,iBAAS,EAAC,KAAK,EAAE,cAAc,CAAC,CAAA;AAA3E,QAAA,IAAI,QAAuE;AAExF;;;;GAIG;AACI,MAAM,IAAI,GAAG,CAAC,WAAoB,KAAK,EAAU,EAAE;IACxD,MAAM,KAAK,GAAG,IAAA,kBAAU,EAAC,CAAC,EAAE,IAAI,CAAC,CAAA;IAEjC,MAAM,GAAG,GAAG,GAAG,KAAK,GAAG,IAAA,UAAE,EAAC,KAAK,CAAC,EAAE,CAAA;IAElC,IAAI,QAAQ;QAAE,OAAO,IAAA,YAAI,EAAC,GAAG,CAAC,CAAA;IAE9B,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA;AARY,QAAA,IAAI,QAQhB;AAED,kBAAe,gBAAQ,CAAA"}
@@ -1 +0,0 @@
1
- export {};
package/dist/cnpj.d.ts DELETED
@@ -1,114 +0,0 @@
1
- /**
2
- * isCNPJ()
3
- * Calcula se um CNPJ é válido
4
- *
5
- * A partir da Nota Técnica conjunta COCAD/SUARA/RFB nº 49 de 14 de maio de 2024, CNPJ passa
6
- * a poder ser criado com letras e números, ao invés de apenas números. Esta alteração entra
7
- * em vigor em 2026.
8
- *
9
- *
10
- * @doc
11
- * - CNPJ deve possuir 14 dígitos no formato AA.AAA.AAA/AAAA-NN, onde A representa letras
12
- * ou números e N representa números (Nota Técnica conjunta COCAD/SUARA/RFB nº 49 de 14 de maio de 2024)
13
- *
14
- * - Os caracteres 1 a 8 são a identificação da empresa definida pela Receita Federal. Podem ser letras ou números
15
- *
16
- * - Os caracteres 9 a 12 são a identificação das filiais da empresa. Podendo ser letras ou números
17
- *
18
- * - Os caracteres 13 e 14 são os dígitos verificadores
19
- *
20
- * 1) Partes do número
21
- * _______________________________ _______________ _______
22
- * | Número | Filiais | DV |
23
- * | 1 1 . 2 2 2 . 3 3 3 / 0 0 0 1 - X Y |
24
- * |_______________________________|_______________|_______|
25
- *
26
- *
27
- * 2.1) Conversão dos números para tabela ASCII
28
- * Converte os caracteres do CNPJ em valores numéricos, mesmo que alguns deles
29
- * sejam numéricos. A conversão será baseada na tabela ASCII
30
- *
31
- * Tabela ASCII
32
- * 0 = 48 1 = 49 2 = 50 3 = 51 4 = 52
33
- * 5 = 53 6 = 54 7 = 55 8 = 56 9 = 57
34
- * A = 65 B = 66 C = 67 D = 68 E = 69
35
- * F = 70 G = 71 H = 72 I = 73 J = 74
36
- * K = 75 L = 76 M = 77 N = 78 O = 79
37
- * P = 80 Q = 81 R = 82 S = 83 T = 84
38
- * U = 85 V = 86 W = 87 X = 88 Y = 89
39
- * Z = 90
40
- *
41
- * Ao converter cada dígito do CNPJ para o seu equivalente na tabela ASCII, subtraia de 48
42
- * para obter o número que será multiplicado.
43
- * Como o "0" é 48 e deve-se subtrair de 48, não há mudanças nos números.
44
- *
45
- *
46
- *
47
- * 2) Cálculo do primeiro DV.
48
- *
49
- * - Soma-se o produto das algarismos 1 a 12 pelos números 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2
50
- *
51
- * 1 1 2 2 2 3 3 3 0 0 0 1
52
- * x x x x x x x x x x x x
53
- * 5 4 3 2 9 8 7 6 5 4 3 2
54
- * = 5 +4 +6 +4 +18 +24 +21 +18 +0 +0 +0 +2 = 102
55
- *
56
- * - O somatório encontrado é dividido por 11 e o resultado é subtraído de 11
57
- * 102 / 11 tem resto 8. 11 - 3 = 8. DV1 é 8.
58
- * Obs.: Caso o cálculo de DV1 retorne 10, o resultado será 0.
59
- *
60
- * 3) Cálculo do segundo DV.
61
- *
62
- * - Soma-se o produto das algarismos 1 a 13 (incluindo o DV1 calculado) pelos
63
- * números 6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2.
64
- *
65
- * 1 1 2 2 2 3 3 3 0 0 0 1 8
66
- * x x x x x x x x x x x x x
67
- * 6 5 4 3 2 9 8 7 6 5 4 3 2
68
- * = 6 +5 +8 +6 +4 +27 +24 +21 +0 +0 +0 +3 +16 = 120
69
- *
70
- * - O somatório encontrado é dividido por 11 e o resultado é subtraído de 11
71
- * 120 / 11 tem resto 10. 11 - 10 = 1. DV2 é 1.
72
- * Obs.: Caso o cálculo de DV2 retorne 10, o resultado será 0.
73
- *
74
- * Fonte: http://www.macoratti.net/alg_cnpj.htm
75
- *
76
- * @param {String} value Título eleitoral
77
- * @returns {Boolean}
78
- */
79
- type FakeInput = {
80
- withMask?: boolean;
81
- alphanumeric?: boolean;
82
- };
83
- export declare function dv(value: string | number): string;
84
- /**
85
- * Aplica uma máscara ao número informado
86
- *
87
- * @param {String} value Número de Processo
88
- * @returns {String} Valor com a máscara
89
- */
90
- export declare function mask(value: string | number): string;
91
- /**
92
- *
93
- *
94
- */
95
- export declare function fake(options?: FakeInput): string;
96
- export declare function fake(withMask?: boolean): string;
97
- /**
98
- * validateOrFail()
99
- * Valida se um número é válido e
100
- * retorna uma exceção se não estiver
101
- *
102
- * @param {String|Number} value Número a ser validado
103
- * @returns {Boolean}
104
- */
105
- export declare function validateOrFail(value: string | number): boolean;
106
- /**
107
- * validate()
108
- * Valida se um número é válido
109
- *
110
- * @param {String|Number} value Número a ser validado
111
- * @returns {Boolean}
112
- */
113
- export declare function validate(value: string | number): boolean;
114
- export default validate;