validation-br 1.5.1 → 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.
- package/.prettierrc +9 -0
- package/dist/jest.config.d.ts +8 -0
- package/dist/jest.config.d.ts.map +1 -0
- package/dist/jest.config.js +154 -0
- package/dist/jest.config.js.map +1 -0
- package/dist/test/_helpers/array_random.spec.d.ts +2 -0
- package/dist/test/_helpers/array_random.spec.d.ts.map +1 -0
- package/dist/test/_helpers/array_random.spec.js +13 -0
- package/dist/test/_helpers/array_random.spec.js.map +1 -0
- package/dist/test/_helpers/crc.spec.d.ts +2 -0
- package/dist/test/_helpers/crc.spec.d.ts.map +1 -0
- package/dist/test/_helpers/crc.spec.js +11 -0
- package/dist/test/_helpers/crc.spec.js.map +1 -0
- package/dist/test/carplate.spec.d.ts +2 -0
- package/dist/test/carplate.spec.d.ts.map +1 -0
- package/dist/test/carplate.spec.js +141 -0
- package/dist/test/carplate.spec.js.map +1 -0
- package/dist/test/cnh.spec.d.ts +2 -0
- package/dist/test/cnh.spec.d.ts.map +1 -0
- package/dist/test/cnh.spec.js +60 -0
- package/dist/test/cnh.spec.js.map +1 -0
- package/dist/test/cnpj.spec.d.ts +2 -0
- package/dist/test/cnpj.spec.d.ts.map +1 -0
- package/dist/test/cnpj.spec.js +105 -0
- package/dist/test/cnpj.spec.js.map +1 -0
- package/dist/test/cpf.spec.d.ts +2 -0
- package/dist/test/cpf.spec.d.ts.map +1 -0
- package/dist/test/cpf.spec.js +66 -0
- package/dist/test/cpf.spec.js.map +1 -0
- package/dist/test/index.test.d.ts +2 -0
- package/dist/test/index.test.d.ts.map +1 -0
- package/dist/test/index.test.js +77 -0
- package/dist/test/index.test.js.map +1 -0
- package/dist/test/judicial-process.spec.d.ts +2 -0
- package/dist/test/judicial-process.spec.d.ts.map +1 -0
- package/dist/test/judicial-process.spec.js +101 -0
- package/dist/test/judicial-process.spec.js.map +1 -0
- package/dist/test/nup17.spec.d.ts +2 -0
- package/dist/test/nup17.spec.d.ts.map +1 -0
- package/dist/test/nup17.spec.js +70 -0
- package/dist/test/nup17.spec.js.map +1 -0
- package/dist/test/phone.spec.d.ts +2 -0
- package/dist/test/phone.spec.d.ts.map +1 -0
- package/dist/test/phone.spec.js +67 -0
- package/dist/test/phone.spec.js.map +1 -0
- package/dist/test/pis-pasep.spec.d.ts +2 -0
- package/dist/test/pis-pasep.spec.d.ts.map +1 -0
- package/dist/test/pis-pasep.spec.js +65 -0
- package/dist/test/pis-pasep.spec.js.map +1 -0
- package/dist/test/pix-copy-paste.spec.d.ts +2 -0
- package/dist/test/pix-copy-paste.spec.d.ts.map +1 -0
- package/dist/test/pix-copy-paste.spec.js +31 -0
- package/dist/test/pix-copy-paste.spec.js.map +1 -0
- package/dist/test/pix-key.spec.d.ts +2 -0
- package/dist/test/pix-key.spec.d.ts.map +1 -0
- package/dist/test/pix-key.spec.js +36 -0
- package/dist/test/pix-key.spec.js.map +1 -0
- package/dist/test/postal-track-code.test.d.ts +2 -0
- package/dist/test/postal-track-code.test.d.ts.map +1 -0
- package/dist/test/postal-track-code.test.js +75 -0
- package/dist/test/postal-track-code.test.js.map +1 -0
- package/dist/test/renavam.spec.d.ts +2 -0
- package/dist/test/renavam.spec.d.ts.map +1 -0
- package/dist/test/renavam.spec.js +63 -0
- package/dist/test/renavam.spec.js.map +1 -0
- package/dist/test/tituloEleitor.spec.d.ts +2 -0
- package/dist/test/tituloEleitor.spec.d.ts.map +1 -0
- package/dist/test/tituloEleitor.spec.js +68 -0
- package/dist/test/tituloEleitor.spec.js.map +1 -0
- package/dist/test/utils-applyMask.test.d.ts +2 -0
- package/dist/test/utils-applyMask.test.d.ts.map +1 -0
- package/dist/test/utils-applyMask.test.js +18 -0
- package/dist/test/utils-applyMask.test.js.map +1 -0
- package/dist/test/utils-checkRepeatedSequence.test.d.ts +2 -0
- package/dist/test/utils-checkRepeatedSequence.test.d.ts.map +1 -0
- package/dist/test/utils-checkRepeatedSequence.test.js +18 -0
- package/dist/test/utils-checkRepeatedSequence.test.js.map +1 -0
- package/dist/test/utils-clearValue.test.d.ts +2 -0
- package/dist/test/utils-clearValue.test.d.ts.map +1 -0
- package/dist/test/utils-clearValue.test.js +74 -0
- package/dist/test/utils-clearValue.test.js.map +1 -0
- package/dist/test/utils-fakeNumber.test.d.ts +2 -0
- package/dist/test/utils-fakeNumber.test.d.ts.map +1 -0
- package/dist/test/utils-fakeNumber.test.js +24 -0
- package/dist/test/utils-fakeNumber.test.js.map +1 -0
- package/dist/test/utils-insertAtPosition.test.d.ts +2 -0
- package/dist/test/utils-insertAtPosition.test.d.ts.map +1 -0
- package/dist/test/utils-insertAtPosition.test.js +16 -0
- package/dist/test/utils-insertAtPosition.test.js.map +1 -0
- package/dist/test/utils-randomLetter.test.d.ts +2 -0
- package/dist/test/utils-randomLetter.test.d.ts.map +1 -0
- package/dist/test/utils-randomLetter.test.js +14 -0
- package/dist/test/utils-randomLetter.test.js.map +1 -0
- package/dist/test/utils-removeFromPosition.test.d.ts +2 -0
- package/dist/test/utils-removeFromPosition.test.d.ts.map +1 -0
- package/dist/test/utils-removeFromPosition.test.js +16 -0
- package/dist/test/utils-removeFromPosition.test.js.map +1 -0
- package/dist/test/utils-sumElementsByMultipliers.test.d.ts +2 -0
- package/dist/test/utils-sumElementsByMultipliers.test.d.ts.map +1 -0
- package/dist/test/utils-sumElementsByMultipliers.test.js +23 -0
- package/dist/test/utils-sumElementsByMultipliers.test.js.map +1 -0
- package/dist/test/utils-sumToDV.test.d.ts +2 -0
- package/dist/test/utils-sumToDV.test.d.ts.map +1 -0
- package/dist/test/utils-sumToDV.test.js +17 -0
- package/dist/test/utils-sumToDV.test.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/eslint.config.mjs +11 -0
- package/jest.config.ts +210 -0
- package/package.json +4 -3
- package/readme.md +3 -2
- package/test/_helpers/array_random.spec.ts +12 -0
- package/test/_helpers/crc.spec.ts +13 -0
- package/test/carplate.spec.ts +161 -0
- package/test/cnh.spec.ts +71 -0
- package/test/cnpj.spec.ts +127 -0
- package/test/cpf.spec.ts +76 -0
- package/test/index.test.ts +112 -0
- package/test/judicial-process.spec.ts +131 -0
- package/test/nup17.spec.ts +79 -0
- package/test/phone.spec.ts +75 -0
- package/test/pis-pasep.spec.ts +73 -0
- package/test/pix-copy-paste.spec.ts +37 -0
- package/test/pix-key.spec.ts +41 -0
- package/test/postal-track-code.test.ts +83 -0
- package/test/renavam.spec.ts +71 -0
- package/test/tituloEleitor.spec.ts +72 -0
- package/test/utils-applyMask.test.ts +17 -0
- package/test/utils-checkRepeatedSequence.test.ts +17 -0
- package/test/utils-clearValue.test.ts +85 -0
- package/test/utils-fakeNumber.test.ts +28 -0
- package/test/utils-insertAtPosition.test.ts +15 -0
- package/test/utils-randomLetter.test.ts +14 -0
- package/test/utils-removeFromPosition.test.ts +15 -0
- package/test/utils-sumElementsByMultipliers.test.ts +24 -0
- package/test/utils-sumToDV.test.ts +16 -0
- package/todo.md +18 -0
- package/tsconfig.json +103 -23
- package/.github/workflows/test.yml +0 -39
- package/.prettierrc.js +0 -7
- package/dist/cnh.d.ts +0 -91
- package/dist/cnh.js +0 -139
- package/dist/cnh.js.map +0 -1
- package/dist/cnh.test.d.ts +0 -1
- package/dist/cnpj.d.ts +0 -87
- package/dist/cnpj.js +0 -151
- package/dist/cnpj.js.map +0 -1
- package/dist/cnpj.test.d.ts +0 -1
- package/dist/cpf.d.ts +0 -99
- package/dist/cpf.js +0 -147
- package/dist/cpf.js.map +0 -1
- package/dist/cpf.test.d.ts +0 -1
- package/dist/data/ValidationBRError.d.ts +0 -6
- package/dist/data/ValidationBRError.js +0 -10
- package/dist/data/ValidationBRError.js.map +0 -1
- package/dist/index.d.ts +0 -21
- package/dist/index.js +0 -42
- package/dist/index.js.map +0 -1
- package/dist/index.test.d.ts +0 -1
- package/dist/judicialProcess.d.ts +0 -126
- package/dist/judicialProcess.js +0 -190
- package/dist/judicialProcess.js.map +0 -1
- package/dist/judicialProcess.test.d.ts +0 -1
- package/dist/nup17.d.ts +0 -102
- package/dist/nup17.js +0 -155
- package/dist/nup17.js.map +0 -1
- package/dist/nup17.test.d.ts +0 -1
- package/dist/pisPasep.d.ts +0 -81
- package/dist/pisPasep.js +0 -126
- package/dist/pisPasep.js.map +0 -1
- package/dist/pisPasep.test.d.ts +0 -1
- package/dist/postalCode.d.ts +0 -83
- package/dist/postalCode.js +0 -136
- package/dist/postalCode.js.map +0 -1
- package/dist/postalCode.test.d.ts +0 -1
- package/dist/renavam.d.ts +0 -75
- package/dist/renavam.js +0 -122
- package/dist/renavam.js.map +0 -1
- package/dist/renavam.test.d.ts +0 -1
- package/dist/tituloEleitor.d.ts +0 -93
- package/dist/tituloEleitor.js +0 -143
- package/dist/tituloEleitor.js.map +0 -1
- package/dist/tituloEleitor.test.d.ts +0 -1
- package/dist/utils-applyMask.test.d.ts +0 -1
- package/dist/utils-checkRepeatedSequence.test.d.ts +0 -1
- package/dist/utils-clearValue.test.d.ts +0 -1
- package/dist/utils-fakeNumber.test.d.ts +0 -1
- package/dist/utils-insertAtPosition.test.d.ts +0 -1
- package/dist/utils-invalidListGenerator.test.d.ts +0 -1
- package/dist/utils-randomLetter.test.d.ts +0 -1
- package/dist/utils-removeFromPosition.test.d.ts +0 -1
- package/dist/utils-sumElementsByMultipliers.test.d.ts +0 -1
- package/dist/utils-sumToDV.test.d.ts +0 -1
- package/dist/utils.d.ts +0 -131
- package/dist/utils.js +0 -189
- package/dist/utils.js.map +0 -1
- package/docs/Nota.COCAD.SUARA.2024.05.49.CNPJ.Alfanumerico-1.pdf +0 -0
- package/eslint.config.js +0 -82
- package/jest.config.js +0 -11
package/tsconfig.json
CHANGED
|
@@ -1,25 +1,105 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;G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00
|
|
7
|
-
*
|
|
8
|
-
* - Os caracteres 1 a 8 são números sequenciais definidos pela Receita Federal
|
|
9
|
-
*
|
|
10
|
-
* - Os caracteres 9 a 12 são a identificação das filiais da empresa.
|
|
11
|
-
*
|
|
12
|
-
* - Os caracteres 13 e 14 são os dígitos verificadores
|
|
13
|
-
*
|
|
14
|
-
* 1) Partes do número
|
|
15
|
-
* _______________________________ _______________ _______
|
|
16
|
-
* | Número | Filiais | DV |
|
|
17
|
-
* | 1 1 . 2 2 2 . 3 3 3 / 0 0 0 1 - X Y |
|
|
18
|
-
* |_______________________________|_______________|_______|
|
|
19
|
-
*
|
|
20
|
-
* 2) Cálculo do primeiro DV.
|
|
21
|
-
*
|
|
22
|
-
* - Soma-se o produto das algarismos 1 a 12 pelos números 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2
|
|
23
|
-
*
|
|
24
|
-
* 1 1 2 2 2 3 3 3 0 0 0 1
|
|
25
|
-
* x x x x x x x x x x x x
|
|
26
|
-
* 5 4 3 2 9 8 7 6 5 4 3 2
|
|
27
|
-
* = 5 +4 +6 +4 +18 +24 +21 +18 +0 +0 +0 +2 = 102
|
|
28
|
-
*
|
|
29
|
-
* - O somatório encontrado é dividido por 11 e o resultado é subtraído de 11
|
|
30
|
-
* 102 / 11 tem resto 8. 11 - 3 = 8. DV1 é 8.
|
|
31
|
-
* Obs.: Caso o cálculo de DV1 retorne 10, o resultado será 0.
|
|
32
|
-
*
|
|
33
|
-
* 3) Cálculo do segundo DV.
|
|
34
|
-
*
|
|
35
|
-
* - Soma-se o produto das algarismos 1 a 13 (incluindo o DV1 calculado) pelos
|
|
36
|
-
* números 6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2.
|
|
37
|
-
*
|
|
38
|
-
* 1 1 2 2 2 3 3 3 0 0 0 1 8
|
|
39
|
-
* x x x x x x x x x x x x x
|
|
40
|
-
* 6 5 4 3 2 9 8 7 6 5 4 3 2
|
|
41
|
-
* = 6 +5 +8 +6 +4 +27 +24 +21 +0 +0 +0 +3 +16 = 120
|
|
42
|
-
*
|
|
43
|
-
* - O somatório encontrado é dividido por 11 e o resultado é subtraído de 11
|
|
44
|
-
* 120 / 11 tem resto 10. 11 - 10 = 1. DV2 é 1.
|
|
45
|
-
* Obs.: Caso o cálculo de DV2 retorne 10, o resultado será 0.
|
|
46
|
-
*
|
|
47
|
-
* Fonte: http://www.macoratti.net/alg_cnpj.htm
|
|
48
|
-
*
|
|
49
|
-
* @param {String} value Título eleitoral
|
|
50
|
-
* @returns {Boolean}
|
|
51
|
-
*/
|
|
52
|
-
type FakeInput = {
|
|
53
|
-
withMask?: boolean;
|
|
54
|
-
alphanumeric?: boolean;
|
|
55
|
-
};
|
|
56
|
-
export declare function dv(value: string | number): string;
|
|
57
|
-
/**
|
|
58
|
-
* Aplica uma máscara ao número informado
|
|
59
|
-
*
|
|
60
|
-
* @param {String} value Número de Processo
|
|
61
|
-
* @returns {String} Valor com a máscara
|
|
62
|
-
*/
|
|
63
|
-
export declare function mask(value: string | number): string;
|
|
64
|
-
/**
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*/
|
|
68
|
-
export declare function fake(options?: FakeInput): string;
|
|
69
|
-
export declare function fake(withMask?: boolean): string;
|
|
70
|
-
/**
|
|
71
|
-
* validateOrFail()
|
|
72
|
-
* Valida se um número é válido e
|
|
73
|
-
* retorna uma exceção se não estiver
|
|
74
|
-
*
|
|
75
|
-
* @param {String|Number} value Número a ser validado
|
|
76
|
-
* @returns {Boolean}
|
|
77
|
-
*/
|
|
78
|
-
export declare function validateOrFail(value: string | number): boolean;
|
|
79
|
-
/**
|
|
80
|
-
* validate()
|
|
81
|
-
* Valida se um número é válido
|
|
82
|
-
*
|
|
83
|
-
* @param {String|Number} value Número a ser validado
|
|
84
|
-
* @returns {Boolean}
|
|
85
|
-
*/
|
|
86
|
-
export declare function validate(value: string | number): boolean;
|
|
87
|
-
export default validate;
|
package/dist/cnpj.js
DELETED
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* isCNPJ()
|
|
4
|
-
* Calcula se um CNPJ é válido
|
|
5
|
-
*
|
|
6
|
-
* @doc
|
|
7
|
-
* - CNPJ deve possuir 14 dígitos no formato 00.000.000/0000-00
|
|
8
|
-
*
|
|
9
|
-
* - Os caracteres 1 a 8 são números sequenciais definidos pela Receita Federal
|
|
10
|
-
*
|
|
11
|
-
* - Os caracteres 9 a 12 são a identificação das filiais da empresa.
|
|
12
|
-
*
|
|
13
|
-
* - Os caracteres 13 e 14 são os dígitos verificadores
|
|
14
|
-
*
|
|
15
|
-
* 1) Partes do número
|
|
16
|
-
* _______________________________ _______________ _______
|
|
17
|
-
* | Número | Filiais | DV |
|
|
18
|
-
* | 1 1 . 2 2 2 . 3 3 3 / 0 0 0 1 - X Y |
|
|
19
|
-
* |_______________________________|_______________|_______|
|
|
20
|
-
*
|
|
21
|
-
* 2) Cálculo do primeiro DV.
|
|
22
|
-
*
|
|
23
|
-
* - Soma-se o produto das algarismos 1 a 12 pelos números 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2
|
|
24
|
-
*
|
|
25
|
-
* 1 1 2 2 2 3 3 3 0 0 0 1
|
|
26
|
-
* x x x x x x x x x x x x
|
|
27
|
-
* 5 4 3 2 9 8 7 6 5 4 3 2
|
|
28
|
-
* = 5 +4 +6 +4 +18 +24 +21 +18 +0 +0 +0 +2 = 102
|
|
29
|
-
*
|
|
30
|
-
* - O somatório encontrado é dividido por 11 e o resultado é subtraído de 11
|
|
31
|
-
* 102 / 11 tem resto 8. 11 - 3 = 8. DV1 é 8.
|
|
32
|
-
* Obs.: Caso o cálculo de DV1 retorne 10, o resultado será 0.
|
|
33
|
-
*
|
|
34
|
-
* 3) Cálculo do segundo DV.
|
|
35
|
-
*
|
|
36
|
-
* - Soma-se o produto das algarismos 1 a 13 (incluindo o DV1 calculado) pelos
|
|
37
|
-
* números 6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2.
|
|
38
|
-
*
|
|
39
|
-
* 1 1 2 2 2 3 3 3 0 0 0 1 8
|
|
40
|
-
* x x x x x x x x x x x x x
|
|
41
|
-
* 6 5 4 3 2 9 8 7 6 5 4 3 2
|
|
42
|
-
* = 6 +5 +8 +6 +4 +27 +24 +21 +0 +0 +0 +3 +16 = 120
|
|
43
|
-
*
|
|
44
|
-
* - O somatório encontrado é dividido por 11 e o resultado é subtraído de 11
|
|
45
|
-
* 120 / 11 tem resto 10. 11 - 10 = 1. DV2 é 1.
|
|
46
|
-
* Obs.: Caso o cálculo de DV2 retorne 10, o resultado será 0.
|
|
47
|
-
*
|
|
48
|
-
* Fonte: http://www.macoratti.net/alg_cnpj.htm
|
|
49
|
-
*
|
|
50
|
-
* @param {String} value Título eleitoral
|
|
51
|
-
* @returns {Boolean}
|
|
52
|
-
*/
|
|
53
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
54
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
55
|
-
};
|
|
56
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
57
|
-
exports.dv = dv;
|
|
58
|
-
exports.mask = mask;
|
|
59
|
-
exports.fake = fake;
|
|
60
|
-
exports.validateOrFail = validateOrFail;
|
|
61
|
-
exports.validate = validate;
|
|
62
|
-
const ValidationBRError_1 = __importDefault(require("./data/ValidationBRError"));
|
|
63
|
-
const utils_1 = require("./utils");
|
|
64
|
-
function dv(value) {
|
|
65
|
-
const cnpj = (0, utils_1.clearValue)(value, 12, {
|
|
66
|
-
trimAtRight: true,
|
|
67
|
-
rejectEmpty: true,
|
|
68
|
-
});
|
|
69
|
-
const dv1Factors = [5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2];
|
|
70
|
-
const dv1 = sumToDvWithAlpha(cnpj.substring(0, 12), dv1Factors);
|
|
71
|
-
const dv2Factors = [6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2];
|
|
72
|
-
const dv2 = sumToDvWithAlpha(cnpj.substring(0, 12) + dv1, dv2Factors);
|
|
73
|
-
return `${dv1}${dv2}`;
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Aplica uma máscara ao número informado
|
|
77
|
-
*
|
|
78
|
-
* @param {String} value Número de Processo
|
|
79
|
-
* @returns {String} Valor com a máscara
|
|
80
|
-
*/
|
|
81
|
-
function mask(value) {
|
|
82
|
-
return (0, utils_1.applyMask)(value, '00.000.000/0000-00');
|
|
83
|
-
}
|
|
84
|
-
function fake(options = false) {
|
|
85
|
-
const num = (0, utils_1.fakeNumber)(12, true);
|
|
86
|
-
const cnpj = `${num}${dv(num)}`;
|
|
87
|
-
const withMask = typeof options === 'boolean' ? options : options.withMask;
|
|
88
|
-
if (withMask)
|
|
89
|
-
return mask(cnpj);
|
|
90
|
-
return cnpj;
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* validateOrFail()
|
|
94
|
-
* Valida se um número é válido e
|
|
95
|
-
* retorna uma exceção se não estiver
|
|
96
|
-
*
|
|
97
|
-
* @param {String|Number} value Número a ser validado
|
|
98
|
-
* @returns {Boolean}
|
|
99
|
-
*/
|
|
100
|
-
function validateOrFail(value) {
|
|
101
|
-
const cnpj = (0, utils_1.clearValue)(value, 14, {
|
|
102
|
-
fillZerosAtLeft: false,
|
|
103
|
-
rejectEmpty: true,
|
|
104
|
-
rejectHigherLength: true,
|
|
105
|
-
rejectEqualSequence: true,
|
|
106
|
-
});
|
|
107
|
-
if (dv(cnpj) !== cnpj.substring(12, 14)) {
|
|
108
|
-
throw ValidationBRError_1.default.INVALID_DV;
|
|
109
|
-
}
|
|
110
|
-
return true;
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* validate()
|
|
114
|
-
* Valida se um número é válido
|
|
115
|
-
*
|
|
116
|
-
* @param {String|Number} value Número a ser validado
|
|
117
|
-
* @returns {Boolean}
|
|
118
|
-
*/
|
|
119
|
-
function validate(value) {
|
|
120
|
-
try {
|
|
121
|
-
return validateOrFail(value);
|
|
122
|
-
}
|
|
123
|
-
catch (error) {
|
|
124
|
-
return false;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
exports.default = validate;
|
|
128
|
-
/**
|
|
129
|
-
*
|
|
130
|
-
* Converte o número para
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*/
|
|
134
|
-
function asciiTableConverter(character) {
|
|
135
|
-
if (/^\d$/.test(character))
|
|
136
|
-
return +character;
|
|
137
|
-
const ascii = character.toLocaleUpperCase().charCodeAt(0) - 48;
|
|
138
|
-
return ascii;
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
*
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
*/
|
|
145
|
-
function sumToDvWithAlpha(value, multiplier) {
|
|
146
|
-
const sum = [...value]
|
|
147
|
-
.map(character => asciiTableConverter(character))
|
|
148
|
-
.reduce((sum, asciiChar, index) => sum + asciiChar * multiplier[index], 0);
|
|
149
|
-
return (0, utils_1.sumToDV)(sum);
|
|
150
|
-
}
|
|
151
|
-
//# sourceMappingURL=cnpj.js.map
|
package/dist/cnpj.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cnpj.js","sourceRoot":"","sources":["../src/cnpj.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;;;;;AAUH,gBAaC;AAQD,oBAEC;AAQD,oBASC;AAUD,wCAaC;AASD,4BAMC;AAtFD,iFAAwD;AACxD,mCAA8F;AAO9F,SAAgB,EAAE,CAAC,KAAsB;IACvC,MAAM,IAAI,GAAG,IAAA,kBAAU,EAAC,KAAK,EAAE,EAAE,EAAE;QACjC,WAAW,EAAE,IAAI;QACjB,WAAW,EAAE,IAAI;KAClB,CAAC,CAAA;IAEF,MAAM,UAAU,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAA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