validation-br 2.0.0-next-8 → 2.0.0-next-10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{_helpers → cjs/_helpers}/crc.js +0 -1
- package/dist/{_helpers → cjs/_helpers}/crockford.js +2 -2
- package/dist/{_helpers → cjs/_helpers}/mask.js +0 -1
- package/dist/{_helpers → cjs/_helpers}/random.js +1 -1
- package/dist/{base.js → cjs/base.js} +0 -1
- package/dist/{carplate.js → cjs/carplate.js} +1 -2
- package/dist/{cbi_sinter.js → cjs/cbi_sinter.js} +1 -1
- package/dist/{cep.js → cjs/cep.js} +70 -71
- package/dist/cjs/certidao.d.ts +111 -0
- package/dist/cjs/certidao.js +174 -0
- package/dist/{cnh.js → cjs/cnh.js} +1 -1
- package/dist/{cnpj.js → cjs/cnpj.js} +3 -3
- package/dist/{cpf.js → cjs/cpf.js} +1 -2
- package/dist/{email.js → cjs/email.js} +1 -2
- package/dist/{judicial-process.js → cjs/judicial-process.js} +1 -8
- package/dist/{nup17.js → cjs/nup17.js} +1 -2
- package/dist/cjs/package.json +3 -0
- package/dist/{phone.js → cjs/phone.js} +23 -23
- package/dist/{pis-pasep.js → cjs/pis-pasep.js} +1 -2
- package/dist/{pix-copy-paste.js → cjs/pix-copy-paste.js} +3 -3
- package/dist/{pix-key.js → cjs/pix-key.js} +5 -7
- package/dist/{postal-track-code.js → cjs/postal-track-code.js} +1 -1
- package/dist/{renavam.js → cjs/renavam.js} +1 -2
- package/dist/{tituloEleitor.js → cjs/tituloEleitor.js} +1 -2
- package/dist/{uf.js → cjs/uf.js} +33 -35
- package/dist/{uuid.js → cjs/uuid.js} +8 -6
- package/dist/esm/_exceptions/ValidationBRError.d.ts +24 -0
- package/dist/esm/_exceptions/ValidationBRError.js +40 -0
- package/dist/esm/_helpers/crc.d.ts +7 -0
- package/dist/esm/_helpers/crc.js +43 -0
- package/dist/esm/_helpers/crockford.d.ts +31 -0
- package/dist/esm/_helpers/crockford.js +58 -0
- package/dist/esm/_helpers/mask.d.ts +18 -0
- package/dist/esm/_helpers/mask.js +33 -0
- package/dist/esm/_helpers/random.d.ts +27 -0
- package/dist/esm/_helpers/random.js +50 -0
- package/dist/esm/_helpers/utils.d.ts +94 -0
- package/dist/esm/_helpers/utils.js +119 -0
- package/dist/esm/base.d.ts +33 -0
- package/dist/esm/base.js +45 -0
- package/dist/esm/carplate.d.ts +31 -0
- package/dist/esm/carplate.js +65 -0
- package/dist/esm/cbi_sinter.d.ts +78 -0
- package/dist/esm/cbi_sinter.js +119 -0
- package/dist/esm/cep.d.ts +61 -0
- package/dist/esm/cep.js +183 -0
- package/dist/esm/certidao.d.ts +111 -0
- package/dist/esm/certidao.js +170 -0
- package/dist/esm/cnh.d.ts +80 -0
- package/dist/esm/cnh.js +124 -0
- package/dist/esm/cnpj.d.ts +107 -0
- package/dist/esm/cnpj.js +170 -0
- package/dist/esm/cpf.d.ts +88 -0
- package/dist/esm/cpf.js +132 -0
- package/dist/esm/email.d.ts +12 -0
- package/dist/esm/email.js +36 -0
- package/dist/esm/index.d.ts +15 -0
- package/dist/esm/index.js +39 -0
- package/dist/esm/judicial-process.d.ts +150 -0
- package/dist/esm/judicial-process.js +253 -0
- package/dist/esm/nup17.d.ts +98 -0
- package/dist/esm/nup17.js +150 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/phone.d.ts +103 -0
- package/dist/esm/phone.js +165 -0
- package/dist/esm/pis-pasep.d.ts +70 -0
- package/dist/esm/pis-pasep.js +111 -0
- package/dist/esm/pix-copy-paste.d.ts +26 -0
- package/dist/esm/pix-copy-paste.js +78 -0
- package/dist/esm/pix-key.d.ts +29 -0
- package/dist/esm/pix-key.js +83 -0
- package/dist/esm/postal-track-code.d.ts +76 -0
- package/dist/esm/postal-track-code.js +125 -0
- package/dist/esm/renavam.d.ts +31 -0
- package/dist/esm/renavam.js +108 -0
- package/dist/esm/tituloEleitor.d.ts +82 -0
- package/dist/esm/tituloEleitor.js +129 -0
- package/dist/esm/uf.d.ts +89 -0
- package/dist/esm/uf.js +223 -0
- package/dist/esm/uuid.d.ts +9 -0
- package/dist/esm/uuid.js +29 -0
- package/package.json +138 -129
- package/readme.md +412 -160
- package/dist/certidao.d.ts +0 -83
- package/dist/certidao.js +0 -130
- /package/dist/{_exceptions → cjs/_exceptions}/ValidationBRError.d.ts +0 -0
- /package/dist/{_exceptions → cjs/_exceptions}/ValidationBRError.js +0 -0
- /package/dist/{_helpers → cjs/_helpers}/crc.d.ts +0 -0
- /package/dist/{_helpers → cjs/_helpers}/crockford.d.ts +0 -0
- /package/dist/{_helpers → cjs/_helpers}/mask.d.ts +0 -0
- /package/dist/{_helpers → cjs/_helpers}/random.d.ts +0 -0
- /package/dist/{_helpers → cjs/_helpers}/utils.d.ts +0 -0
- /package/dist/{_helpers → cjs/_helpers}/utils.js +0 -0
- /package/dist/{base.d.ts → cjs/base.d.ts} +0 -0
- /package/dist/{carplate.d.ts → cjs/carplate.d.ts} +0 -0
- /package/dist/{cbi_sinter.d.ts → cjs/cbi_sinter.d.ts} +0 -0
- /package/dist/{cep.d.ts → cjs/cep.d.ts} +0 -0
- /package/dist/{cnh.d.ts → cjs/cnh.d.ts} +0 -0
- /package/dist/{cnpj.d.ts → cjs/cnpj.d.ts} +0 -0
- /package/dist/{cpf.d.ts → cjs/cpf.d.ts} +0 -0
- /package/dist/{email.d.ts → cjs/email.d.ts} +0 -0
- /package/dist/{index.d.ts → cjs/index.d.ts} +0 -0
- /package/dist/{index.js → cjs/index.js} +0 -0
- /package/dist/{judicial-process.d.ts → cjs/judicial-process.d.ts} +0 -0
- /package/dist/{nup17.d.ts → cjs/nup17.d.ts} +0 -0
- /package/dist/{phone.d.ts → cjs/phone.d.ts} +0 -0
- /package/dist/{pis-pasep.d.ts → cjs/pis-pasep.d.ts} +0 -0
- /package/dist/{pix-copy-paste.d.ts → cjs/pix-copy-paste.d.ts} +0 -0
- /package/dist/{pix-key.d.ts → cjs/pix-key.d.ts} +0 -0
- /package/dist/{postal-track-code.d.ts → cjs/postal-track-code.d.ts} +0 -0
- /package/dist/{renavam.d.ts → cjs/renavam.d.ts} +0 -0
- /package/dist/{tituloEleitor.d.ts → cjs/tituloEleitor.d.ts} +0 -0
- /package/dist/{uf.d.ts → cjs/uf.d.ts} +0 -0
- /package/dist/{uuid.d.ts → cjs/uuid.d.ts} +0 -0
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Crockford = void 0;
|
|
4
4
|
class Crockford {
|
|
5
|
-
// Alfabeto Base 32 de Douglas Crockford (32 caracteres)
|
|
6
|
-
static ALPHABET = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
|
|
7
5
|
/**
|
|
8
6
|
* Normaliza a string conforme as regras do SINTER/CIB:
|
|
9
7
|
* 1. Remove pontuação e espaços
|
|
@@ -60,3 +58,5 @@ class Crockford {
|
|
|
60
58
|
}
|
|
61
59
|
}
|
|
62
60
|
exports.Crockford = Crockford;
|
|
61
|
+
// Alfabeto Base 32 de Douglas Crockford (32 caracteres)
|
|
62
|
+
Crockford.ALPHABET = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
|
|
@@ -23,7 +23,7 @@ class Random {
|
|
|
23
23
|
return result;
|
|
24
24
|
}
|
|
25
25
|
static fromArray(array, length = 1) {
|
|
26
|
-
const _get = () => array
|
|
26
|
+
const _get = () => array[Random.between(0, array.length - 1)];
|
|
27
27
|
if (length === 1)
|
|
28
28
|
return _get();
|
|
29
29
|
const result = [];
|
|
@@ -11,11 +11,10 @@ const base_1 = require("./base");
|
|
|
11
11
|
const ValidationBRError_1 = require("./_exceptions/ValidationBRError");
|
|
12
12
|
const random_1 = require("./_helpers/random");
|
|
13
13
|
class CarPlate extends base_1.Base {
|
|
14
|
-
_value;
|
|
15
|
-
_mask = '000-0000';
|
|
16
14
|
constructor(_value) {
|
|
17
15
|
super(_value);
|
|
18
16
|
this._value = _value;
|
|
17
|
+
this._mask = '000-0000';
|
|
19
18
|
this.normalize();
|
|
20
19
|
if (!this.validate())
|
|
21
20
|
throw new ValidationBRError_1.InvalidFormatException();
|
|
@@ -59,9 +59,9 @@ const random_1 = require("./_helpers/random");
|
|
|
59
59
|
const base_1 = require("./base");
|
|
60
60
|
const utils_1 = require("./_helpers/utils");
|
|
61
61
|
class CBISinter extends base_1.Base {
|
|
62
|
-
_mask = "0000000-0"; // Máscara apenas informativa
|
|
63
62
|
constructor(value) {
|
|
64
63
|
super(value);
|
|
64
|
+
this._mask = "0000000-0"; // Máscara apenas informativa
|
|
65
65
|
this.normalize();
|
|
66
66
|
if (!this.validate()) {
|
|
67
67
|
throw new ValidationBRError_1.InvalidChecksumException();
|
|
@@ -39,79 +39,10 @@ const random_1 = require("./_helpers/random");
|
|
|
39
39
|
const base_1 = require("./base");
|
|
40
40
|
const uf_1 = require("./uf");
|
|
41
41
|
class CEP extends base_1.Base {
|
|
42
|
-
_value;
|
|
43
|
-
_mask = '00000-000';
|
|
44
|
-
static _ranges = {
|
|
45
|
-
// São Paulo(SP) 01000-000 a 19999-999
|
|
46
|
-
[uf_1.UF.SP.value]: [['01000000', '19999999']],
|
|
47
|
-
// Rio de Janeiro(RJ) 20000-000 a 28999-999
|
|
48
|
-
[uf_1.UF.RJ.value]: [['20000000', '28999999']],
|
|
49
|
-
// Espírito Santo(ES) 29000-000 a 29999-999
|
|
50
|
-
[uf_1.UF.ES.value]: [['29000000', '29999999']],
|
|
51
|
-
// Minas Gerais(MG) 30000-000 a 39999-999
|
|
52
|
-
[uf_1.UF.MG.value]: [['30000000', '39999999']],
|
|
53
|
-
// Paraná(PR) 80000-000 a 87999-999
|
|
54
|
-
[uf_1.UF.PR.value]: [['80000000', '87999999']],
|
|
55
|
-
// Santa Catarina(SC) 88000-000 a 89999-999
|
|
56
|
-
[uf_1.UF.SC.value]: [['88000000', '89999999']],
|
|
57
|
-
// Rio Grande do Sul(RS) 90000-000 a 99999-999
|
|
58
|
-
[uf_1.UF.RS.value]: [['90000000', '99999999']],
|
|
59
|
-
// Bahia(BA) 40000-000 a 48999-999
|
|
60
|
-
[uf_1.UF.BA.value]: [['40000000', '48999999']],
|
|
61
|
-
// Sergipe(SE) 49000-000 a 49999-999
|
|
62
|
-
[uf_1.UF.SE.value]: [['49000000', '49999999']],
|
|
63
|
-
// Pernambuco(PE) 50000-000 a 56999-999
|
|
64
|
-
[uf_1.UF.PE.value]: [['50000000', '56999999']],
|
|
65
|
-
// Alagoas(AL) 57000-000 a 57999-999
|
|
66
|
-
[uf_1.UF.AL.value]: [['57000000', '57999999']],
|
|
67
|
-
// Paraíba(PB) 58000-000 a 58999-999
|
|
68
|
-
[uf_1.UF.PB.value]: [['58000000', '58999999']],
|
|
69
|
-
// Rio Grande do Norte(RN) 59000-000 a 59999-999
|
|
70
|
-
[uf_1.UF.RN.value]: [['59000000', '59999999']],
|
|
71
|
-
// Ceará(CE) 60000-000 a 63999-999
|
|
72
|
-
[uf_1.UF.CE.value]: [['60000000', '63999999']],
|
|
73
|
-
// Piauí(PI) 64000-000 a 64999-999
|
|
74
|
-
[uf_1.UF.PI.value]: [['64000000', '64999999']],
|
|
75
|
-
// Maranhão(MA) 65000-000 a 65999-999
|
|
76
|
-
[uf_1.UF.MA.value]: [['65000000', '65999999']],
|
|
77
|
-
// Pará(PA) 66000-000 a 68899-999
|
|
78
|
-
[uf_1.UF.PA.value]: [['66000000', '68899999']],
|
|
79
|
-
// Amapá(AP) 68900-000 a 68999-999
|
|
80
|
-
[uf_1.UF.AP.value]: [['68900000', '68999999']],
|
|
81
|
-
// Amazonas(AM) 1 69000-000 a 69299-999
|
|
82
|
-
// Amazonas(AM) 2 69400-000 a 69899-999
|
|
83
|
-
[uf_1.UF.AM.value]: [
|
|
84
|
-
['69000000', '69299999'],
|
|
85
|
-
['69400000', '69899999'],
|
|
86
|
-
],
|
|
87
|
-
// Roraima(RR) 69300-000 a 69399-999
|
|
88
|
-
[uf_1.UF.RR.value]: [['69300000', '69399999']],
|
|
89
|
-
// Acre(AC) 69900-000 a 69999-999
|
|
90
|
-
[uf_1.UF.AC.value]: [['69900000', '69999999']],
|
|
91
|
-
// Rondônia(RO) 76800-000 a 76999-999
|
|
92
|
-
[uf_1.UF.RO.value]: [['76800000', '76999999']],
|
|
93
|
-
// Tocantins(TO) 77000-000 a 77999-999
|
|
94
|
-
[uf_1.UF.TO.value]: [['77000000', '77999999']],
|
|
95
|
-
// Distrito Federal(DF) 1 70000-000 a 72799-999
|
|
96
|
-
// Distrito Federal(DF) 2 73000-000 a 73699-999
|
|
97
|
-
[uf_1.UF.DF.value]: [
|
|
98
|
-
['70000000', '72799999'],
|
|
99
|
-
['73000000', '73699999'],
|
|
100
|
-
],
|
|
101
|
-
// Goiás(GO) 1 72800-000 a 72999-999
|
|
102
|
-
// Goiás(GO) 2 73700-000 a 76799-999
|
|
103
|
-
[uf_1.UF.GO.value]: [
|
|
104
|
-
['72800000', '72999999'],
|
|
105
|
-
['73700000', '76799999'],
|
|
106
|
-
],
|
|
107
|
-
// Mato Grosso(MT) 78000-000 a 78899-999
|
|
108
|
-
[uf_1.UF.MT.value]: [['78000000', '78899999']],
|
|
109
|
-
// Mato Grosso do Sul(MS) 79000-000 a 79999-999
|
|
110
|
-
[uf_1.UF.MS.value]: [['79000000', '79999999']],
|
|
111
|
-
};
|
|
112
42
|
constructor(_value, options) {
|
|
113
43
|
super(_value);
|
|
114
44
|
this._value = _value;
|
|
45
|
+
this._mask = '00000-000';
|
|
115
46
|
if (!this.validate(options)) {
|
|
116
47
|
throw new ValidationBRError_1.InvalidFormatException();
|
|
117
48
|
}
|
|
@@ -146,7 +77,7 @@ class CEP extends base_1.Base {
|
|
|
146
77
|
if (!isValidFormat)
|
|
147
78
|
return false;
|
|
148
79
|
// Valida se tiver estado
|
|
149
|
-
if (options
|
|
80
|
+
if (options === null || options === void 0 ? void 0 : options.uf) {
|
|
150
81
|
return CEP.getUFByCEP(this._value).short === options.uf.short;
|
|
151
82
|
}
|
|
152
83
|
return true;
|
|
@@ -214,6 +145,74 @@ class CEP extends base_1.Base {
|
|
|
214
145
|
}
|
|
215
146
|
}
|
|
216
147
|
exports.CEP = CEP;
|
|
148
|
+
CEP._ranges = {
|
|
149
|
+
// São Paulo(SP) 01000-000 a 19999-999
|
|
150
|
+
[uf_1.UF.SP.value]: [['01000000', '19999999']],
|
|
151
|
+
// Rio de Janeiro(RJ) 20000-000 a 28999-999
|
|
152
|
+
[uf_1.UF.RJ.value]: [['20000000', '28999999']],
|
|
153
|
+
// Espírito Santo(ES) 29000-000 a 29999-999
|
|
154
|
+
[uf_1.UF.ES.value]: [['29000000', '29999999']],
|
|
155
|
+
// Minas Gerais(MG) 30000-000 a 39999-999
|
|
156
|
+
[uf_1.UF.MG.value]: [['30000000', '39999999']],
|
|
157
|
+
// Paraná(PR) 80000-000 a 87999-999
|
|
158
|
+
[uf_1.UF.PR.value]: [['80000000', '87999999']],
|
|
159
|
+
// Santa Catarina(SC) 88000-000 a 89999-999
|
|
160
|
+
[uf_1.UF.SC.value]: [['88000000', '89999999']],
|
|
161
|
+
// Rio Grande do Sul(RS) 90000-000 a 99999-999
|
|
162
|
+
[uf_1.UF.RS.value]: [['90000000', '99999999']],
|
|
163
|
+
// Bahia(BA) 40000-000 a 48999-999
|
|
164
|
+
[uf_1.UF.BA.value]: [['40000000', '48999999']],
|
|
165
|
+
// Sergipe(SE) 49000-000 a 49999-999
|
|
166
|
+
[uf_1.UF.SE.value]: [['49000000', '49999999']],
|
|
167
|
+
// Pernambuco(PE) 50000-000 a 56999-999
|
|
168
|
+
[uf_1.UF.PE.value]: [['50000000', '56999999']],
|
|
169
|
+
// Alagoas(AL) 57000-000 a 57999-999
|
|
170
|
+
[uf_1.UF.AL.value]: [['57000000', '57999999']],
|
|
171
|
+
// Paraíba(PB) 58000-000 a 58999-999
|
|
172
|
+
[uf_1.UF.PB.value]: [['58000000', '58999999']],
|
|
173
|
+
// Rio Grande do Norte(RN) 59000-000 a 59999-999
|
|
174
|
+
[uf_1.UF.RN.value]: [['59000000', '59999999']],
|
|
175
|
+
// Ceará(CE) 60000-000 a 63999-999
|
|
176
|
+
[uf_1.UF.CE.value]: [['60000000', '63999999']],
|
|
177
|
+
// Piauí(PI) 64000-000 a 64999-999
|
|
178
|
+
[uf_1.UF.PI.value]: [['64000000', '64999999']],
|
|
179
|
+
// Maranhão(MA) 65000-000 a 65999-999
|
|
180
|
+
[uf_1.UF.MA.value]: [['65000000', '65999999']],
|
|
181
|
+
// Pará(PA) 66000-000 a 68899-999
|
|
182
|
+
[uf_1.UF.PA.value]: [['66000000', '68899999']],
|
|
183
|
+
// Amapá(AP) 68900-000 a 68999-999
|
|
184
|
+
[uf_1.UF.AP.value]: [['68900000', '68999999']],
|
|
185
|
+
// Amazonas(AM) 1 69000-000 a 69299-999
|
|
186
|
+
// Amazonas(AM) 2 69400-000 a 69899-999
|
|
187
|
+
[uf_1.UF.AM.value]: [
|
|
188
|
+
['69000000', '69299999'],
|
|
189
|
+
['69400000', '69899999'],
|
|
190
|
+
],
|
|
191
|
+
// Roraima(RR) 69300-000 a 69399-999
|
|
192
|
+
[uf_1.UF.RR.value]: [['69300000', '69399999']],
|
|
193
|
+
// Acre(AC) 69900-000 a 69999-999
|
|
194
|
+
[uf_1.UF.AC.value]: [['69900000', '69999999']],
|
|
195
|
+
// Rondônia(RO) 76800-000 a 76999-999
|
|
196
|
+
[uf_1.UF.RO.value]: [['76800000', '76999999']],
|
|
197
|
+
// Tocantins(TO) 77000-000 a 77999-999
|
|
198
|
+
[uf_1.UF.TO.value]: [['77000000', '77999999']],
|
|
199
|
+
// Distrito Federal(DF) 1 70000-000 a 72799-999
|
|
200
|
+
// Distrito Federal(DF) 2 73000-000 a 73699-999
|
|
201
|
+
[uf_1.UF.DF.value]: [
|
|
202
|
+
['70000000', '72799999'],
|
|
203
|
+
['73000000', '73699999'],
|
|
204
|
+
],
|
|
205
|
+
// Goiás(GO) 1 72800-000 a 72999-999
|
|
206
|
+
// Goiás(GO) 2 73700-000 a 76799-999
|
|
207
|
+
[uf_1.UF.GO.value]: [
|
|
208
|
+
['72800000', '72999999'],
|
|
209
|
+
['73700000', '76799999'],
|
|
210
|
+
],
|
|
211
|
+
// Mato Grosso(MT) 78000-000 a 78899-999
|
|
212
|
+
[uf_1.UF.MT.value]: [['78000000', '78899999']],
|
|
213
|
+
// Mato Grosso do Sul(MS) 79000-000 a 79999-999
|
|
214
|
+
[uf_1.UF.MS.value]: [['79000000', '79999999']],
|
|
215
|
+
};
|
|
217
216
|
class NotFoundCEPException extends ValidationBRError_1.default {
|
|
218
217
|
constructor() {
|
|
219
218
|
super('CEP não encontrado');
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Certidao
|
|
3
|
+
* Detalhamento do cálculo da matrícula (CNJ - 32 dígitos)
|
|
4
|
+
*
|
|
5
|
+
* @doc
|
|
6
|
+
* O Número de Matrícula tem a configuração aaaaaa.bb.cc.dddd.e.fffff.ggg.hhhhhhh-ii, onde:
|
|
7
|
+
*
|
|
8
|
+
* - aaaaaa: Código Nacional da Serventia (identificação única do cartório) ex.: 10453-9
|
|
9
|
+
* - bb: Código do Acervo (01-Acervo Próprio e 02-Acervos incorporados)
|
|
10
|
+
* - cc: Tipo de Serviço Prestado (55 - Serviço de Registro Civil das Pessoas Naturais)
|
|
11
|
+
* - dddd: Ano do Registro - ex.: 2013
|
|
12
|
+
* - e: Tipo do livro
|
|
13
|
+
* 1 - Livro A (Nascimento)
|
|
14
|
+
* 2 - Livro B (Casamento)
|
|
15
|
+
* 3 - Livro B Auxiliar (Registro de casamentos religiosos para fins civis)
|
|
16
|
+
* 4 - Livro C (Óbito)
|
|
17
|
+
* 5 - Livro C Auxiliar (Registro de Natimortos)
|
|
18
|
+
* 6 - Livro D (Registro de Proclamas)
|
|
19
|
+
* 7 - Livro E (Demais atos relativos ao Registro Civil ou Livro E único)
|
|
20
|
+
* 8 - Livro E (Desdobrado para registro específico das Emancipações)
|
|
21
|
+
* 9 - Livro E (Desdobrado para registro específico das Interdições)
|
|
22
|
+
* - fffff: Número do livro - ex.: 00012
|
|
23
|
+
* - ggg: Número da folha - ex.: 021
|
|
24
|
+
* - hhhhhhh: Número do Termo - ex.: 0000123
|
|
25
|
+
* - ii: Dígito Verificador DV, cujo cálculo obedece ao esquema de MÓDULO 11.
|
|
26
|
+
*
|
|
27
|
+
* Exemplo de Cálculo: 104539.01.55.2013.1.00012.021.0000123-21
|
|
28
|
+
*
|
|
29
|
+
* 1) Cálculo do primeiro DV.
|
|
30
|
+
* - Soma-se o produto dos 30 primeiros dígitos por pesos específicos:
|
|
31
|
+
* Pesos: 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
|
|
32
|
+
*
|
|
33
|
+
* 1 0 4 5 3 9 0 1 5 5 2 0 1 3 1 0 0 0 1 2 0 2 1 0 0 0 0 1 2 3
|
|
34
|
+
* x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
|
|
35
|
+
* 2 3 4 5 6 7 8 9 10 0 1 2 3 4 5 6 7 8 9 10 0 1 2 3 4 5 6 7 8 9
|
|
36
|
+
*
|
|
37
|
+
* Soma = 288
|
|
38
|
+
*
|
|
39
|
+
* - O somatório encontrado é dividido por 11.
|
|
40
|
+
* 288 ÷ 11 = 26, com resto 2.
|
|
41
|
+
* DV1 = Resto (2). Se resto for 10, DV1 será 1.
|
|
42
|
+
*
|
|
43
|
+
* 2) Cálculo do segundo DV.
|
|
44
|
+
* - Soma-se o produto dos 31 primeiros dígitos (incluindo DV1) por novos pesos.
|
|
45
|
+
* Pesos: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
|
|
46
|
+
*
|
|
47
|
+
* 1 0 4 5 3 9 0 1 5 5 2 0 1 3 1 0 0 0 1 2 0 2 1 0 0 0 0 1 2 3 2
|
|
48
|
+
* x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
|
|
49
|
+
* 1 2 3 4 5 6 7 8 9 10 0 1 2 3 4 5 6 7 8 9 10 0 1 2 3 4 5 6 7 8 9
|
|
50
|
+
*
|
|
51
|
+
* Soma = 309
|
|
52
|
+
*
|
|
53
|
+
* - O somatório encontrado é dividido por 11.
|
|
54
|
+
* 309 ÷ 11 = 28, com resto 1.
|
|
55
|
+
* DV2 = Resto (1). Se resto for 10, DV2 será 1.
|
|
56
|
+
*
|
|
57
|
+
* Links:
|
|
58
|
+
* - http://ghiorzi.org/DVnew.htm#zc
|
|
59
|
+
* - https://www.arpensp.org.br/calculo-de-matricula
|
|
60
|
+
*
|
|
61
|
+
* @param {String} value Matrícula da Certidão
|
|
62
|
+
* @returns {Boolean}
|
|
63
|
+
*/
|
|
64
|
+
import { Base } from './base';
|
|
65
|
+
export declare enum CertidaoTipoLivro {
|
|
66
|
+
Nascimento = "1",
|
|
67
|
+
Casamento = "2",
|
|
68
|
+
CasamentoReligioso = "3",
|
|
69
|
+
Obito = "4",
|
|
70
|
+
Natimorto = "5",
|
|
71
|
+
Proclamas = "6",
|
|
72
|
+
Outros = "7"
|
|
73
|
+
}
|
|
74
|
+
export declare enum CertidaoServico {
|
|
75
|
+
Notas = "51",
|
|
76
|
+
Protesto = "52",
|
|
77
|
+
RegistroImoveis = "53",
|
|
78
|
+
RegistroTitulosDocumentos = "54",
|
|
79
|
+
RegistroCivilPessoasNaturais = "55",
|
|
80
|
+
RegistroContratosMaritimos = "56",
|
|
81
|
+
RegistroDistribuicao = "57"
|
|
82
|
+
}
|
|
83
|
+
export interface FakeCertidaoOptions {
|
|
84
|
+
cns?: string;
|
|
85
|
+
acervo?: string;
|
|
86
|
+
servico?: CertidaoServico;
|
|
87
|
+
ano?: number;
|
|
88
|
+
tipoLivro?: CertidaoTipoLivro;
|
|
89
|
+
livro?: number;
|
|
90
|
+
folha?: number;
|
|
91
|
+
termo?: number;
|
|
92
|
+
}
|
|
93
|
+
export declare class Certidao extends Base {
|
|
94
|
+
protected _value: string;
|
|
95
|
+
protected _mask: string;
|
|
96
|
+
constructor(_value: string);
|
|
97
|
+
protected normalize(): void;
|
|
98
|
+
/**
|
|
99
|
+
* Valida se a certidão atual possui o DV correto e tamanho 32
|
|
100
|
+
*/
|
|
101
|
+
validate(): boolean;
|
|
102
|
+
/**
|
|
103
|
+
* Calcula o DV para uma sequência de 30 dígitos
|
|
104
|
+
* Algoritmo Módulo 97:
|
|
105
|
+
*/
|
|
106
|
+
static checksum(base30: string): string;
|
|
107
|
+
/**
|
|
108
|
+
* Gera uma instância de Certidao válida com dados aleatórios ou específicos
|
|
109
|
+
*/
|
|
110
|
+
static fake(options?: FakeCertidaoOptions): Certidao;
|
|
111
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Certidao
|
|
4
|
+
* Detalhamento do cálculo da matrícula (CNJ - 32 dígitos)
|
|
5
|
+
*
|
|
6
|
+
* @doc
|
|
7
|
+
* O Número de Matrícula tem a configuração aaaaaa.bb.cc.dddd.e.fffff.ggg.hhhhhhh-ii, onde:
|
|
8
|
+
*
|
|
9
|
+
* - aaaaaa: Código Nacional da Serventia (identificação única do cartório) ex.: 10453-9
|
|
10
|
+
* - bb: Código do Acervo (01-Acervo Próprio e 02-Acervos incorporados)
|
|
11
|
+
* - cc: Tipo de Serviço Prestado (55 - Serviço de Registro Civil das Pessoas Naturais)
|
|
12
|
+
* - dddd: Ano do Registro - ex.: 2013
|
|
13
|
+
* - e: Tipo do livro
|
|
14
|
+
* 1 - Livro A (Nascimento)
|
|
15
|
+
* 2 - Livro B (Casamento)
|
|
16
|
+
* 3 - Livro B Auxiliar (Registro de casamentos religiosos para fins civis)
|
|
17
|
+
* 4 - Livro C (Óbito)
|
|
18
|
+
* 5 - Livro C Auxiliar (Registro de Natimortos)
|
|
19
|
+
* 6 - Livro D (Registro de Proclamas)
|
|
20
|
+
* 7 - Livro E (Demais atos relativos ao Registro Civil ou Livro E único)
|
|
21
|
+
* 8 - Livro E (Desdobrado para registro específico das Emancipações)
|
|
22
|
+
* 9 - Livro E (Desdobrado para registro específico das Interdições)
|
|
23
|
+
* - fffff: Número do livro - ex.: 00012
|
|
24
|
+
* - ggg: Número da folha - ex.: 021
|
|
25
|
+
* - hhhhhhh: Número do Termo - ex.: 0000123
|
|
26
|
+
* - ii: Dígito Verificador DV, cujo cálculo obedece ao esquema de MÓDULO 11.
|
|
27
|
+
*
|
|
28
|
+
* Exemplo de Cálculo: 104539.01.55.2013.1.00012.021.0000123-21
|
|
29
|
+
*
|
|
30
|
+
* 1) Cálculo do primeiro DV.
|
|
31
|
+
* - Soma-se o produto dos 30 primeiros dígitos por pesos específicos:
|
|
32
|
+
* Pesos: 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
|
|
33
|
+
*
|
|
34
|
+
* 1 0 4 5 3 9 0 1 5 5 2 0 1 3 1 0 0 0 1 2 0 2 1 0 0 0 0 1 2 3
|
|
35
|
+
* x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
|
|
36
|
+
* 2 3 4 5 6 7 8 9 10 0 1 2 3 4 5 6 7 8 9 10 0 1 2 3 4 5 6 7 8 9
|
|
37
|
+
*
|
|
38
|
+
* Soma = 288
|
|
39
|
+
*
|
|
40
|
+
* - O somatório encontrado é dividido por 11.
|
|
41
|
+
* 288 ÷ 11 = 26, com resto 2.
|
|
42
|
+
* DV1 = Resto (2). Se resto for 10, DV1 será 1.
|
|
43
|
+
*
|
|
44
|
+
* 2) Cálculo do segundo DV.
|
|
45
|
+
* - Soma-se o produto dos 31 primeiros dígitos (incluindo DV1) por novos pesos.
|
|
46
|
+
* Pesos: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
|
|
47
|
+
*
|
|
48
|
+
* 1 0 4 5 3 9 0 1 5 5 2 0 1 3 1 0 0 0 1 2 0 2 1 0 0 0 0 1 2 3 2
|
|
49
|
+
* x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
|
|
50
|
+
* 1 2 3 4 5 6 7 8 9 10 0 1 2 3 4 5 6 7 8 9 10 0 1 2 3 4 5 6 7 8 9
|
|
51
|
+
*
|
|
52
|
+
* Soma = 309
|
|
53
|
+
*
|
|
54
|
+
* - O somatório encontrado é dividido por 11.
|
|
55
|
+
* 309 ÷ 11 = 28, com resto 1.
|
|
56
|
+
* DV2 = Resto (1). Se resto for 10, DV2 será 1.
|
|
57
|
+
*
|
|
58
|
+
* Links:
|
|
59
|
+
* - http://ghiorzi.org/DVnew.htm#zc
|
|
60
|
+
* - https://www.arpensp.org.br/calculo-de-matricula
|
|
61
|
+
*
|
|
62
|
+
* @param {String} value Matrícula da Certidão
|
|
63
|
+
* @returns {Boolean}
|
|
64
|
+
*/
|
|
65
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
66
|
+
exports.Certidao = exports.CertidaoServico = exports.CertidaoTipoLivro = void 0;
|
|
67
|
+
const ValidationBRError_1 = require("./_exceptions/ValidationBRError");
|
|
68
|
+
const base_1 = require("./base");
|
|
69
|
+
const utils_1 = require("./_helpers/utils");
|
|
70
|
+
var CertidaoTipoLivro;
|
|
71
|
+
(function (CertidaoTipoLivro) {
|
|
72
|
+
CertidaoTipoLivro["Nascimento"] = "1";
|
|
73
|
+
CertidaoTipoLivro["Casamento"] = "2";
|
|
74
|
+
CertidaoTipoLivro["CasamentoReligioso"] = "3";
|
|
75
|
+
CertidaoTipoLivro["Obito"] = "4";
|
|
76
|
+
CertidaoTipoLivro["Natimorto"] = "5";
|
|
77
|
+
CertidaoTipoLivro["Proclamas"] = "6";
|
|
78
|
+
CertidaoTipoLivro["Outros"] = "7";
|
|
79
|
+
})(CertidaoTipoLivro || (exports.CertidaoTipoLivro = CertidaoTipoLivro = {}));
|
|
80
|
+
var CertidaoServico;
|
|
81
|
+
(function (CertidaoServico) {
|
|
82
|
+
CertidaoServico["Notas"] = "51";
|
|
83
|
+
CertidaoServico["Protesto"] = "52";
|
|
84
|
+
CertidaoServico["RegistroImoveis"] = "53";
|
|
85
|
+
CertidaoServico["RegistroTitulosDocumentos"] = "54";
|
|
86
|
+
CertidaoServico["RegistroCivilPessoasNaturais"] = "55";
|
|
87
|
+
CertidaoServico["RegistroContratosMaritimos"] = "56";
|
|
88
|
+
CertidaoServico["RegistroDistribuicao"] = "57";
|
|
89
|
+
})(CertidaoServico || (exports.CertidaoServico = CertidaoServico = {}));
|
|
90
|
+
class Certidao extends base_1.Base {
|
|
91
|
+
constructor(_value) {
|
|
92
|
+
super(_value);
|
|
93
|
+
this._value = _value;
|
|
94
|
+
this._mask = '000000 00 00 0000 0 00000 000 0000000 00';
|
|
95
|
+
this.normalize();
|
|
96
|
+
if (!this.validate()) {
|
|
97
|
+
throw new ValidationBRError_1.InvalidChecksumException();
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
normalize() {
|
|
101
|
+
this._value = this._value.replace(/([. -])/g, '');
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Valida se a certidão atual possui o DV correto e tamanho 32
|
|
105
|
+
*/
|
|
106
|
+
validate() {
|
|
107
|
+
const certidao = (0, utils_1.clearValue)(this._value, 32, {
|
|
108
|
+
rejectEmpty: true,
|
|
109
|
+
rejectIfLonger: true,
|
|
110
|
+
rejectIfShorter: true,
|
|
111
|
+
rejectEqualSequence: false, // 32 digits can possibly have sequences, though unlikely to be ALL same.
|
|
112
|
+
});
|
|
113
|
+
return Certidao.checksum(certidao.substring(0, 30)) === certidao.substring(30, 32);
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Calcula o DV para uma sequência de 30 dígitos
|
|
117
|
+
* Algoritmo Módulo 97:
|
|
118
|
+
*/
|
|
119
|
+
static checksum(base30) {
|
|
120
|
+
if (!base30)
|
|
121
|
+
throw new ValidationBRError_1.EmptyValueException();
|
|
122
|
+
if (base30.length !== 30)
|
|
123
|
+
throw new ValidationBRError_1.InvalidFormatException();
|
|
124
|
+
// Pesos específicos conforme solicitação:
|
|
125
|
+
// DV1: 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
|
|
126
|
+
const weights1 = [
|
|
127
|
+
2, 3, 4, 5, 6, 7, 8, 9, 10, 0,
|
|
128
|
+
1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
|
|
129
|
+
0, 1, 2, 3, 4, 5, 6, 7, 8, 9
|
|
130
|
+
];
|
|
131
|
+
let sum1 = 0;
|
|
132
|
+
for (let i = 0; i < 30; i++) {
|
|
133
|
+
sum1 += parseInt(base30[i], 10) * weights1[i];
|
|
134
|
+
}
|
|
135
|
+
let dv1 = sum1 % 11;
|
|
136
|
+
if (dv1 === 10)
|
|
137
|
+
dv1 = 1;
|
|
138
|
+
// DV2: Inclui o DV1 no final
|
|
139
|
+
// Pesos: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
|
|
140
|
+
const base31 = base30 + dv1.toString();
|
|
141
|
+
const weights2 = [
|
|
142
|
+
1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
|
|
143
|
+
0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
|
|
144
|
+
10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
|
|
145
|
+
];
|
|
146
|
+
let sum2 = 0;
|
|
147
|
+
for (let i = 0; i < 31; i++) {
|
|
148
|
+
sum2 += parseInt(base31[i], 10) * weights2[i];
|
|
149
|
+
}
|
|
150
|
+
let dv2 = sum2 % 11;
|
|
151
|
+
if (dv2 === 10)
|
|
152
|
+
dv2 = 1;
|
|
153
|
+
return `${dv1}${dv2}`;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Gera uma instância de Certidao válida com dados aleatórios ou específicos
|
|
157
|
+
*/
|
|
158
|
+
static fake(options = {}) {
|
|
159
|
+
const pad = (n, size) => n.toString().padStart(size, '0');
|
|
160
|
+
const meupa = (0, utils_1.clearValue)(0, 3, { fillZerosAtLeft: true });
|
|
161
|
+
const cns = options.cns ? pad(options.cns, 6) : pad(Math.floor(Math.random() * 999999), 6);
|
|
162
|
+
const acervo = options.acervo ? pad(options.acervo, 2) : '01';
|
|
163
|
+
const servico = options.servico || CertidaoServico.RegistroCivilPessoasNaturais;
|
|
164
|
+
const ano = options.ano || new Date().getFullYear();
|
|
165
|
+
const tipo = options.tipoLivro || CertidaoTipoLivro.Nascimento;
|
|
166
|
+
const livro = options.livro !== undefined ? pad(options.livro, 5) : pad(Math.floor(Math.random() * 99999), 5);
|
|
167
|
+
const folha = options.folha !== undefined ? pad(options.folha, 3) : pad(Math.floor(Math.random() * 999), 3);
|
|
168
|
+
const termo = options.termo !== undefined ? pad(options.termo, 7) : pad(Math.floor(Math.random() * 9999999), 7);
|
|
169
|
+
const base30 = `${cns}${acervo}${servico}${ano}${tipo}${livro}${folha}${termo}`;
|
|
170
|
+
const dv = Certidao.checksum(base30);
|
|
171
|
+
return new Certidao(base30 + dv);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
exports.Certidao = Certidao;
|
|
@@ -61,9 +61,9 @@ const random_1 = require("./_helpers/random");
|
|
|
61
61
|
const base_1 = require("./base");
|
|
62
62
|
const utils_1 = require("./_helpers/utils");
|
|
63
63
|
class CNH extends base_1.Base {
|
|
64
|
-
_mask = '000000000-00';
|
|
65
64
|
constructor(value) {
|
|
66
65
|
super(value);
|
|
66
|
+
this._mask = '000000000-00';
|
|
67
67
|
this.normalize();
|
|
68
68
|
if (!this.validate()) {
|
|
69
69
|
throw new ValidationBRError_1.InvalidChecksumException();
|
|
@@ -84,11 +84,10 @@ const random_1 = require("./_helpers/random");
|
|
|
84
84
|
const base_1 = require("./base");
|
|
85
85
|
const utils_1 = require("./_helpers/utils");
|
|
86
86
|
class CNPJ extends base_1.Base {
|
|
87
|
-
_value;
|
|
88
|
-
_mask = '00.000.000/0000-00';
|
|
89
87
|
constructor(_value) {
|
|
90
88
|
super(_value);
|
|
91
89
|
this._value = _value;
|
|
90
|
+
this._mask = '00.000.000/0000-00';
|
|
92
91
|
this.normalize();
|
|
93
92
|
if (!this.validate()) {
|
|
94
93
|
throw new ValidationBRError_1.InvalidChecksumException();
|
|
@@ -142,7 +141,8 @@ class CNPJ extends base_1.Base {
|
|
|
142
141
|
*
|
|
143
142
|
*/
|
|
144
143
|
static fake(options = {}) {
|
|
145
|
-
|
|
144
|
+
var _a;
|
|
145
|
+
const num = random_1.Random.number(8, true, (_a = options === null || options === void 0 ? void 0 : options.alphanumeric) !== null && _a !== void 0 ? _a : false);
|
|
146
146
|
const fullNumber = `${num}0001`;
|
|
147
147
|
return new CNPJ(`${fullNumber}${CNPJ.checksum(fullNumber)}`);
|
|
148
148
|
}
|
|
@@ -65,11 +65,10 @@ const random_1 = require("./_helpers/random");
|
|
|
65
65
|
const base_1 = require("./base");
|
|
66
66
|
const utils_1 = require("./_helpers/utils");
|
|
67
67
|
class CPF extends base_1.Base {
|
|
68
|
-
_value;
|
|
69
|
-
_mask = '000.000.000-00';
|
|
70
68
|
constructor(_value) {
|
|
71
69
|
super(_value);
|
|
72
70
|
this._value = _value;
|
|
71
|
+
this._mask = '000.000.000-00';
|
|
73
72
|
this.normalize();
|
|
74
73
|
if (!this.validate()) {
|
|
75
74
|
throw new ValidationBRError_1.InvalidChecksumException();
|
|
@@ -8,11 +8,10 @@ const ValidationBRError_1 = __importDefault(require("./_exceptions/ValidationBRE
|
|
|
8
8
|
const random_1 = require("./_helpers/random");
|
|
9
9
|
const base_1 = require("./base");
|
|
10
10
|
class Email extends base_1.Base {
|
|
11
|
-
_value;
|
|
12
|
-
_mask = null;
|
|
13
11
|
constructor(_value) {
|
|
14
12
|
super(_value);
|
|
15
13
|
this._value = _value;
|
|
14
|
+
this._mask = null;
|
|
16
15
|
this.normalize();
|
|
17
16
|
if (!this.validate()) {
|
|
18
17
|
throw new ValidationBRError_1.default('Email inválido');
|
|
@@ -118,17 +118,10 @@ const random_1 = require("./_helpers/random");
|
|
|
118
118
|
const base_1 = require("./base");
|
|
119
119
|
const utils_1 = require("./_helpers/utils");
|
|
120
120
|
class JudicialProcess extends base_1.Base {
|
|
121
|
-
_value;
|
|
122
|
-
_court;
|
|
123
|
-
_subCourt;
|
|
124
|
-
_origin;
|
|
125
|
-
_year;
|
|
126
|
-
_processNumber;
|
|
127
|
-
_checksum;
|
|
128
|
-
_mask = '0000000-00.0000.0.00.0000';
|
|
129
121
|
constructor(_value) {
|
|
130
122
|
super(_value);
|
|
131
123
|
this._value = _value;
|
|
124
|
+
this._mask = '0000000-00.0000.0.00.0000';
|
|
132
125
|
this.normalize();
|
|
133
126
|
if (!this.validate()) {
|
|
134
127
|
throw new ValidationBRError_1.InvalidChecksumException();
|
|
@@ -67,11 +67,10 @@ const random_1 = require("./_helpers/random");
|
|
|
67
67
|
const base_1 = require("./base");
|
|
68
68
|
const utils_1 = require("./_helpers/utils");
|
|
69
69
|
class NUP17 extends base_1.Base {
|
|
70
|
-
_value;
|
|
71
|
-
_mask = '00000.000000/0000-00';
|
|
72
70
|
constructor(_value) {
|
|
73
71
|
super(_value);
|
|
74
72
|
this._value = _value;
|
|
73
|
+
this._mask = '00000.000000/0000-00';
|
|
75
74
|
this.normalize();
|
|
76
75
|
if (!this.validate()) {
|
|
77
76
|
throw new ValidationBRError_1.InvalidChecksumException();
|