@br-validators/core 0.12.0-alpha.2 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +210 -131
- package/dist/batch.d.ts +28 -0
- package/dist/batch.js +29 -0
- package/dist/batch.js.map +1 -0
- package/dist/boleto.d.ts +58 -5
- package/dist/boleto.js +6 -3
- package/dist/brcode.d.ts +15 -3
- package/dist/brcode.js +8 -8
- package/dist/cartao-credito.d.ts +2 -2
- package/dist/cartao-credito.js +3 -3
- package/dist/cep.d.ts +2 -2
- package/dist/cep.js +4 -4
- package/dist/{chunk-WPL47PWJ.js → chunk-3LMDBXU6.js} +3 -3
- package/dist/{chunk-WPL47PWJ.js.map → chunk-3LMDBXU6.js.map} +1 -1
- package/dist/chunk-4J5IMD7B.js +3 -0
- package/dist/chunk-4J5IMD7B.js.map +1 -0
- package/dist/{chunk-BFZPCEYB.js → chunk-54UWHK5L.js} +3 -3
- package/dist/{chunk-BFZPCEYB.js.map → chunk-54UWHK5L.js.map} +1 -1
- package/dist/{chunk-F6PTZY4O.js → chunk-63G7QO73.js} +3 -3
- package/dist/{chunk-F6PTZY4O.js.map → chunk-63G7QO73.js.map} +1 -1
- package/dist/{chunk-3QP6R46N.js → chunk-665E36SC.js} +4 -4
- package/dist/{chunk-3QP6R46N.js.map → chunk-665E36SC.js.map} +1 -1
- package/dist/{chunk-AK5GVYQ5.js → chunk-ANWQBKGN.js} +3 -3
- package/dist/{chunk-AK5GVYQ5.js.map → chunk-ANWQBKGN.js.map} +1 -1
- package/dist/{chunk-D36RM7OD.js → chunk-AO6UTQ4A.js} +3 -3
- package/dist/{chunk-D36RM7OD.js.map → chunk-AO6UTQ4A.js.map} +1 -1
- package/dist/chunk-AU6TW3GH.js +136 -0
- package/dist/chunk-AU6TW3GH.js.map +1 -0
- package/dist/{chunk-XW5G2RAL.js → chunk-B6A7VF4R.js} +3 -3
- package/dist/{chunk-XW5G2RAL.js.map → chunk-B6A7VF4R.js.map} +1 -1
- package/dist/chunk-BFMRXXFE.js +99 -0
- package/dist/chunk-BFMRXXFE.js.map +1 -0
- package/dist/{chunk-Y6IW2LMW.js → chunk-CDNOUZEI.js} +3 -3
- package/dist/{chunk-Y6IW2LMW.js.map → chunk-CDNOUZEI.js.map} +1 -1
- package/dist/{chunk-XUO7FV6Z.js → chunk-CSRBRKXY.js} +3 -3
- package/dist/{chunk-XUO7FV6Z.js.map → chunk-CSRBRKXY.js.map} +1 -1
- package/dist/{chunk-DJUANFIK.js → chunk-CSVGWTCG.js} +3 -3
- package/dist/{chunk-DJUANFIK.js.map → chunk-CSVGWTCG.js.map} +1 -1
- package/dist/{chunk-5UL3M7IU.js → chunk-DAR6VOMT.js} +3 -3
- package/dist/{chunk-5UL3M7IU.js.map → chunk-DAR6VOMT.js.map} +1 -1
- package/dist/chunk-E2EFGMWA.js +200 -0
- package/dist/chunk-E2EFGMWA.js.map +1 -0
- package/dist/{chunk-KSLDM5AD.js → chunk-EVULAGR5.js} +3 -3
- package/dist/{chunk-KSLDM5AD.js.map → chunk-EVULAGR5.js.map} +1 -1
- package/dist/{chunk-YXELVV37.js → chunk-FBARVLLP.js} +4 -4
- package/dist/{chunk-YXELVV37.js.map → chunk-FBARVLLP.js.map} +1 -1
- package/dist/chunk-FKFRB3RJ.js +135 -0
- package/dist/chunk-FKFRB3RJ.js.map +1 -0
- package/dist/chunk-G6OBZRZM.js +131 -0
- package/dist/chunk-G6OBZRZM.js.map +1 -0
- package/dist/{chunk-MK7OJUF5.js → chunk-H3MLGGFI.js} +8 -8
- package/dist/{chunk-MK7OJUF5.js.map → chunk-H3MLGGFI.js.map} +1 -1
- package/dist/chunk-HUIMOB5E.js +41 -0
- package/dist/chunk-HUIMOB5E.js.map +1 -0
- package/dist/{chunk-WLE2ENQA.js → chunk-I66ZRSEN.js} +3 -3
- package/dist/{chunk-WLE2ENQA.js.map → chunk-I66ZRSEN.js.map} +1 -1
- package/dist/{chunk-Q7B5VOPW.js → chunk-I7DM47IR.js} +243 -37
- package/dist/chunk-I7DM47IR.js.map +1 -0
- package/dist/{chunk-GRDUTHNX.js → chunk-IYOPXJLY.js} +3 -3
- package/dist/{chunk-GRDUTHNX.js.map → chunk-IYOPXJLY.js.map} +1 -1
- package/dist/{chunk-4Y2FBO57.js → chunk-JKDU7QYP.js} +3 -3
- package/dist/{chunk-4Y2FBO57.js.map → chunk-JKDU7QYP.js.map} +1 -1
- package/dist/{chunk-KH7DWOUA.js → chunk-JLCQ7MGC.js} +3 -3
- package/dist/{chunk-KH7DWOUA.js.map → chunk-JLCQ7MGC.js.map} +1 -1
- package/dist/chunk-KBNWI6GE.js +3 -0
- package/dist/chunk-KBNWI6GE.js.map +1 -0
- package/dist/chunk-KLPONHBL.js +3 -0
- package/dist/chunk-KLPONHBL.js.map +1 -0
- package/dist/{chunk-CDGRHI7W.js → chunk-LAEUXOF6.js} +3 -3
- package/dist/{chunk-CDGRHI7W.js.map → chunk-LAEUXOF6.js.map} +1 -1
- package/dist/{chunk-ZAUZRIOU.js → chunk-MESOO5GZ.js} +3 -3
- package/dist/{chunk-ZAUZRIOU.js.map → chunk-MESOO5GZ.js.map} +1 -1
- package/dist/chunk-N2WVO3GF.js +128 -0
- package/dist/chunk-N2WVO3GF.js.map +1 -0
- package/dist/chunk-N6N5ATLY.js +93 -0
- package/dist/chunk-N6N5ATLY.js.map +1 -0
- package/dist/chunk-N6RQICAP.js +220 -0
- package/dist/chunk-N6RQICAP.js.map +1 -0
- package/dist/{chunk-MSLJF2FM.js → chunk-NUQSMT4Y.js} +2 -2
- package/dist/chunk-NUQSMT4Y.js.map +1 -0
- package/dist/{chunk-KQDLIGSG.js → chunk-P2KNN6ZR.js} +3 -3
- package/dist/{chunk-KQDLIGSG.js.map → chunk-P2KNN6ZR.js.map} +1 -1
- package/dist/{chunk-G2Y63PIF.js → chunk-PD7ZTWMM.js} +3 -3
- package/dist/{chunk-G2Y63PIF.js.map → chunk-PD7ZTWMM.js.map} +1 -1
- package/dist/{chunk-LYBFUKHR.js → chunk-RMTHCPIV.js} +4 -4
- package/dist/{chunk-LYBFUKHR.js.map → chunk-RMTHCPIV.js.map} +1 -1
- package/dist/chunk-SAZA3V2U.js +100 -0
- package/dist/chunk-SAZA3V2U.js.map +1 -0
- package/dist/{chunk-2JJS46FM.js → chunk-TE6NSONR.js} +3 -3
- package/dist/{chunk-2JJS46FM.js.map → chunk-TE6NSONR.js.map} +1 -1
- package/dist/{chunk-NHLLC6WH.js → chunk-TJCE4TVX.js} +4 -4
- package/dist/{chunk-NHLLC6WH.js.map → chunk-TJCE4TVX.js.map} +1 -1
- package/dist/{chunk-WCQUQ2WX.js → chunk-V7UJ55KW.js} +47 -5
- package/dist/chunk-V7UJ55KW.js.map +1 -0
- package/dist/{chunk-IQGRFAQV.js → chunk-VSW3NBJQ.js} +3 -3
- package/dist/{chunk-IQGRFAQV.js.map → chunk-VSW3NBJQ.js.map} +1 -1
- package/dist/{chunk-6QJFMOIX.js → chunk-VWVQWN2G.js} +3 -3
- package/dist/{chunk-6QJFMOIX.js.map → chunk-VWVQWN2G.js.map} +1 -1
- package/dist/{chunk-JZNTCZMV.js → chunk-WC6YYFWP.js} +34 -18
- package/dist/chunk-WC6YYFWP.js.map +1 -0
- package/dist/{chunk-FXLVNCG3.js → chunk-XWHGXSQV.js} +3 -3
- package/dist/{chunk-FXLVNCG3.js.map → chunk-XWHGXSQV.js.map} +1 -1
- package/dist/{chunk-G32U6YQ5.js → chunk-YD5MPZWY.js} +3 -3
- package/dist/{chunk-G32U6YQ5.js.map → chunk-YD5MPZWY.js.map} +1 -1
- package/dist/{chunk-US4OLTJ2.js → chunk-YNVMVDFN.js} +3 -3
- package/dist/{chunk-US4OLTJ2.js.map → chunk-YNVMVDFN.js.map} +1 -1
- package/dist/cnh.d.ts +2 -2
- package/dist/cnh.js +4 -4
- package/dist/cnpj.d.ts +2 -2
- package/dist/cnpj.js +5 -5
- package/dist/compare.d.ts +16 -0
- package/dist/compare.js +32 -0
- package/dist/compare.js.map +1 -0
- package/dist/cpf.d.ts +2 -2
- package/dist/cpf.js +4 -4
- package/dist/detect.d.ts +1 -1
- package/dist/detect.js +22 -20
- package/dist/diff.d.ts +16 -0
- package/dist/diff.js +32 -0
- package/dist/diff.js.map +1 -0
- package/dist/generate.d.ts +24 -3
- package/dist/generate.js +36 -27
- package/dist/{index-CZLo9YOT.d.ts → index-BEJFgDXj.d.ts} +1 -1
- package/dist/index.d.ts +13 -8
- package/dist/index.js +60 -49
- package/dist/index.js.map +1 -1
- package/dist/{inscricao-estadual-produtor-rural-CfWUaggb.d.ts → inscricao-estadual-produtor-rural-BXFVQscj.d.ts} +1 -1
- package/dist/inscricao-estadual-produtor-rural.d.ts +2 -2
- package/dist/inscricao-estadual-produtor-rural.js +3 -3
- package/dist/inscricao-estadual.d.ts +3 -3
- package/dist/inscricao-estadual.js +4 -4
- package/dist/mask.d.ts +13 -0
- package/dist/mask.js +40 -0
- package/dist/mask.js.map +1 -0
- package/dist/nfe-chave.d.ts +2 -2
- package/dist/nfe-chave.js +4 -3
- package/dist/pis-pasep.d.ts +2 -2
- package/dist/pis-pasep.js +3 -3
- package/dist/{pix-ddldLlb7.d.ts → pix-B4habHLG.d.ts} +1 -1
- package/dist/pix.d.ts +2 -2
- package/dist/pix.js +9 -8
- package/dist/placa.d.ts +2 -2
- package/dist/placa.js +4 -4
- package/dist/renavam.d.ts +2 -2
- package/dist/renavam.js +4 -4
- package/dist/sanitize.d.ts +2 -2
- package/dist/sanitize.js +20 -17
- package/dist/telefone.d.ts +2 -2
- package/dist/telefone.js +3 -3
- package/dist/titulo-eleitor.d.ts +2 -2
- package/dist/titulo-eleitor.js +4 -4
- package/dist/types-MXifBcV5.d.ts +10 -0
- package/dist/{validation-result-BhQE-1_O.d.ts → validation-result-BaI2Xder.d.ts} +24 -5
- package/package.json +23 -3
- package/dist/chunk-4W4OKLSZ.js +0 -366
- package/dist/chunk-4W4OKLSZ.js.map +0 -1
- package/dist/chunk-CSZCIOGA.js +0 -187
- package/dist/chunk-CSZCIOGA.js.map +0 -1
- package/dist/chunk-JZNTCZMV.js.map +0 -1
- package/dist/chunk-MSLJF2FM.js.map +0 -1
- package/dist/chunk-Q7B5VOPW.js.map +0 -1
- package/dist/chunk-WCQUQ2WX.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,110 +1,63 @@
|
|
|
1
1
|
# @br-validators/core
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> **The** Brazilian document validation library for TypeScript.
|
|
4
|
+
> Validate, format, and generate CPF, CNPJ (including the new alphanumeric format), NF-e, BR Code PIX, boleto, IE (all 27 states), and 15+ more — zero dependencies, fully typed, never throws.
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
> The unscoped name `br-validators` on npm is a **different package**. Use **`@br-validators/core`**.
|
|
10
|
-
|
|
11
|
-
---
|
|
12
|
-
|
|
13
|
-
## Install
|
|
6
|
+
[](https://www.npmjs.com/package/@br-validators/core)
|
|
7
|
+
[](https://github.com/AlexandreZanata/br-validators/blob/main/LICENSE)
|
|
8
|
+
[]()
|
|
14
9
|
|
|
15
10
|
```bash
|
|
16
11
|
npm install @br-validators/core
|
|
17
12
|
```
|
|
18
13
|
|
|
19
|
-
|
|
14
|
+
**Try it now → [doc-raiz-playground.vercel.app](https://doc-raiz-playground.vercel.app)**
|
|
15
|
+
**CLI → `npm install -g @br-validators/cli`**
|
|
20
16
|
|
|
21
|
-
|
|
17
|
+
> ⚠️ The unscoped `br-validators` on npm is a different package. Use **`@br-validators/core`**.
|
|
22
18
|
|
|
23
|
-
|
|
19
|
+
---
|
|
24
20
|
|
|
25
|
-
|
|
21
|
+
## Why this library
|
|
26
22
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
| **`sanitize()`** | `@br-validators/core/sanitize` | ETL fixes → validate (returns `fixes[]`) |
|
|
31
|
-
| **`generate()`** | `@br-validators/core/generate` | Synthetic **test fixtures** only (`seed` for reproducibility) |
|
|
23
|
+
Every Brazilian SaaS eventually reinvents CPF validation — usually wrong.
|
|
24
|
+
`@br-validators/core` implements each algorithm from its **official primary source**
|
|
25
|
+
(Receita Federal, Bacen, CONTRAN, TSE, SEFAZ, FEBRABAN, Anatel) so you don't have to.
|
|
32
26
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
27
|
+
- ✅ **CNPJ alfanumérico** — new RFB format (effective July 2026), ready now
|
|
28
|
+
- ✅ **18+ document types** — CPF, CNPJ, CEP, NF-e chave, BR Code PIX, boleto (cobrança + arrecadação), CNH, RENAVAM, placa, PIS/PASEP, PIX key, cartão de crédito, IE (27 UFs), IE produtor rural, título de eleitor, telefone, + platform APIs above
|
|
29
|
+
- ✅ **Zero runtime dependencies** — pure TypeScript logic, no HTTP calls
|
|
30
|
+
- ✅ **Never throws** — every function returns `{ ok: true, value } | { ok: false, message, code }`
|
|
31
|
+
- ✅ **Tree-shakeable** — subpath imports per document type
|
|
32
|
+
- ✅ **ESM only**, Node ≥ 18, works in browser, Bun, Deno
|
|
36
33
|
|
|
37
|
-
|
|
38
|
-
detect('123.456.789-09');
|
|
39
|
-
// → { type: 'cpf', ok: true, value: '12345678909', format: 'numeric' }
|
|
34
|
+
---
|
|
40
35
|
|
|
41
|
-
|
|
42
|
-
// → { type: 'inscricao-estadual', ok: true, ... }
|
|
36
|
+
## Quick start
|
|
43
37
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
// → { ok: true, value: '12345678909', fixes: ['trimmed', 'removed_non_digits'] }
|
|
38
|
+
```typescript
|
|
39
|
+
import { validateCpf, formatCpf } from '@br-validators/core';
|
|
47
40
|
|
|
48
|
-
|
|
49
|
-
//
|
|
41
|
+
validateCpf('123.456.789-09');
|
|
42
|
+
// { ok: true, value: '12345678909' }
|
|
50
43
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
validateCpf(cpf).ok; // true
|
|
44
|
+
formatCpf('12345678909');
|
|
45
|
+
// { ok: true, formatted: '123.456.789-09' }
|
|
54
46
|
|
|
55
|
-
|
|
56
|
-
|
|
47
|
+
validateCpf('111.111.111-11');
|
|
48
|
+
// { ok: false, message: 'CPF with all identical digits is invalid', code: 'KNOWN_INVALID_PATTERN' }
|
|
57
49
|
```
|
|
58
50
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
**Generate policy:** 9 types — CPF, CNPJ, CEP, placa, PIS, RENAVAM, CNH, telefone, cartão. Excludes boleto, NF-e chave, IE, BR Code, PIX.
|
|
62
|
-
|
|
63
|
-
---
|
|
64
|
-
|
|
65
|
-
## Per-type validators
|
|
66
|
-
|
|
67
|
-
Every module exposes `validate*`, `format*`, `strip*` (where applicable). All return `ValidationResult` — **never throw** on invalid input.
|
|
68
|
-
|
|
69
|
-
| Subpath | Key functions | Golden vector |
|
|
70
|
-
|---------|---------------|---------------|
|
|
71
|
-
| `./cnpj` | `validateCnpj`, `formatCnpj`, `stripCnpj` | `12ABC34501DE35` (alphanumeric) |
|
|
72
|
-
| `./cpf` | `validateCpf`, `formatCpf`, `stripCpf` | `12345678909` |
|
|
73
|
-
| `./cep` | `validateCep`, `formatCep`, `stripCep` | `01310100` |
|
|
74
|
-
| `./telefone` | `validateTelefone`, `formatTelefone`, `stripTelefone` | `11999999999` (celular) |
|
|
75
|
-
| `./cnh` | `validateCnh`, `formatCnh`, `stripCnh` | `62472927637` (11 digits, no CPF mask) |
|
|
76
|
-
| `./renavam` | `validateRenavam`, `formatRenavam`, `stripRenavam` | `63977791104` |
|
|
77
|
-
| `./titulo-eleitor` | `validateTituloEleitor`, `formatTituloEleitor`, `stripTituloEleitor` | `004356870906` |
|
|
78
|
-
| `./nfe-chave` | `validateNfeChave`, `parseNfeChave`, `formatNfeChave` | `52060433009911002506550120000007800267301615` |
|
|
79
|
-
| `./brcode` | `validateBrCode`, `parseBrCode` | EMV PIX payload (CRC16) |
|
|
80
|
-
| `./placa` | `validatePlaca`, `formatPlaca`, `convertPlacaToMercosul` | `ABC1D23` (Mercosul), `ABC1234` (legacy) |
|
|
81
|
-
| `./pis-pasep` | `validatePisPasep`, `formatPisPasep`, `stripPisPasep` | `10027230888` |
|
|
82
|
-
| `./pix` | `validatePixKey`, `formatPixKey`, `detectPixKeyType` | `pix@bcb.gov.br` |
|
|
83
|
-
| `./boleto` | `validateBoleto`, `formatBoleto`, `convertLinhaToCodigoBarras` | Situação 1 + 2 (FEBRABAN) |
|
|
84
|
-
| `./cartao-credito` | `validateCartaoCredito`, `passesLuhn`, `detectCardBrand` | `4111111111111111` |
|
|
85
|
-
| `./inscricao-estadual` | `validateInscricaoEstadual`, `formatInscricaoEstadual` | `110042490114` (SP) — **27 UFs**, `{ uf }` required |
|
|
86
|
-
| `./inscricao-estadual-produtor-rural` | `validateIeProdutorRural`, `validateIeSpRural` | `P011004243002` (SP Regra II) |
|
|
87
|
-
|
|
88
|
-
Tree-shaking via subpaths:
|
|
51
|
+
### CNPJ — numeric and alphanumeric (new RFB format)
|
|
89
52
|
|
|
90
53
|
```typescript
|
|
91
|
-
import { validateCnpj } from '@br-validators/core/cnpj';
|
|
92
|
-
import { validateNfeChave } from '@br-validators/core/nfe-chave';
|
|
93
|
-
import { validateTituloEleitor } from '@br-validators/core/titulo-eleitor';
|
|
94
|
-
import { validateBrCode } from '@br-validators/core/brcode';
|
|
95
|
-
import { validateInscricaoEstadual } from '@br-validators/core/inscricao-estadual';
|
|
96
|
-
import { validateIeProdutorRural } from '@br-validators/core/inscricao-estadual-produtor-rural';
|
|
97
|
-
```
|
|
54
|
+
import { validateCnpj, formatCnpj } from '@br-validators/core/cnpj';
|
|
98
55
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
### CNPJ (numeric + alphanumeric)
|
|
104
|
-
|
|
105
|
-
```typescript
|
|
106
|
-
import { validateCnpj, formatCnpj } from '@br-validators/core';
|
|
56
|
+
// Numeric (current format)
|
|
57
|
+
validateCnpj('11.222.333/0001-81');
|
|
58
|
+
// { ok: true, value: '11222333000181', format: 'numeric' }
|
|
107
59
|
|
|
60
|
+
// Alphanumeric (new format — effective July 2026)
|
|
108
61
|
validateCnpj('12ABC34501DE35');
|
|
109
62
|
// { ok: true, value: '12ABC34501DE35', format: 'alphanumeric' }
|
|
110
63
|
|
|
@@ -112,105 +65,231 @@ formatCnpj('12ABC34501DE35');
|
|
|
112
65
|
// { ok: true, formatted: '12.ABC.345/01DE-35' }
|
|
113
66
|
```
|
|
114
67
|
|
|
115
|
-
###
|
|
68
|
+
### Auto-detect document type
|
|
116
69
|
|
|
117
70
|
```typescript
|
|
118
|
-
import {
|
|
71
|
+
import { detect } from '@br-validators/core';
|
|
72
|
+
|
|
73
|
+
detect('123.456.789-09');
|
|
74
|
+
// { type: 'cpf', ok: true, value: '12345678909' }
|
|
75
|
+
|
|
76
|
+
detect('ABC1D23');
|
|
77
|
+
// { type: 'placa', ok: true, format: 'mercosul' }
|
|
78
|
+
|
|
79
|
+
detect('110042490114', { uf: 'SP' });
|
|
80
|
+
// { type: 'inscricao-estadual', ok: true }
|
|
81
|
+
```
|
|
119
82
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
83
|
+
### Generate valid documents for tests
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
import { generate } from '@br-validators/core';
|
|
87
|
+
|
|
88
|
+
generate('cpf', { seed: 42 }); // reproducible, always valid
|
|
89
|
+
generate('cnpj', { format: 'alphanumeric', masked: true });
|
|
90
|
+
generate('placa', { format: 'mercosul' });
|
|
91
|
+
generate('renavam');
|
|
92
|
+
generate('cnh');
|
|
93
|
+
generate('inscricao-estadual', { uf: 'SP', seed: 42 });
|
|
94
|
+
generate('titulo-eleitor', { uf: 'SC', seed: 42 });
|
|
95
|
+
generate('cartao-credito', { brand: 'visa', seed: 42 });
|
|
96
|
+
generate('pix', { seed: 42 }); // EVP UUID — Bacen DICT
|
|
97
|
+
generate('nfe-chave', { seed: 42 }); // MOC §2.2.6 modulo-11 DV
|
|
98
|
+
generate('brcode', { seed: 42 }); // static PIX EMV + CRC16
|
|
99
|
+
generate('boleto', { masked: true }); // FEBRABAN cobrança Situação 1
|
|
100
|
+
generate('boleto-arrecadacao'); // FEBRABAN Layout v7
|
|
101
|
+
generate('inscricao-estadual-produtor-rural', { masked: true }); // SP SINTEGRA Bloco II
|
|
123
102
|
```
|
|
124
103
|
|
|
125
|
-
|
|
104
|
+
> `generate()` is for test fixtures and seed data only — never use in production.
|
|
105
|
+
> Alphanumeric CPF: `generate('cpf', { format: 'alphanumeric' })` throws `CPF_ALPHA_SPEC_PENDING` until RFB publishes the official algorithm ([OFFICIAL-SOURCES.md](https://github.com/AlexandreZanata/br-validators/blob/main/docs/OFFICIAL-SOURCES.md)).
|
|
106
|
+
|
|
107
|
+
### ETL / data cleanup
|
|
126
108
|
|
|
127
109
|
```typescript
|
|
128
|
-
import {
|
|
110
|
+
import { sanitize } from '@br-validators/core';
|
|
111
|
+
|
|
112
|
+
sanitize(' 123.456.789-09 ', 'cpf');
|
|
113
|
+
// { ok: true, value: '12345678909', fixes: ['trimmed', 'removed_non_digits'] }
|
|
129
114
|
|
|
130
|
-
|
|
131
|
-
// { ok: true, value: '
|
|
115
|
+
sanitize('110.042.490.114', 'inscricao-estadual', { uf: 'SP' });
|
|
116
|
+
// { ok: true, value: '110042490114', fixes: [...] }
|
|
132
117
|
```
|
|
133
118
|
|
|
134
|
-
### NF-e
|
|
119
|
+
### NF-e chave de acesso (44 digits)
|
|
135
120
|
|
|
136
121
|
```typescript
|
|
137
122
|
import { validateNfeChave, parseNfeChave } from '@br-validators/core/nfe-chave';
|
|
138
123
|
|
|
139
124
|
const result = validateNfeChave('52060433009911002506550120000007800267301615');
|
|
140
|
-
// { ok: true, parsed: { cUF, cnpj, mod
|
|
125
|
+
// { ok: true, parsed: { cUF: '52', cnpj: '33009911002506', mod: '55', ... }, uf: 'GO' }
|
|
141
126
|
```
|
|
142
127
|
|
|
143
128
|
### BR Code (PIX QR payload)
|
|
144
129
|
|
|
145
130
|
```typescript
|
|
146
|
-
import {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
131
|
+
import {
|
|
132
|
+
buildStaticPixBrCode,
|
|
133
|
+
parseBrCode,
|
|
134
|
+
validateBrCode,
|
|
135
|
+
} from '@br-validators/core/brcode';
|
|
136
|
+
|
|
137
|
+
// Permanent static QR (no amount — payer sets value at payment time)
|
|
138
|
+
const payload = buildStaticPixBrCode({
|
|
139
|
+
pixKey: 'pix@bcb.gov.br',
|
|
140
|
+
merchantName: 'Fulano de Tal',
|
|
141
|
+
merchantCity: 'BRASILIA',
|
|
142
|
+
});
|
|
143
|
+
validateBrCode(payload).ok; // true
|
|
144
|
+
|
|
145
|
+
// Fixed-value static QR
|
|
146
|
+
buildStaticPixBrCode({
|
|
147
|
+
pixKey: 'pix@bcb.gov.br',
|
|
148
|
+
merchantName: 'Fulano de Tal',
|
|
149
|
+
merchantCity: 'BRASILIA',
|
|
150
|
+
amount: '10.50',
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
parseBrCode(payload);
|
|
154
|
+
// { ok: true, pixKey, pixKeyType, merchantName, merchantCity, amount, txid }
|
|
150
155
|
```
|
|
151
156
|
|
|
152
|
-
|
|
157
|
+
**Playground:** [doc-raiz-playground.vercel.app/pix](https://doc-raiz-playground.vercel.app/pix) renders the QR image from `buildStaticPixBrCode` output. Official sources: [Bacen Manual BR Code](https://www.bcb.gov.br/content/estabilidadefinanceira/spb_docs/ManualBRCode.pdf) · [Manual de Padrões PIX](https://www.bcb.gov.br/content/estabilidadefinanceira/pix/Regulamento_Pix/II_ManualdePadroesparaIniciacaodoPix.pdf).
|
|
158
|
+
|
|
159
|
+
### Boleto — cobrança + arrecadação
|
|
153
160
|
|
|
154
161
|
```typescript
|
|
155
|
-
import { validateBoleto,
|
|
162
|
+
import { validateBoleto, validateArrecadacao } from '@br-validators/core/boleto';
|
|
156
163
|
|
|
157
164
|
validateBoleto('03399.02579 08991.834006 71742.301014 6 14500000099668');
|
|
165
|
+
// cobrança Situação 1/2 — FEBRABAN FB-0061/2021
|
|
166
|
+
|
|
167
|
+
validateArrecadacao('846300000003812345678906123456789015234567890129');
|
|
168
|
+
// arrecadação 48-digit — FEBRABAN Layout v7
|
|
158
169
|
```
|
|
159
170
|
|
|
160
|
-
|
|
171
|
+
### Platform APIs — mask, compare, batch, diff
|
|
161
172
|
|
|
162
|
-
|
|
173
|
+
```typescript
|
|
174
|
+
import { mask, compare, batch, diff } from '@br-validators/core';
|
|
163
175
|
|
|
164
|
-
|
|
176
|
+
mask('12345678909', 'cpf');
|
|
177
|
+
// { ok: true, formatted: '123.456.789-09' }
|
|
165
178
|
|
|
166
|
-
|
|
179
|
+
compare('123.456.789-09', '12345678909', 'cpf');
|
|
180
|
+
// { equal: true }
|
|
167
181
|
|
|
168
|
-
|
|
182
|
+
batch(['12345678909', 'invalid'], 'cpf');
|
|
183
|
+
// { valid: [...], invalid: [...], summary: { total: 2, valid: 1, invalid: 1 } }
|
|
169
184
|
|
|
170
|
-
|
|
185
|
+
diff('12345678909', '12345678901', 'cpf');
|
|
186
|
+
// { changed: true, fields: [{ field: 'dv', a: '09', b: '01' }] }
|
|
187
|
+
```
|
|
171
188
|
|
|
172
|
-
|
|
189
|
+
Per-type rules and official sources: [docs/OFFICIAL-SOURCES.md](https://github.com/AlexandreZanata/br-validators/blob/main/docs/OFFICIAL-SOURCES.md) · API contract: [docs/LIBRARY-API.md](https://github.com/AlexandreZanata/br-validators/blob/main/docs/LIBRARY-API.md)
|
|
190
|
+
|
|
191
|
+
### Form handler (React / Next.js)
|
|
192
|
+
|
|
193
|
+
```typescript
|
|
194
|
+
'use client';
|
|
195
|
+
import { validateCnpj, formatCnpj } from '@br-validators/core/cnpj';
|
|
196
|
+
import { useState } from 'react';
|
|
197
|
+
|
|
198
|
+
export function CnpjField() {
|
|
199
|
+
const [input, setInput] = useState('');
|
|
200
|
+
const result = input ? validateCnpj(input) : null;
|
|
201
|
+
const formatted = result?.ok ? formatCnpj(result.value) : null;
|
|
202
|
+
|
|
203
|
+
return (
|
|
204
|
+
<div>
|
|
205
|
+
<input value={input} onChange={e => setInput(e.target.value)} />
|
|
206
|
+
{formatted?.ok && <p>✅ {formatted.formatted}</p>}
|
|
207
|
+
{result && !result.ok && <p>❌ {result.message}</p>}
|
|
208
|
+
</div>
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
```
|
|
173
212
|
|
|
174
|
-
|
|
213
|
+
### Shell / CI
|
|
175
214
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
215
|
+
```bash
|
|
216
|
+
br-validators cnpj validate "$CNPJ" --quiet || exit 1
|
|
217
|
+
br-validators ie validate "$IE" --uf SP --json
|
|
218
|
+
br-validators detect '123.456.789-09' --json
|
|
219
|
+
br-validators generate cpf --seed 42 --masked
|
|
220
|
+
br-validators generate pix --seed 42
|
|
221
|
+
br-validators generate nfe-chave --seed 42
|
|
222
|
+
br-validators generate brcode --seed 42
|
|
223
|
+
br-validators generate boleto --masked --seed 42
|
|
224
|
+
br-validators generate boleto-arrecadacao --seed 42
|
|
225
|
+
br-validators generate inscricao-estadual-produtor-rural --masked --seed 42
|
|
226
|
+
```
|
|
181
227
|
|
|
182
228
|
---
|
|
183
229
|
|
|
184
|
-
##
|
|
230
|
+
## All supported types
|
|
231
|
+
|
|
232
|
+
| Document | Subpath import | CLI | Playground |
|
|
233
|
+
|---|---|---|---|
|
|
234
|
+
| CPF | `@br-validators/core/cpf` | `br-validators cpf …` | `/cpf` |
|
|
235
|
+
| CNPJ (numeric + alphanumeric) | `@br-validators/core/cnpj` | `br-validators cnpj …` | `/cnpj` |
|
|
236
|
+
| CEP | `@br-validators/core/cep` | `br-validators cep …` | `/cep` |
|
|
237
|
+
| Telefone | `@br-validators/core/telefone` | `br-validators telefone …` | `/telefone` |
|
|
238
|
+
| CNH | `@br-validators/core/cnh` | `br-validators cnh …` | `/cnh` |
|
|
239
|
+
| RENAVAM | `@br-validators/core/renavam` | `br-validators renavam …` | `/renavam` |
|
|
240
|
+
| Título de Eleitor | `@br-validators/core/titulo-eleitor` | `br-validators titulo-eleitor …` | `/titulo-eleitor` |
|
|
241
|
+
| Placa (Mercosul + legada) | `@br-validators/core/placa` | `br-validators placa …` | `/placa` |
|
|
242
|
+
| PIS / PASEP / NIS | `@br-validators/core/pis-pasep` | `br-validators pis-pasep …` | `/pis` |
|
|
243
|
+
| PIX key | `@br-validators/core/pix` | `br-validators pix …` | `/pix` |
|
|
244
|
+
| BR Code (PIX QR payload + builder) | `@br-validators/core/brcode` | `br-validators brcode …` | `/brcode` |
|
|
245
|
+
| Boleto cobrança (Situação 1 + 2) | `@br-validators/core/boleto` | `br-validators boleto …` | `/boleto` |
|
|
246
|
+
| Boleto arrecadação (48/44) | `@br-validators/core/boleto` | `br-validators boleto …` | `/boleto` |
|
|
247
|
+
| NF-e / NFC-e chave (44 digits) | `@br-validators/core/nfe-chave` | `br-validators nfe-chave …` | `/nfe-chave` |
|
|
248
|
+
| Cartão de crédito (Luhn) | `@br-validators/core/cartao-credito` | `br-validators cartao …` | `/cartao-credito` |
|
|
249
|
+
| Inscrição Estadual (27 UFs) | `@br-validators/core/inscricao-estadual` | `br-validators ie … --uf SP` | `/ie` |
|
|
250
|
+
| IE Produtor Rural | `@br-validators/core/inscricao-estadual-produtor-rural` | `br-validators ie …` (auto `P`) | `/ie` |
|
|
251
|
+
| **detect()** | `@br-validators/core/detect` | `br-validators detect …` | `/detect` |
|
|
252
|
+
| **sanitize()** | `@br-validators/core/sanitize` | `br-validators sanitize …` | `/sanitize` |
|
|
253
|
+
| **mask()** | `@br-validators/core/mask` | — | via per-type `format` |
|
|
254
|
+
| **compare()** | `@br-validators/core/compare` | — | — |
|
|
255
|
+
| **batch()** | `@br-validators/core/batch` | — | — |
|
|
256
|
+
| **diff()** | `@br-validators/core/diff` | — | — |
|
|
257
|
+
| **generate()** | `@br-validators/core/generate` | `br-validators generate …` | `/generate` |
|
|
258
|
+
| **buildStaticPixBrCode()** | `@br-validators/core/brcode` | — | `/pix` (QR panel) |
|
|
259
|
+
|
|
260
|
+
Full official sources per type: [docs/OFFICIAL-SOURCES.md](https://github.com/AlexandreZanata/br-validators/blob/main/docs/OFFICIAL-SOURCES.md)
|
|
185
261
|
|
|
186
|
-
|
|
187
|
-
npm install -g @br-validators/cli
|
|
262
|
+
---
|
|
188
263
|
|
|
189
|
-
|
|
190
|
-
br-validators cnpj validate 12ABC34501DE35 --json
|
|
191
|
-
br-validators nfe-chave validate 52060433009911002506550120000007800267301615 --json
|
|
192
|
-
br-validators titulo-eleitor validate 004356870906
|
|
193
|
-
br-validators brcode validate '<emv-payload>'
|
|
194
|
-
br-validators ie validate 110042490114 --uf SP
|
|
264
|
+
## Tree-shaking
|
|
195
265
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
266
|
+
```typescript
|
|
267
|
+
// Only ships the CPF module — nothing else
|
|
268
|
+
import { validateCpf } from '@br-validators/core/cpf';
|
|
269
|
+
|
|
270
|
+
// Only ships NF-e module
|
|
271
|
+
import { parseNfeChave } from '@br-validators/core/nfe-chave';
|
|
200
272
|
```
|
|
201
273
|
|
|
202
274
|
---
|
|
203
275
|
|
|
204
|
-
## Related packages
|
|
276
|
+
## Related packages
|
|
205
277
|
|
|
206
278
|
| Package | Status |
|
|
207
|
-
|
|
208
|
-
| `@br-validators/cli` | Published
|
|
209
|
-
| `@br-validators/zod` |
|
|
210
|
-
| `@br-validators/react-hook-form` |
|
|
279
|
+
|---|---|
|
|
280
|
+
| [`@br-validators/cli`](https://www.npmjs.com/package/@br-validators/cli) | Published |
|
|
281
|
+
| [`@br-validators/zod`](https://www.npmjs.com/package/@br-validators/zod) | Published — Zod 3/4 schemas |
|
|
282
|
+
| [`@br-validators/react-hook-form`](https://www.npmjs.com/package/@br-validators/react-hook-form) | Published — RHF resolvers |
|
|
283
|
+
|
|
284
|
+
---
|
|
285
|
+
|
|
286
|
+
## Contributing
|
|
287
|
+
|
|
288
|
+
Issues, corrections, and new document types are welcome.
|
|
289
|
+
See [CONTRIBUTING.md](https://github.com/AlexandreZanata/br-validators/blob/main/CONTRIBUTING.md) and open `good first issue` items.
|
|
211
290
|
|
|
212
291
|
---
|
|
213
292
|
|
|
214
293
|
## License
|
|
215
294
|
|
|
216
|
-
MIT
|
|
295
|
+
[MIT](https://github.com/AlexandreZanata/br-validators/blob/main/LICENSE) — permanently free and open source.
|
package/dist/batch.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { P as PlatformDocumentType, a as PlatformOptions } from './types-MXifBcV5.js';
|
|
2
|
+
import { V as ValidationErrorCode } from './validation-result-BaI2Xder.js';
|
|
3
|
+
import './index-BEJFgDXj.js';
|
|
4
|
+
|
|
5
|
+
type BatchValidEntry = {
|
|
6
|
+
index: number;
|
|
7
|
+
input: string;
|
|
8
|
+
value: string;
|
|
9
|
+
};
|
|
10
|
+
type BatchInvalidEntry = {
|
|
11
|
+
index: number;
|
|
12
|
+
input: string;
|
|
13
|
+
code: ValidationErrorCode;
|
|
14
|
+
message: string;
|
|
15
|
+
};
|
|
16
|
+
type BatchSummary = {
|
|
17
|
+
total: number;
|
|
18
|
+
valid: number;
|
|
19
|
+
invalid: number;
|
|
20
|
+
};
|
|
21
|
+
type BatchResult = {
|
|
22
|
+
valid: BatchValidEntry[];
|
|
23
|
+
invalid: BatchInvalidEntry[];
|
|
24
|
+
summary: BatchSummary;
|
|
25
|
+
};
|
|
26
|
+
declare function batch(inputs: readonly string[], type: PlatformDocumentType, options?: PlatformOptions): BatchResult;
|
|
27
|
+
|
|
28
|
+
export { type BatchInvalidEntry, type BatchResult, type BatchSummary, type BatchValidEntry, batch };
|
package/dist/batch.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export { batch } from './chunk-N2WVO3GF.js';
|
|
2
|
+
import './chunk-I66ZRSEN.js';
|
|
3
|
+
import './chunk-AO6UTQ4A.js';
|
|
4
|
+
import './chunk-JLCQ7MGC.js';
|
|
5
|
+
import './chunk-3LMDBXU6.js';
|
|
6
|
+
import './chunk-DAR6VOMT.js';
|
|
7
|
+
import './chunk-CSVGWTCG.js';
|
|
8
|
+
import './chunk-665E36SC.js';
|
|
9
|
+
import './chunk-CDNOUZEI.js';
|
|
10
|
+
import './chunk-AU6TW3GH.js';
|
|
11
|
+
import './chunk-N6RQICAP.js';
|
|
12
|
+
import './chunk-E2EFGMWA.js';
|
|
13
|
+
import './chunk-V7UJ55KW.js';
|
|
14
|
+
import './chunk-H3MLGGFI.js';
|
|
15
|
+
import './chunk-P2KNN6ZR.js';
|
|
16
|
+
import './chunk-63G7QO73.js';
|
|
17
|
+
import './chunk-ANWQBKGN.js';
|
|
18
|
+
import './chunk-TE6NSONR.js';
|
|
19
|
+
import './chunk-YNVMVDFN.js';
|
|
20
|
+
import './chunk-YYHS5WQN.js';
|
|
21
|
+
import './chunk-4SNBZFS5.js';
|
|
22
|
+
import './chunk-UCJPSJN5.js';
|
|
23
|
+
import './chunk-CSRBRKXY.js';
|
|
24
|
+
import './chunk-FBARVLLP.js';
|
|
25
|
+
import './chunk-OTZHMJYE.js';
|
|
26
|
+
import './chunk-EB3G4IG6.js';
|
|
27
|
+
import './chunk-NUQSMT4Y.js';
|
|
28
|
+
//# sourceMappingURL=batch.js.map
|
|
29
|
+
//# sourceMappingURL=batch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"batch.js"}
|
package/dist/boleto.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { a as BoletoSituacao, i as CodigoBarras, D as DocumentFormat, L as LinhaDigitavel } from './validation-result-
|
|
1
|
+
import { y as CobrancaBoletoValidationResult, V as ValidationErrorCode, B as BoletoInputKind, b as BoletoValidationResult, F as FormatResult } from './validation-result-BaI2Xder.js';
|
|
2
|
+
export { a as BoletoSituacao, i as CodigoBarras, D as DocumentFormat, L as LinhaDigitavel } from './validation-result-BaI2Xder.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* FEBRABAN bank boleto (cobrança) — linha digitável + código de barras.
|
|
@@ -20,6 +20,10 @@ declare const BOLETO_GOLDEN_LINHA_SITUACAO2_STRIPPED = "988012345167890123457678
|
|
|
20
20
|
declare const BOLETO_GOLDEN_CODIGO_BARRAS_SITUACAO2 = "98807607469480001121234567890123456789012345";
|
|
21
21
|
declare const BOLETO_OFFICIAL_SOURCE_URL = "https://cmsarquivos.febraban.org.br/Arquivos/documentos/PDF/Conven%C3%A7%C3%A3o%20da%20Cobran%C3%A7a%20-%2005_02_2021_f.pdf";
|
|
22
22
|
declare const BOLETO_LAYOUTS_PORTAL_URL = "https://portal.febraban.org.br/pagina/3425/33/pt-br/layout-febraban";
|
|
23
|
+
declare const BOLETO_ARRECADACAO_LINHA_LENGTH = 48;
|
|
24
|
+
declare const BOLETO_ARRECADACAO_CODIGO_BARRAS_LENGTH = 44;
|
|
25
|
+
declare const BOLETO_ARRECADACAO_PRODUCT_ID = "8";
|
|
26
|
+
declare const BOLETO_ARRECADACAO_OFFICIAL_SOURCE_URL = "https://cmsarquivos.febraban.org.br/Arquivos/documentos/PDF/Layout%20-%20C%C3%B3digo%20de%20Barras%20-%20Vers%C3%A3o%207%20-%2001_03_2023_mn.pdf";
|
|
23
27
|
|
|
24
28
|
/**
|
|
25
29
|
* Modulo 10 — linha digitável field DVs (Anexo IX).
|
|
@@ -52,7 +56,7 @@ declare function formatLinhaDigitavel(stripped: string): string;
|
|
|
52
56
|
*/
|
|
53
57
|
|
|
54
58
|
declare function stripLinhaDigitavel(input: string): string;
|
|
55
|
-
declare function validateLinhaDigitavel(input: string):
|
|
59
|
+
declare function validateLinhaDigitavel(input: string): CobrancaBoletoValidationResult;
|
|
56
60
|
|
|
57
61
|
/**
|
|
58
62
|
* Código de barras validation — modulo 11 general DV (Anexo X).
|
|
@@ -60,7 +64,7 @@ declare function validateLinhaDigitavel(input: string): BoletoValidationResult;
|
|
|
60
64
|
*/
|
|
61
65
|
|
|
62
66
|
declare function stripCodigoBarras(input: string): string;
|
|
63
|
-
declare function validateCodigoBarras(input: string):
|
|
67
|
+
declare function validateCodigoBarras(input: string): CobrancaBoletoValidationResult;
|
|
64
68
|
|
|
65
69
|
/**
|
|
66
70
|
* Due-date factor semantic validation (Situação 1 only).
|
|
@@ -93,6 +97,55 @@ type ValorDocumentoValidationResult = {
|
|
|
93
97
|
};
|
|
94
98
|
declare function validateValorDocumento(value: string): ValorDocumentoValidationResult;
|
|
95
99
|
|
|
100
|
+
/**
|
|
101
|
+
* FEBRABAN arrecadação modulo 11 — Layout v7 §09–10.
|
|
102
|
+
* @see BOLETO_ARRECADACAO_OFFICIAL_SOURCE_URL
|
|
103
|
+
*
|
|
104
|
+
* Multipliers 2,3,4,5,6,7,8,9,2,3,4… from right; remainder 0|1 → DV 0; remainder 10 → DV 1.
|
|
105
|
+
*/
|
|
106
|
+
declare function computeArrecadacaoModulo11Dv(digits: string): number;
|
|
107
|
+
declare function isArrecadacaoValueType(valueType: string): valueType is ArrecadacaoValueType;
|
|
108
|
+
type ArrecadacaoValueType = '6' | '7' | '8' | '9';
|
|
109
|
+
declare function getArrecadacaoDvCalculator(valueType: string): (digits: string) => number;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Boleto arrecadação — FEBRABAN Layout v7 (48-digit linha + 44-digit código de barras).
|
|
113
|
+
* @see docs/use-cases/UC-007-validate-boleto.md
|
|
114
|
+
* @see BOLETO_ARRECADACAO_OFFICIAL_SOURCE_URL
|
|
115
|
+
*/
|
|
116
|
+
|
|
117
|
+
type ArrecadacaoInputKind = 'arrecadacao-linha' | 'arrecadacao-codigo-barras';
|
|
118
|
+
type ArrecadacaoValidationResult = {
|
|
119
|
+
ok: true;
|
|
120
|
+
value: string;
|
|
121
|
+
inputKind: ArrecadacaoInputKind;
|
|
122
|
+
format: 'arrecadacao';
|
|
123
|
+
segment: string;
|
|
124
|
+
valueType: ArrecadacaoValueType;
|
|
125
|
+
} | {
|
|
126
|
+
ok: false;
|
|
127
|
+
code: ValidationErrorCode;
|
|
128
|
+
message: string;
|
|
129
|
+
inputKind?: ArrecadacaoInputKind;
|
|
130
|
+
};
|
|
131
|
+
declare function stripArrecadacao(input: string): string;
|
|
132
|
+
declare function linhaArrecadacaoToCodigoBarras(linha: string): string;
|
|
133
|
+
declare function validateArrecadacaoLinha(input: string): ArrecadacaoValidationResult;
|
|
134
|
+
declare function validateArrecadacaoCodigoBarras(input: string): ArrecadacaoValidationResult;
|
|
135
|
+
declare function validateArrecadacao(input: string): ArrecadacaoValidationResult;
|
|
136
|
+
declare function isValidArrecadacao(input: string): boolean;
|
|
137
|
+
/** @internal Golden vector helper — builds valid barcode then linha. */
|
|
138
|
+
declare function buildArrecadacaoGoldenPair(options: {
|
|
139
|
+
segment: string;
|
|
140
|
+
valueType: ArrecadacaoValueType;
|
|
141
|
+
value: string;
|
|
142
|
+
company: string;
|
|
143
|
+
free: string;
|
|
144
|
+
}): {
|
|
145
|
+
barcode: string;
|
|
146
|
+
linha: string;
|
|
147
|
+
};
|
|
148
|
+
|
|
96
149
|
/**
|
|
97
150
|
* Boleto validation — linha digitável + código de barras (FEBRABAN cobrança).
|
|
98
151
|
* @see docs/use-cases/UC-007-validate-boleto.md
|
|
@@ -110,4 +163,4 @@ declare function convertCodigoBarrasToLinhaDigitavel(input: string): BoletoValid
|
|
|
110
163
|
|
|
111
164
|
declare function formatBoleto(input: string): FormatResult;
|
|
112
165
|
|
|
113
|
-
export { BOLETO_CODE_ISPB_HOLDER, BOLETO_CODIGO_BARRAS_LENGTH, BOLETO_CURRENCY_ISPB, BOLETO_CURRENCY_REAL, BOLETO_GOLDEN_CODIGO_BARRAS, BOLETO_GOLDEN_CODIGO_BARRAS_BB, BOLETO_GOLDEN_CODIGO_BARRAS_SITUACAO2, BOLETO_GOLDEN_LINHA_BB_STRIPPED, BOLETO_GOLDEN_LINHA_MASKED, BOLETO_GOLDEN_LINHA_SITUACAO2_STRIPPED, BOLETO_GOLDEN_LINHA_STRIPPED, BOLETO_LAYOUTS_PORTAL_URL, BOLETO_LINHA_LENGTH, BOLETO_OFFICIAL_SOURCE_URL, BoletoInputKind, type BoletoSituacaoCode, type BoletoSituacaoKind, BoletoValidationResult, type DetectedBoletoInputKind, type FatorVencimentoValidationResult, type ValidateBoletoOptions, ValidationErrorCode, type ValorDocumentoValidationResult, applyLinhaDigitavelMask, computeModulo10FieldDv, computeModulo11BarcodeDv, convertCodigoBarrasToLinhaDigitavel, convertCodigoBarrasToLinhaDigits, convertLinhaToCodigoBarras, convertLinhaToCodigoBarrasDigits, detectBoletoInputKind, detectBoletoSituacao, formatBoleto, formatLinhaDigitavel, isValidBoleto, stripCodigoBarras, stripLinhaDigitavel, validateBoleto, validateCodigoBarras, validateFatorVencimento, validateLinhaDigitavel, validateValorDocumento };
|
|
166
|
+
export { type ArrecadacaoInputKind, type ArrecadacaoValidationResult, type ArrecadacaoValueType, BOLETO_ARRECADACAO_CODIGO_BARRAS_LENGTH, BOLETO_ARRECADACAO_LINHA_LENGTH, BOLETO_ARRECADACAO_OFFICIAL_SOURCE_URL, BOLETO_ARRECADACAO_PRODUCT_ID, BOLETO_CODE_ISPB_HOLDER, BOLETO_CODIGO_BARRAS_LENGTH, BOLETO_CURRENCY_ISPB, BOLETO_CURRENCY_REAL, BOLETO_GOLDEN_CODIGO_BARRAS, BOLETO_GOLDEN_CODIGO_BARRAS_BB, BOLETO_GOLDEN_CODIGO_BARRAS_SITUACAO2, BOLETO_GOLDEN_LINHA_BB_STRIPPED, BOLETO_GOLDEN_LINHA_MASKED, BOLETO_GOLDEN_LINHA_SITUACAO2_STRIPPED, BOLETO_GOLDEN_LINHA_STRIPPED, BOLETO_LAYOUTS_PORTAL_URL, BOLETO_LINHA_LENGTH, BOLETO_OFFICIAL_SOURCE_URL, BoletoInputKind, type BoletoSituacaoCode, type BoletoSituacaoKind, BoletoValidationResult, type DetectedBoletoInputKind, type FatorVencimentoValidationResult, type ValidateBoletoOptions, ValidationErrorCode, type ValorDocumentoValidationResult, applyLinhaDigitavelMask, buildArrecadacaoGoldenPair, computeModulo10FieldDv as computeArrecadacaoModulo10Dv, computeArrecadacaoModulo11Dv, computeModulo10FieldDv, computeModulo11BarcodeDv, convertCodigoBarrasToLinhaDigitavel, convertCodigoBarrasToLinhaDigits, convertLinhaToCodigoBarras, convertLinhaToCodigoBarrasDigits, detectBoletoInputKind, detectBoletoSituacao, formatBoleto, formatLinhaDigitavel, getArrecadacaoDvCalculator, isArrecadacaoValueType, isValidArrecadacao, isValidBoleto, linhaArrecadacaoToCodigoBarras, stripArrecadacao, stripCodigoBarras, stripLinhaDigitavel, validateArrecadacao, validateArrecadacaoCodigoBarras, validateArrecadacaoLinha, validateBoleto, validateCodigoBarras, validateFatorVencimento, validateLinhaDigitavel, validateValorDocumento };
|
package/dist/boleto.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
3
|
-
|
|
1
|
+
import './chunk-KBNWI6GE.js';
|
|
2
|
+
export { formatBoleto } from './chunk-XWHGXSQV.js';
|
|
3
|
+
export { convertCodigoBarrasToLinhaDigitavel, convertLinhaToCodigoBarras, isValidBoleto, validateBoleto, validateFatorVencimento, validateValorDocumento } from './chunk-AU6TW3GH.js';
|
|
4
|
+
export { buildArrecadacaoGoldenPair, computeArrecadacaoModulo11Dv, getArrecadacaoDvCalculator, isArrecadacaoValueType, isValidArrecadacao, linhaArrecadacaoToCodigoBarras, stripArrecadacao, stripCodigoBarras, validateArrecadacao, validateArrecadacaoCodigoBarras, validateArrecadacaoLinha, validateCodigoBarras } from './chunk-N6RQICAP.js';
|
|
5
|
+
export { BOLETO_ARRECADACAO_CODIGO_BARRAS_LENGTH, BOLETO_ARRECADACAO_LINHA_LENGTH, BOLETO_ARRECADACAO_OFFICIAL_SOURCE_URL, BOLETO_ARRECADACAO_PRODUCT_ID, BOLETO_CODE_ISPB_HOLDER, BOLETO_CODIGO_BARRAS_LENGTH, BOLETO_CURRENCY_ISPB, BOLETO_CURRENCY_REAL, BOLETO_GOLDEN_CODIGO_BARRAS, BOLETO_GOLDEN_CODIGO_BARRAS_BB, BOLETO_GOLDEN_CODIGO_BARRAS_SITUACAO2, BOLETO_GOLDEN_LINHA_BB_STRIPPED, BOLETO_GOLDEN_LINHA_MASKED, BOLETO_GOLDEN_LINHA_SITUACAO2_STRIPPED, BOLETO_GOLDEN_LINHA_STRIPPED, BOLETO_LAYOUTS_PORTAL_URL, BOLETO_LINHA_LENGTH, BOLETO_OFFICIAL_SOURCE_URL, applyLinhaDigitavelMask, computeModulo10FieldDv as computeArrecadacaoModulo10Dv, computeModulo10FieldDv, computeModulo11BarcodeDv, convertCodigoBarrasToLinhaDigits, convertLinhaToCodigoBarrasDigits, detectBoletoInputKind, detectBoletoSituacao, formatLinhaDigitavel, stripLinhaDigitavel, validateLinhaDigitavel } from './chunk-E2EFGMWA.js';
|
|
6
|
+
import './chunk-NUQSMT4Y.js';
|
|
4
7
|
//# sourceMappingURL=boleto.js.map
|
|
5
8
|
//# sourceMappingURL=boleto.js.map
|
package/dist/brcode.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { p as PixKey, q as PixKeyType, V as ValidationErrorCode, d as BrCodeValidationResult } from './validation-result-
|
|
2
|
-
export { c as BrCodePayload } from './validation-result-
|
|
1
|
+
import { p as PixKey, q as PixKeyType, V as ValidationErrorCode, d as BrCodeValidationResult } from './validation-result-BaI2Xder.js';
|
|
2
|
+
export { c as BrCodePayload } from './validation-result-BaI2Xder.js';
|
|
3
3
|
|
|
4
4
|
/** Bacen Manual BR Code — EMV-QRCPS-MPM TLV + CRC16-CCITT */
|
|
5
5
|
declare const BRCODE_OFFICIAL_SOURCE_URL = "https://www.bcb.gov.br/content/estabilidadefinanceira/spb_docs/ManualBRCode.pdf";
|
|
@@ -24,6 +24,18 @@ declare function verifyBrCodeCrc(payload: string): {
|
|
|
24
24
|
message: string;
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
+
type StaticPixBrCodeInput = {
|
|
28
|
+
pixKey: string;
|
|
29
|
+
merchantName: string;
|
|
30
|
+
merchantCity: string;
|
|
31
|
+
/** Omit for permanent static QR (payer sets amount). Decimal with up to 2 fraction digits. */
|
|
32
|
+
amount?: string;
|
|
33
|
+
/** Defaults to `***` per Manual de Padrões PIX static QR. */
|
|
34
|
+
txid?: string;
|
|
35
|
+
};
|
|
36
|
+
/** Build static PIX BR Code EMV payload. Validate output with `validateBrCode`. */
|
|
37
|
+
declare function buildStaticPixBrCode(input: StaticPixBrCodeInput): string;
|
|
38
|
+
|
|
27
39
|
type BrCodeParsedFields = {
|
|
28
40
|
merchantName: string;
|
|
29
41
|
merchantCity: string;
|
|
@@ -76,4 +88,4 @@ declare function isValidBrCode(input: string): boolean;
|
|
|
76
88
|
declare function parseBrCode(input: string): BrCodeValidationResult;
|
|
77
89
|
declare function validateBrCode(input: string): BrCodeValidationResult;
|
|
78
90
|
|
|
79
|
-
export { BRCODE_GOLDEN_COMPOSITE, BRCODE_GOLDEN_DYNAMIC_URL, BRCODE_GOLDEN_STATIC_CPF, BRCODE_GOLDEN_STATIC_EMAIL, BRCODE_GOLDEN_STATIC_EVP, BRCODE_OFFICIAL_SOURCE_URL, BRCODE_PIX_INITIATION_MANUAL_URL, type BrCodeParseResult, type BrCodeParsedFields, BrCodeValidationResult, PixKeyType, type TlvField, type TlvParseResult, computeCrc16Ccitt, findPixMerchantAccount, findTlvField, isValidBrCode, normalizeBrCodePayload, parseBrCode, parseBrCodePayload, parseTlvSequence, validateBrCode, verifyBrCodeCrc };
|
|
91
|
+
export { BRCODE_GOLDEN_COMPOSITE, BRCODE_GOLDEN_DYNAMIC_URL, BRCODE_GOLDEN_STATIC_CPF, BRCODE_GOLDEN_STATIC_EMAIL, BRCODE_GOLDEN_STATIC_EVP, BRCODE_OFFICIAL_SOURCE_URL, BRCODE_PIX_INITIATION_MANUAL_URL, type BrCodeParseResult, type BrCodeParsedFields, BrCodeValidationResult, PixKeyType, type StaticPixBrCodeInput, type TlvField, type TlvParseResult, buildStaticPixBrCode, computeCrc16Ccitt, findPixMerchantAccount, findTlvField, isValidBrCode, normalizeBrCodePayload, parseBrCode, parseBrCodePayload, parseTlvSequence, validateBrCode, verifyBrCodeCrc };
|