validation-br 2.0.0 → 2.0.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/dist/cjs/phone.d.ts +7 -1
- package/dist/cjs/phone.js +11 -3
- package/dist/esm/phone.d.ts +7 -1
- package/dist/esm/phone.js +11 -3
- package/package.json +8 -3
- package/readme.md +1 -2
package/dist/cjs/phone.d.ts
CHANGED
|
@@ -15,8 +15,14 @@
|
|
|
15
15
|
* new Phone('8440043214').validate()
|
|
16
16
|
* // -> true
|
|
17
17
|
*
|
|
18
|
+
* new Phone('(21) 2345-6789').validate()
|
|
19
|
+
* // -> true (fixos iniciam de 2 a 6)
|
|
20
|
+
*
|
|
21
|
+
* new Phone('(11) 7555-1234').validate()
|
|
22
|
+
* // -> throws error (fixo iniciado em 7 é reserva técnica)
|
|
23
|
+
*
|
|
18
24
|
* new Phone('(23) 4004-3214').validate()
|
|
19
|
-
* // -> throws error
|
|
25
|
+
* // -> throws error (DDD 23 não existe)
|
|
20
26
|
*
|
|
21
27
|
* new Phone('(13) 6 6321-875').validate()
|
|
22
28
|
* // -> throws error
|
package/dist/cjs/phone.js
CHANGED
|
@@ -16,8 +16,14 @@
|
|
|
16
16
|
* new Phone('8440043214').validate()
|
|
17
17
|
* // -> true
|
|
18
18
|
*
|
|
19
|
+
* new Phone('(21) 2345-6789').validate()
|
|
20
|
+
* // -> true (fixos iniciam de 2 a 6)
|
|
21
|
+
*
|
|
22
|
+
* new Phone('(11) 7555-1234').validate()
|
|
23
|
+
* // -> throws error (fixo iniciado em 7 é reserva técnica)
|
|
24
|
+
*
|
|
19
25
|
* new Phone('(23) 4004-3214').validate()
|
|
20
|
-
* // -> throws error
|
|
26
|
+
* // -> throws error (DDD 23 não existe)
|
|
21
27
|
*
|
|
22
28
|
* new Phone('(13) 6 6321-875').validate()
|
|
23
29
|
* // -> throws error
|
|
@@ -80,7 +86,9 @@ class Phone extends base_1.Base {
|
|
|
80
86
|
super(_value);
|
|
81
87
|
this._value = _value;
|
|
82
88
|
this._mask = null;
|
|
83
|
-
|
|
89
|
+
// Fixos (STFC/SCM): 8 dígitos iniciados em 2 a 6 — Resolução Anatel nº 749/2022, art. 11, I, "a".
|
|
90
|
+
// Celulares (SMP): 9 dígitos iniciados em 9.
|
|
91
|
+
this._regex = /^(?<ddi>\+55)?(?<ddd>\d{2})(?<phone>9\d{8}|[2-6]\d{7})$/;
|
|
84
92
|
this._ddd = '';
|
|
85
93
|
this._phone = '';
|
|
86
94
|
this._ddi = '';
|
|
@@ -169,7 +177,7 @@ class Phone extends base_1.Base {
|
|
|
169
177
|
const ddd = (_a = config === null || config === void 0 ? void 0 : config.ddd) !== null && _a !== void 0 ? _a : random_1.Random.fromArray(Phone._ddds);
|
|
170
178
|
// Prefixos
|
|
171
179
|
const mobilePrefixes = ['99', '98', '97'];
|
|
172
|
-
const landLinePrefixes = ['3', '4'];
|
|
180
|
+
const landLinePrefixes = ['2', '3', '4', '5', '6'];
|
|
173
181
|
// Se não informar se quer mobile ou fixo, gere o tipo
|
|
174
182
|
let firstPart;
|
|
175
183
|
if (config === null || config === void 0 ? void 0 : config.isMobile)
|
package/dist/esm/phone.d.ts
CHANGED
|
@@ -15,8 +15,14 @@
|
|
|
15
15
|
* new Phone('8440043214').validate()
|
|
16
16
|
* // -> true
|
|
17
17
|
*
|
|
18
|
+
* new Phone('(21) 2345-6789').validate()
|
|
19
|
+
* // -> true (fixos iniciam de 2 a 6)
|
|
20
|
+
*
|
|
21
|
+
* new Phone('(11) 7555-1234').validate()
|
|
22
|
+
* // -> throws error (fixo iniciado em 7 é reserva técnica)
|
|
23
|
+
*
|
|
18
24
|
* new Phone('(23) 4004-3214').validate()
|
|
19
|
-
* // -> throws error
|
|
25
|
+
* // -> throws error (DDD 23 não existe)
|
|
20
26
|
*
|
|
21
27
|
* new Phone('(13) 6 6321-875').validate()
|
|
22
28
|
* // -> throws error
|
package/dist/esm/phone.js
CHANGED
|
@@ -15,8 +15,14 @@
|
|
|
15
15
|
* new Phone('8440043214').validate()
|
|
16
16
|
* // -> true
|
|
17
17
|
*
|
|
18
|
+
* new Phone('(21) 2345-6789').validate()
|
|
19
|
+
* // -> true (fixos iniciam de 2 a 6)
|
|
20
|
+
*
|
|
21
|
+
* new Phone('(11) 7555-1234').validate()
|
|
22
|
+
* // -> throws error (fixo iniciado em 7 é reserva técnica)
|
|
23
|
+
*
|
|
18
24
|
* new Phone('(23) 4004-3214').validate()
|
|
19
|
-
* // -> throws error
|
|
25
|
+
* // -> throws error (DDD 23 não existe)
|
|
20
26
|
*
|
|
21
27
|
* new Phone('(13) 6 6321-875').validate()
|
|
22
28
|
* // -> throws error
|
|
@@ -44,7 +50,9 @@ export class Phone extends Base {
|
|
|
44
50
|
super(_value);
|
|
45
51
|
this._value = _value;
|
|
46
52
|
this._mask = null;
|
|
47
|
-
|
|
53
|
+
// Fixos (STFC/SCM): 8 dígitos iniciados em 2 a 6 — Resolução Anatel nº 749/2022, art. 11, I, "a".
|
|
54
|
+
// Celulares (SMP): 9 dígitos iniciados em 9.
|
|
55
|
+
this._regex = /^(?<ddi>\+55)?(?<ddd>\d{2})(?<phone>9\d{8}|[2-6]\d{7})$/;
|
|
48
56
|
this._ddd = '';
|
|
49
57
|
this._phone = '';
|
|
50
58
|
this._ddi = '';
|
|
@@ -133,7 +141,7 @@ export class Phone extends Base {
|
|
|
133
141
|
const ddd = (_a = config === null || config === void 0 ? void 0 : config.ddd) !== null && _a !== void 0 ? _a : Random.fromArray(Phone._ddds);
|
|
134
142
|
// Prefixos
|
|
135
143
|
const mobilePrefixes = ['99', '98', '97'];
|
|
136
|
-
const landLinePrefixes = ['3', '4'];
|
|
144
|
+
const landLinePrefixes = ['2', '3', '4', '5', '6'];
|
|
137
145
|
// Se não informar se quer mobile ou fixo, gere o tipo
|
|
138
146
|
let firstPart;
|
|
139
147
|
if (config === null || config === void 0 ? void 0 : config.isMobile)
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "validation-br",
|
|
3
3
|
"description": "Brazilian personal documents validation - cpf, cnpj, titulo, pis/pasep, cnh, renavam, processos judiciais, protocolo federal, código de rastreamento dos correios",
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.1",
|
|
5
5
|
"author": "Cláudio Medeiros <klawdyo@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"sideEffects": false,
|
|
@@ -73,13 +73,18 @@
|
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"@eslint/js": "^10.0.1",
|
|
75
75
|
"@types/node": "^22.20.2",
|
|
76
|
-
"@vitest/coverage-v8": "^4.1.
|
|
76
|
+
"@vitest/coverage-v8": "^4.1.12",
|
|
77
77
|
"eslint": "^10.10.0",
|
|
78
78
|
"globals": "^17.12.0",
|
|
79
79
|
"ts-node": "^9.0.0",
|
|
80
80
|
"typescript": "^5.6.2",
|
|
81
81
|
"typescript-eslint": "^8.70.0",
|
|
82
|
-
"vitest": "^4.1.
|
|
82
|
+
"vitest": "^4.1.12"
|
|
83
|
+
},
|
|
84
|
+
"overrides": {
|
|
85
|
+
"@typescript-eslint/typescript-estree": {
|
|
86
|
+
"minimatch": "^11.0.1"
|
|
87
|
+
}
|
|
83
88
|
},
|
|
84
89
|
"repository": {
|
|
85
90
|
"url": "https://github.com/klawdyo/validation-br"
|
package/readme.md
CHANGED
|
@@ -854,6 +854,7 @@ Github actions executados nas versões 18, 20, 22 e 24 do Node, buildando e vali
|
|
|
854
854
|
# Changelog
|
|
855
855
|
|
|
856
856
|
- **12/09/2026**:
|
|
857
|
+
- Adicionadas as validações `PixKey` (chave Pix) e `PixCopyPaste` (Pix Copia e Cola), com seção própria no README (`isPixKey`, `isPixCopyPaste`)
|
|
857
858
|
- Adicionados os atalhos `isBoleto`, `isCAEPF`, `isCEP`, `isCertidao`, `isCBISinter` e `isUF`, que faltavam para essas classes
|
|
858
859
|
- Adicionada a pasta [examples](examples), com um projeto funcional testando a integração do validation-br com Joi, Yup, Class-Validator, Indicative e Vuelidate
|
|
859
860
|
- Breaking Changes reescrito: explica em mais detalhes por que `dv()` virou `checksum()` (deixou de fazer suposições sobre o formato de entrada), reforça a imutabilidade das classes (value objects) e remove itens que não eram breaking changes de fato (UUID e CNPJ alfanumérico não existiam como funções na 1.x)
|
|
@@ -875,8 +876,6 @@ Github actions executados nas versões 18, 20, 22 e 24 do Node, buildando e vali
|
|
|
875
876
|
- Adicionadas as funções `isEmail` e `isUUID`
|
|
876
877
|
- **02/10/2024**:
|
|
877
878
|
- Adicionadas as classes `CEP` (com busca de UF pelo CEP) e `UF`
|
|
878
|
-
- **30/09/2024**:
|
|
879
|
-
- Adicionadas as funções `isPixKey` e `isPixCopyPaste`
|
|
880
879
|
- **11/09/2024**:
|
|
881
880
|
- Adicionadas as funções `isCarPlate` e `isPhone`
|
|
882
881
|
- **16/12/2023**:
|