@br-validators/core 0.10.0-alpha.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/LICENSE +21 -0
- package/README.md +91 -0
- package/dist/boleto.d.ts +113 -0
- package/dist/boleto.js +4 -0
- package/dist/boleto.js.map +1 -0
- package/dist/cartao-credito.d.ts +47 -0
- package/dist/cartao-credito.js +4 -0
- package/dist/cartao-credito.js.map +1 -0
- package/dist/cep.d.ts +20 -0
- package/dist/cep.js +7 -0
- package/dist/cep.js.map +1 -0
- package/dist/chunk-54DTXC6V.js +207 -0
- package/dist/chunk-54DTXC6V.js.map +1 -0
- package/dist/chunk-7FOWIH6F.js +20 -0
- package/dist/chunk-7FOWIH6F.js.map +1 -0
- package/dist/chunk-AKJHIJ5E.js +387 -0
- package/dist/chunk-AKJHIJ5E.js.map +1 -0
- package/dist/chunk-B2TDI3YS.js +23 -0
- package/dist/chunk-B2TDI3YS.js.map +1 -0
- package/dist/chunk-DKRM66US.js +35 -0
- package/dist/chunk-DKRM66US.js.map +1 -0
- package/dist/chunk-EB3G4IG6.js +8 -0
- package/dist/chunk-EB3G4IG6.js.map +1 -0
- package/dist/chunk-M66MGLHE.js +156 -0
- package/dist/chunk-M66MGLHE.js.map +1 -0
- package/dist/chunk-OWJ5HN4T.js +91 -0
- package/dist/chunk-OWJ5HN4T.js.map +1 -0
- package/dist/chunk-PBNVKDCF.js +82 -0
- package/dist/chunk-PBNVKDCF.js.map +1 -0
- package/dist/chunk-RMKTJQBB.js +61 -0
- package/dist/chunk-RMKTJQBB.js.map +1 -0
- package/dist/chunk-RZ2JG5PP.js +14 -0
- package/dist/chunk-RZ2JG5PP.js.map +1 -0
- package/dist/chunk-SE33CFGM.js +276 -0
- package/dist/chunk-SE33CFGM.js.map +1 -0
- package/dist/chunk-UCJPSJN5.js +8 -0
- package/dist/chunk-UCJPSJN5.js.map +1 -0
- package/dist/chunk-W6UXVWSR.js +13 -0
- package/dist/chunk-W6UXVWSR.js.map +1 -0
- package/dist/chunk-YY4M2YS6.js +115 -0
- package/dist/chunk-YY4M2YS6.js.map +1 -0
- package/dist/chunk-Z4F75QEC.js +1180 -0
- package/dist/chunk-Z4F75QEC.js.map +1 -0
- package/dist/cnpj.d.ts +37 -0
- package/dist/cnpj.js +7 -0
- package/dist/cnpj.js.map +1 -0
- package/dist/cpf.d.ts +20 -0
- package/dist/cpf.js +7 -0
- package/dist/cpf.js.map +1 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.js +69 -0
- package/dist/index.js.map +1 -0
- package/dist/inscricao-estadual.d.ts +57 -0
- package/dist/inscricao-estadual.js +4 -0
- package/dist/inscricao-estadual.js.map +1 -0
- package/dist/pis-pasep.d.ts +20 -0
- package/dist/pis-pasep.js +5 -0
- package/dist/pis-pasep.js.map +1 -0
- package/dist/pix-DP6jnwpN.d.ts +44 -0
- package/dist/pix.d.ts +11 -0
- package/dist/pix.js +9 -0
- package/dist/pix.js.map +1 -0
- package/dist/placa.d.ts +35 -0
- package/dist/placa.js +7 -0
- package/dist/placa.js.map +1 -0
- package/dist/validation-result-BK4qJuei.d.ts +101 -0
- package/package.json +91 -0
package/dist/pix.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { PIX_DICT_API_SOURCE_URL, PIX_GOLDEN_CNPJ_ALPHANUMERIC, PIX_GOLDEN_CNPJ_NUMERIC, PIX_GOLDEN_CPF, PIX_GOLDEN_EMAIL, PIX_GOLDEN_EVP, PIX_GOLDEN_PHONE, PIX_OFFICIAL_SOURCE_URL, applyPixCnpjKeyMask, applyPixCpfKeyMask, applyPixEmailKeyMask, applyPixEvpKeyMask, applyPixPhoneKeyMask, detectPixKeyType, formatPixKey, isValidPixKey, validatePixCnpjKey, validatePixCpfKey, validatePixEmailKey, validatePixEvpKey, validatePixKey, validatePixPhoneKey } from './chunk-SE33CFGM.js';
|
|
2
|
+
import './chunk-M66MGLHE.js';
|
|
3
|
+
import './chunk-EB3G4IG6.js';
|
|
4
|
+
import './chunk-PBNVKDCF.js';
|
|
5
|
+
import './chunk-UCJPSJN5.js';
|
|
6
|
+
import './chunk-B2TDI3YS.js';
|
|
7
|
+
import './chunk-DKRM66US.js';
|
|
8
|
+
//# sourceMappingURL=pix.js.map
|
|
9
|
+
//# sourceMappingURL=pix.js.map
|
package/dist/pix.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"pix.js"}
|
package/dist/placa.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { F as FormatResult, m as ValidationResult, l as Placa } from './validation-result-BK4qJuei.js';
|
|
2
|
+
export { D as DocumentFormat, V as ValidationErrorCode } from './validation-result-BK4qJuei.js';
|
|
3
|
+
|
|
4
|
+
declare const PLACA_GOLDEN_MERCOSUL = "ABC1D23";
|
|
5
|
+
declare const PLACA_GOLDEN_LEGACY = "ABC1234";
|
|
6
|
+
declare const PLACA_GOLDEN_CONVERSION_FROM = "ABC1234";
|
|
7
|
+
declare const PLACA_GOLDEN_CONVERSION_TO = "ABC1C34";
|
|
8
|
+
declare const PLACA_OFFICIAL_SOURCE_URL = "https://www.gov.br/transportes/pt-br/assuntos/transito/conteudo-contran/resolucoes/resolucao7292018consolidada.pdf";
|
|
9
|
+
|
|
10
|
+
type PlacaFormat = 'legacy' | 'mercosul' | 'unknown';
|
|
11
|
+
declare function detectPlacaFormat(input: string): PlacaFormat;
|
|
12
|
+
|
|
13
|
+
declare function isValidPlacaLegacy(input: string): boolean;
|
|
14
|
+
|
|
15
|
+
declare function isValidPlacaMercosul(input: string): boolean;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Legacy → Mercosul plate conversion (CONTRAN digit-to-letter table).
|
|
19
|
+
* @see https://www.gov.br/transportes/pt-br/assuntos/transito/conteudo-contran/resolucoes/resolucao7292018consolidada.pdf
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
declare function convertPlacaToMercosul(input: string): FormatResult;
|
|
23
|
+
|
|
24
|
+
declare function isValidPlaca(input: string): boolean;
|
|
25
|
+
declare function validatePlaca(input: string): ValidationResult<Placa>;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Strip placa mask — preserve A-Z0-9, uppercase (BR-PLACA-004).
|
|
29
|
+
* @see https://www.gov.br/transportes/pt-br/assuntos/transito/conteudo-contran/resolucoes/resolucao7292018consolidada.pdf
|
|
30
|
+
*/
|
|
31
|
+
declare function stripPlaca(input: string): string;
|
|
32
|
+
|
|
33
|
+
declare function formatPlaca(input: string): FormatResult;
|
|
34
|
+
|
|
35
|
+
export { FormatResult, PLACA_GOLDEN_CONVERSION_FROM, PLACA_GOLDEN_CONVERSION_TO, PLACA_GOLDEN_LEGACY, PLACA_GOLDEN_MERCOSUL, PLACA_OFFICIAL_SOURCE_URL, Placa, type PlacaFormat, ValidationResult, convertPlacaToMercosul, detectPlacaFormat, formatPlaca, isValidPlaca, isValidPlacaLegacy, isValidPlacaMercosul, stripPlaca, validatePlaca };
|
package/dist/placa.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { PLACA_GOLDEN_CONVERSION_FROM, PLACA_GOLDEN_CONVERSION_TO, PLACA_GOLDEN_LEGACY, PLACA_GOLDEN_MERCOSUL, PLACA_OFFICIAL_SOURCE_URL, convertPlacaToMercosul, detectPlacaFormat, formatPlaca, isValidPlaca, isValidPlacaLegacy, isValidPlacaMercosul, validatePlaca } from './chunk-YY4M2YS6.js';
|
|
2
|
+
export { stripPlaca } from './chunk-W6UXVWSR.js';
|
|
3
|
+
import './chunk-EB3G4IG6.js';
|
|
4
|
+
import './chunk-UCJPSJN5.js';
|
|
5
|
+
import './chunk-DKRM66US.js';
|
|
6
|
+
//# sourceMappingURL=placa.js.map
|
|
7
|
+
//# sourceMappingURL=placa.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"placa.js"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
type DocumentFormat = 'numeric' | 'alphanumeric' | 'legacy' | 'mercosul' | 'email' | 'phone' | 'evp' | 'linha-digitavel' | 'codigo-barras' | 'cartao-credito' | 'inscricao-estadual';
|
|
2
|
+
type PixKeyType = 'cpf' | 'cnpj' | 'email' | 'phone' | 'evp';
|
|
3
|
+
type BoletoInputKind = 'linha-digitavel' | 'codigo-barras';
|
|
4
|
+
type ValidationErrorCode = 'INVALID_LENGTH' | 'INVALID_CHARACTER' | 'INVALID_CHECK_DIGIT' | 'KNOWN_INVALID_PATTERN' | 'UNSUPPORTED_FORMAT' | 'EMPTY_INPUT';
|
|
5
|
+
type ValidationResult<T extends string = string> = {
|
|
6
|
+
ok: true;
|
|
7
|
+
value: T;
|
|
8
|
+
format: DocumentFormat;
|
|
9
|
+
} | {
|
|
10
|
+
ok: false;
|
|
11
|
+
code: ValidationErrorCode;
|
|
12
|
+
message: string;
|
|
13
|
+
};
|
|
14
|
+
type FormatResult = {
|
|
15
|
+
ok: true;
|
|
16
|
+
formatted: string;
|
|
17
|
+
} | {
|
|
18
|
+
ok: false;
|
|
19
|
+
code: ValidationErrorCode;
|
|
20
|
+
message: string;
|
|
21
|
+
};
|
|
22
|
+
type Cnpj = string & {
|
|
23
|
+
readonly __brand: 'Cnpj';
|
|
24
|
+
};
|
|
25
|
+
type Cpf = string & {
|
|
26
|
+
readonly __brand: 'Cpf';
|
|
27
|
+
};
|
|
28
|
+
type Cep = string & {
|
|
29
|
+
readonly __brand: 'Cep';
|
|
30
|
+
};
|
|
31
|
+
type Placa = string & {
|
|
32
|
+
readonly __brand: 'Placa';
|
|
33
|
+
};
|
|
34
|
+
type PisPasep = string & {
|
|
35
|
+
readonly __brand: 'PisPasep';
|
|
36
|
+
};
|
|
37
|
+
type PixKey = string & {
|
|
38
|
+
readonly __brand: 'PixKey';
|
|
39
|
+
};
|
|
40
|
+
type LinhaDigitavel = string & {
|
|
41
|
+
readonly __brand: 'LinhaDigitavel';
|
|
42
|
+
};
|
|
43
|
+
type CodigoBarras = string & {
|
|
44
|
+
readonly __brand: 'CodigoBarras';
|
|
45
|
+
};
|
|
46
|
+
type CartaoCredito = string & {
|
|
47
|
+
readonly __brand: 'CartaoCredito';
|
|
48
|
+
};
|
|
49
|
+
type InscricaoEstadual = string & {
|
|
50
|
+
readonly __brand: 'InscricaoEstadual';
|
|
51
|
+
};
|
|
52
|
+
type UfCode = 'AC' | 'AL' | 'AM' | 'AP' | 'BA' | 'CE' | 'DF' | 'ES' | 'GO' | 'MA' | 'MG' | 'MS' | 'MT' | 'PA' | 'PB' | 'PE' | 'PI' | 'PR' | 'RJ' | 'RN' | 'RO' | 'RR' | 'RS' | 'SC' | 'SE' | 'SP' | 'TO';
|
|
53
|
+
type CardBrand = 'visa' | 'mastercard' | 'amex' | 'elo' | 'hipercard' | 'unknown';
|
|
54
|
+
type CartaoCreditoValidationResult = {
|
|
55
|
+
ok: true;
|
|
56
|
+
value: CartaoCredito;
|
|
57
|
+
format: 'cartao-credito';
|
|
58
|
+
brand: CardBrand;
|
|
59
|
+
} | {
|
|
60
|
+
ok: false;
|
|
61
|
+
code: ValidationErrorCode;
|
|
62
|
+
message: string;
|
|
63
|
+
brand?: CardBrand;
|
|
64
|
+
};
|
|
65
|
+
type PixValidationResult = {
|
|
66
|
+
ok: true;
|
|
67
|
+
value: PixKey;
|
|
68
|
+
keyType: PixKeyType;
|
|
69
|
+
format: DocumentFormat;
|
|
70
|
+
} | {
|
|
71
|
+
ok: false;
|
|
72
|
+
code: ValidationErrorCode;
|
|
73
|
+
message: string;
|
|
74
|
+
keyType?: PixKeyType;
|
|
75
|
+
};
|
|
76
|
+
type BoletoSituacao = '1' | '2';
|
|
77
|
+
type BoletoValidationResult = {
|
|
78
|
+
ok: true;
|
|
79
|
+
value: LinhaDigitavel | CodigoBarras;
|
|
80
|
+
inputKind: BoletoInputKind;
|
|
81
|
+
format: DocumentFormat;
|
|
82
|
+
situacao: BoletoSituacao;
|
|
83
|
+
} | {
|
|
84
|
+
ok: false;
|
|
85
|
+
code: ValidationErrorCode;
|
|
86
|
+
message: string;
|
|
87
|
+
inputKind?: BoletoInputKind;
|
|
88
|
+
};
|
|
89
|
+
type InscricaoEstadualValidationResult = {
|
|
90
|
+
ok: true;
|
|
91
|
+
value: InscricaoEstadual;
|
|
92
|
+
uf: UfCode;
|
|
93
|
+
format: 'inscricao-estadual';
|
|
94
|
+
} | {
|
|
95
|
+
ok: false;
|
|
96
|
+
code: ValidationErrorCode;
|
|
97
|
+
message: string;
|
|
98
|
+
uf?: UfCode;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export type { BoletoInputKind as B, CartaoCredito as C, DocumentFormat as D, FormatResult as F, InscricaoEstadual as I, LinhaDigitavel as L, PisPasep as P, UfCode as U, ValidationErrorCode as V, BoletoSituacao as a, BoletoValidationResult as b, CartaoCreditoValidationResult as c, Cep as d, Cnpj as e, CodigoBarras as f, Cpf as g, InscricaoEstadualValidationResult as h, PixKey as i, PixKeyType as j, PixValidationResult as k, Placa as l, ValidationResult as m };
|
package/package.json
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@br-validators/core",
|
|
3
|
+
"version": "0.10.0-alpha.0",
|
|
4
|
+
"description": "100% open-source Brazilian document validators — CPF, CNPJ, CEP, IE (27 UFs), PIX, boleto, and more",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/AlexandreZanata/doc-raiz.git",
|
|
10
|
+
"directory": "packages/br-validators"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/AlexandreZanata/doc-raiz#readme",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/AlexandreZanata/doc-raiz/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"brazil",
|
|
18
|
+
"cpf",
|
|
19
|
+
"cnpj",
|
|
20
|
+
"cep",
|
|
21
|
+
"validator",
|
|
22
|
+
"inscricao-estadual",
|
|
23
|
+
"pix",
|
|
24
|
+
"boleto",
|
|
25
|
+
"typescript"
|
|
26
|
+
],
|
|
27
|
+
"publishConfig": {
|
|
28
|
+
"access": "public"
|
|
29
|
+
},
|
|
30
|
+
"main": "./dist/index.js",
|
|
31
|
+
"types": "./dist/index.d.ts",
|
|
32
|
+
"exports": {
|
|
33
|
+
".": {
|
|
34
|
+
"types": "./dist/index.d.ts",
|
|
35
|
+
"import": "./dist/index.js"
|
|
36
|
+
},
|
|
37
|
+
"./cnpj": {
|
|
38
|
+
"types": "./dist/cnpj.d.ts",
|
|
39
|
+
"import": "./dist/cnpj.js"
|
|
40
|
+
},
|
|
41
|
+
"./cpf": {
|
|
42
|
+
"types": "./dist/cpf.d.ts",
|
|
43
|
+
"import": "./dist/cpf.js"
|
|
44
|
+
},
|
|
45
|
+
"./cep": {
|
|
46
|
+
"types": "./dist/cep.d.ts",
|
|
47
|
+
"import": "./dist/cep.js"
|
|
48
|
+
},
|
|
49
|
+
"./placa": {
|
|
50
|
+
"types": "./dist/placa.d.ts",
|
|
51
|
+
"import": "./dist/placa.js"
|
|
52
|
+
},
|
|
53
|
+
"./pis-pasep": {
|
|
54
|
+
"types": "./dist/pis-pasep.d.ts",
|
|
55
|
+
"import": "./dist/pis-pasep.js"
|
|
56
|
+
},
|
|
57
|
+
"./pix": {
|
|
58
|
+
"types": "./dist/pix.d.ts",
|
|
59
|
+
"import": "./dist/pix.js"
|
|
60
|
+
},
|
|
61
|
+
"./boleto": {
|
|
62
|
+
"types": "./dist/boleto.d.ts",
|
|
63
|
+
"import": "./dist/boleto.js"
|
|
64
|
+
},
|
|
65
|
+
"./cartao-credito": {
|
|
66
|
+
"types": "./dist/cartao-credito.d.ts",
|
|
67
|
+
"import": "./dist/cartao-credito.js"
|
|
68
|
+
},
|
|
69
|
+
"./inscricao-estadual": {
|
|
70
|
+
"types": "./dist/inscricao-estadual.d.ts",
|
|
71
|
+
"import": "./dist/inscricao-estadual.js"
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
"files": [
|
|
75
|
+
"dist",
|
|
76
|
+
"README.md"
|
|
77
|
+
],
|
|
78
|
+
"devDependencies": {
|
|
79
|
+
"@vitest/coverage-v8": "^3.2.4",
|
|
80
|
+
"tsup": "^8.5.0",
|
|
81
|
+
"typescript": "^5.8.3",
|
|
82
|
+
"vitest": "^3.2.4"
|
|
83
|
+
},
|
|
84
|
+
"scripts": {
|
|
85
|
+
"build": "tsup",
|
|
86
|
+
"test": "vitest run",
|
|
87
|
+
"test:coverage": "vitest run --coverage",
|
|
88
|
+
"lint": "eslint src tests --max-warnings 0",
|
|
89
|
+
"typecheck": "tsc --noEmit"
|
|
90
|
+
}
|
|
91
|
+
}
|