@br-validators/vue 1.6.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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 BR Validators contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,66 @@
1
+ # @br-validators/vue
2
+
3
+ [Vue 3](https://vuejs.org/) composables that delegate validation and formatting to [`@br-validators/core`](../br-validators).
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ pnpm add @br-validators/vue @br-validators/core vue
9
+ ```
10
+
11
+ **Peer dependencies:** `vue` `^3.5.0`, `@br-validators/core`
12
+
13
+ ## Generic composable
14
+
15
+ ```vue
16
+ <script setup lang="ts">
17
+ import { useBrValidator } from '@br-validators/vue';
18
+
19
+ const cpf = useBrValidator('cpf');
20
+ </script>
21
+
22
+ <template>
23
+ <input v-model="cpf.value" />
24
+ <p v-if="cpf.error">{{ cpf.error }}</p>
25
+ <p v-else-if="cpf.isValid">Formatted: {{ cpf.formatted }}</p>
26
+ </template>
27
+ ```
28
+
29
+ ## Named composables (v1)
30
+
31
+ | Composable | Core delegate |
32
+ |------------|---------------|
33
+ | `useCpf()` | `validateCpf` / `formatCpf` |
34
+ | `useCnpj()` | `validateCnpj` / `formatCnpj` |
35
+ | `useCep()` | `validateCep` / `formatCep` |
36
+ | `useTelefone()` | `validateTelefone` / `formatTelefone` |
37
+ | `usePix()` | `validatePixKey` / `formatPixKey` |
38
+ | `useInscricaoEstadual({ uf })` | `validateInscricaoEstadual` / `formatInscricaoEstadual` |
39
+
40
+ Each composable exposes reactive `value`, `error`, `formatted`, `isValid`, and `validate()`.
41
+
42
+ ### Inscrição Estadual with UF ref
43
+
44
+ ```typescript
45
+ import { ref } from 'vue';
46
+ import { useInscricaoEstadual } from '@br-validators/vue';
47
+
48
+ const uf = ref<'SP' | 'RJ'>('SP');
49
+ const ie = useInscricaoEstadual({ uf });
50
+ ```
51
+
52
+ ### PIX type constraint
53
+
54
+ ```typescript
55
+ import { usePix } from '@br-validators/vue';
56
+
57
+ const pix = usePix({ pixType: 'email' });
58
+ ```
59
+
60
+ Invalid values surface the same `message` string returned by core `validate*`.
61
+
62
+ Official algorithm sources: [docs/OFFICIAL-SOURCES.md](../../docs/OFFICIAL-SOURCES.md).
63
+
64
+ ## License
65
+
66
+ MIT
package/dist/cep.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ import { U as UseBrValidatorOptions, a as UseBrValidatorReturn } from './types-DNxSWfie.js';
2
+ import 'vue';
3
+ import '@br-validators/core';
4
+
5
+ declare function useCep(options?: Omit<UseBrValidatorOptions, 'uf' | 'pixType'>): UseBrValidatorReturn;
6
+
7
+ export { useCep };
package/dist/cep.js ADDED
@@ -0,0 +1,4 @@
1
+ export { useCep } from './chunk-AQCUZB5O.js';
2
+ import './chunk-35WUWOHK.js';
3
+ //# sourceMappingURL=cep.js.map
4
+ //# sourceMappingURL=cep.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"cep.js"}
@@ -0,0 +1,98 @@
1
+ import { validateTelefone, validateCep, validateCnpj, validateCpf, validateInscricaoEstadual, validatePixKey, formatTelefone, formatCep, formatCnpj, formatCpf, formatInscricaoEstadual, formatPixKey } from '@br-validators/core';
2
+ import { ref, computed, toValue } from 'vue';
3
+
4
+ // src/validator-registry.ts
5
+ function missingUfFailure() {
6
+ return {
7
+ ok: false,
8
+ code: "UNSUPPORTED_FORMAT",
9
+ message: "UF is required for inscricao-estadual \u2014 pass { uf } to useBrValidator() or useInscricaoEstadual()"
10
+ };
11
+ }
12
+ function runPixValidate(value, context) {
13
+ const options = context.pixType ? { type: context.pixType } : void 0;
14
+ return validatePixKey(value, options);
15
+ }
16
+ function runPixFormat(value, context) {
17
+ const options = context.pixType ? { type: context.pixType } : void 0;
18
+ return formatPixKey(value, options);
19
+ }
20
+ function runIeValidate(value, context) {
21
+ const uf = context.uf;
22
+ if (!uf) {
23
+ return missingUfFailure();
24
+ }
25
+ return validateInscricaoEstadual(value, { uf });
26
+ }
27
+ function runIeFormat(value, context) {
28
+ const uf = context.uf;
29
+ if (!uf) {
30
+ return {
31
+ ok: false,
32
+ code: "UNSUPPORTED_FORMAT",
33
+ message: "UF is required for inscricao-estadual \u2014 pass { uf } to useBrValidator() or useInscricaoEstadual()"
34
+ };
35
+ }
36
+ return formatInscricaoEstadual(value, { uf });
37
+ }
38
+ var VALIDATORS = {
39
+ cpf: (value) => validateCpf(value),
40
+ cnpj: (value) => validateCnpj(value),
41
+ cep: (value) => validateCep(value),
42
+ telefone: (value) => validateTelefone(value),
43
+ pix: runPixValidate,
44
+ "inscricao-estadual": runIeValidate
45
+ };
46
+ var FORMATTERS = {
47
+ cpf: (value) => formatCpf(value),
48
+ cnpj: (value) => formatCnpj(value),
49
+ cep: (value) => formatCep(value),
50
+ telefone: (value) => formatTelefone(value),
51
+ pix: runPixFormat,
52
+ "inscricao-estadual": runIeFormat
53
+ };
54
+ function runBrValidator(typeId, value, context) {
55
+ return VALIDATORS[typeId](value, context);
56
+ }
57
+ function runBrFormatter(typeId, value, context) {
58
+ return FORMATTERS[typeId](value, context);
59
+ }
60
+
61
+ // src/evaluate.ts
62
+ function isEmptyBrValue(value) {
63
+ return value.trim() === "";
64
+ }
65
+ function evaluateBrValidator(typeId, value, context) {
66
+ if (isEmptyBrValue(value)) {
67
+ return { isValid: false, error: null, formatted: null };
68
+ }
69
+ const validation = runBrValidator(typeId, value, context);
70
+ if (!validation.ok) {
71
+ return { isValid: false, error: validation.message, formatted: null };
72
+ }
73
+ const formatted = runBrFormatter(typeId, value, context);
74
+ if (!formatted.ok) {
75
+ return { isValid: false, error: formatted.message, formatted: null };
76
+ }
77
+ return { isValid: true, error: null, formatted: formatted.formatted };
78
+ }
79
+ function resolveContext(options) {
80
+ return {
81
+ uf: options.uf !== void 0 ? toValue(options.uf) : void 0,
82
+ pixType: options.pixType !== void 0 ? toValue(options.pixType) : void 0
83
+ };
84
+ }
85
+ function useBrValidator(typeId, options = {}) {
86
+ const value = ref(options.initialValue ?? "");
87
+ const context = computed(() => resolveContext(options));
88
+ const evaluation = computed(() => evaluateBrValidator(typeId, value.value, context.value));
89
+ const isValid = computed(() => evaluation.value.isValid);
90
+ const error = computed(() => evaluation.value.error);
91
+ const formatted = computed(() => evaluation.value.formatted);
92
+ const validate = () => evaluation.value.isValid;
93
+ return { value, isValid, error, formatted, validate };
94
+ }
95
+
96
+ export { evaluateBrValidator, isEmptyBrValue, runBrFormatter, runBrValidator, useBrValidator };
97
+ //# sourceMappingURL=chunk-35WUWOHK.js.map
98
+ //# sourceMappingURL=chunk-35WUWOHK.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/validator-registry.ts","../src/evaluate.ts","../src/use-br-validator.ts"],"names":[],"mappings":";;;;AAyBA,SAAS,gBAAA,GAAqC;AAC5C,EAAA,OAAO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Y,QAAA,CAAS,MAAM,UAAA,CAAW,MAAM,SAAS,CAAA;AAE3D,EAAA,MAAM,QAAA,GAAW,MAAe,UAAA,CAAW,KAAA,CAAM,OAAA;AAEjD,EAAA,OAAO,EAAE,KAAA,EAAO,OAAA,EAAS,KAAA,EAAO,WAAW,QAAA,EAAS;AACtD","file":"chunk-35WUWOHK.js","sourcesContent":["import {\n formatCep,\n formatCnpj,\n formatCpf,\n formatInscricaoEstadual,\n formatPixKey,\n formatTelefone,\n validateCep,\n validateCnpj,\n validateCpf,\n validateInscricaoEstadual,\n validatePixKey,\n validateTelefone,\n type FormatResult,\n type ValidationErrorCode,\n} from '@br-validators/core';\nimport type { BrValidatorV1TypeId, ValidatorContext } from './types.js';\n\nexport type ValidatorOutcome =\n | { ok: true }\n | { ok: false; code: ValidationErrorCode; message: string };\n\ntype ValidatorRunner = (value: string, context: ValidatorContext) => ValidatorOutcome;\ntype FormatterRunner = (value: string, context: ValidatorContext) => FormatResult;\n\nfunction missingUfFailure(): ValidatorOutcome {\n return {\n ok: false,\n code: 'UNSUPPORTED_FORMAT',\n message: 'UF is required for inscricao-estadual — pass { uf } to useBrValidator() or useInscricaoEstadual()',\n };\n}\n\nfunction runPixValidate(value: string, context: ValidatorContext): ValidatorOutcome {\n const options = context.pixType ? { type: context.pixType } : undefined;\n return validatePixKey(value, options);\n}\n\nfunction runPixFormat(value: string, context: ValidatorContext): FormatResult {\n const options = context.pixType ? { type: context.pixType } : undefined;\n return formatPixKey(value, options);\n}\n\nfunction runIeValidate(value: string, context: ValidatorContext): ValidatorOutcome {\n const uf = context.uf;\n if (!uf) {\n return missingUfFailure();\n }\n return validateInscricaoEstadual(value, { uf });\n}\n\nfunction runIeFormat(value: string, context: ValidatorContext): FormatResult {\n const uf = context.uf;\n if (!uf) {\n return {\n ok: false,\n code: 'UNSUPPORTED_FORMAT',\n message: 'UF is required for inscricao-estadual — pass { uf } to useBrValidator() or useInscricaoEstadual()',\n };\n }\n return formatInscricaoEstadual(value, { uf });\n}\n\nconst VALIDATORS: Record<BrValidatorV1TypeId, ValidatorRunner> = {\n cpf: (value) => validateCpf(value),\n cnpj: (value) => validateCnpj(value),\n cep: (value) => validateCep(value),\n telefone: (value) => validateTelefone(value),\n pix: runPixValidate,\n 'inscricao-estadual': runIeValidate,\n};\n\nconst FORMATTERS: Record<BrValidatorV1TypeId, FormatterRunner> = {\n cpf: (value) => formatCpf(value),\n cnpj: (value) => formatCnpj(value),\n cep: (value) => formatCep(value),\n telefone: (value) => formatTelefone(value),\n pix: runPixFormat,\n 'inscricao-estadual': runIeFormat,\n};\n\nexport function runBrValidator(\n typeId: BrValidatorV1TypeId,\n value: string,\n context: ValidatorContext,\n): ValidatorOutcome {\n return VALIDATORS[typeId](value, context);\n}\n\nexport function runBrFormatter(\n typeId: BrValidatorV1TypeId,\n value: string,\n context: ValidatorContext,\n): FormatResult {\n return FORMATTERS[typeId](value, context);\n}\n","import { runBrFormatter, runBrValidator } from './validator-registry.js';\nimport type { BrValidatorEvaluation, BrValidatorV1TypeId, ValidatorContext } from './types.js';\n\nexport function isEmptyBrValue(value: string): boolean {\n return value.trim() === '';\n}\n\nexport function evaluateBrValidator(\n typeId: BrValidatorV1TypeId,\n value: string,\n context: ValidatorContext,\n): BrValidatorEvaluation {\n if (isEmptyBrValue(value)) {\n return { isValid: false, error: null, formatted: null };\n }\n\n const validation = runBrValidator(typeId, value, context);\n if (!validation.ok) {\n return { isValid: false, error: validation.message, formatted: null };\n }\n\n const formatted = runBrFormatter(typeId, value, context);\n if (!formatted.ok) {\n return { isValid: false, error: formatted.message, formatted: null };\n }\n\n return { isValid: true, error: null, formatted: formatted.formatted };\n}\n","import { computed, ref, toValue } from 'vue';\nimport { evaluateBrValidator } from './evaluate.js';\nimport type {\n BrValidatorV1TypeId,\n UseBrValidatorOptions,\n UseBrValidatorReturn,\n ValidatorContext,\n} from './types.js';\n\nfunction resolveContext(options: UseBrValidatorOptions): ValidatorContext {\n return {\n uf: options.uf !== undefined ? toValue(options.uf) : undefined,\n pixType: options.pixType !== undefined ? toValue(options.pixType) : undefined,\n };\n}\n\nexport function useBrValidator(\n typeId: BrValidatorV1TypeId,\n options: UseBrValidatorOptions = {},\n): UseBrValidatorReturn {\n const value = ref(options.initialValue ?? '');\n\n const context = computed(() => resolveContext(options));\n const evaluation = computed(() => evaluateBrValidator(typeId, value.value, context.value));\n\n const isValid = computed(() => evaluation.value.isValid);\n const error = computed(() => evaluation.value.error);\n const formatted = computed(() => evaluation.value.formatted);\n\n const validate = (): boolean => evaluation.value.isValid;\n\n return { value, isValid, error, formatted, validate };\n}\n"]}
@@ -0,0 +1,10 @@
1
+ import { useBrValidator } from './chunk-35WUWOHK.js';
2
+
3
+ // src/cnpj.ts
4
+ function useCnpj(options) {
5
+ return useBrValidator("cnpj", options);
6
+ }
7
+
8
+ export { useCnpj };
9
+ //# sourceMappingURL=chunk-73XHZZMR.js.map
10
+ //# sourceMappingURL=chunk-73XHZZMR.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/cnpj.ts"],"names":[],"mappings":";;;AAGO,SAAS,QAAQ,OAAA,EAA+E;AACrG,EAAA,OAAO,cAAA,CAAe,QAAQ,OAAO,CAAA;AACvC","file":"chunk-73XHZZMR.js","sourcesContent":["import type { UseBrValidatorOptions, UseBrValidatorReturn } from './types.js';\nimport { useBrValidator } from './use-br-validator.js';\n\nexport function useCnpj(options?: Omit<UseBrValidatorOptions, 'uf' | 'pixType'>): UseBrValidatorReturn {\n return useBrValidator('cnpj', options);\n}\n"]}
@@ -0,0 +1,10 @@
1
+ import { useBrValidator } from './chunk-35WUWOHK.js';
2
+
3
+ // src/cep.ts
4
+ function useCep(options) {
5
+ return useBrValidator("cep", options);
6
+ }
7
+
8
+ export { useCep };
9
+ //# sourceMappingURL=chunk-AQCUZB5O.js.map
10
+ //# sourceMappingURL=chunk-AQCUZB5O.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/cep.ts"],"names":[],"mappings":";;;AAGO,SAAS,OAAO,OAAA,EAA+E;AACpG,EAAA,OAAO,cAAA,CAAe,OAAO,OAAO,CAAA;AACtC","file":"chunk-AQCUZB5O.js","sourcesContent":["import type { UseBrValidatorOptions, UseBrValidatorReturn } from './types.js';\nimport { useBrValidator } from './use-br-validator.js';\n\nexport function useCep(options?: Omit<UseBrValidatorOptions, 'uf' | 'pixType'>): UseBrValidatorReturn {\n return useBrValidator('cep', options);\n}\n"]}
@@ -0,0 +1,10 @@
1
+ import { useBrValidator } from './chunk-35WUWOHK.js';
2
+
3
+ // src/inscricao-estadual.ts
4
+ function useInscricaoEstadual(options) {
5
+ return useBrValidator("inscricao-estadual", options);
6
+ }
7
+
8
+ export { useInscricaoEstadual };
9
+ //# sourceMappingURL=chunk-CA2VRLDK.js.map
10
+ //# sourceMappingURL=chunk-CA2VRLDK.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/inscricao-estadual.ts"],"names":[],"mappings":";;;AASO,SAAS,qBAAqB,OAAA,EAA4D;AAC/F,EAAA,OAAO,cAAA,CAAe,sBAAsB,OAAO,CAAA;AACrD","file":"chunk-CA2VRLDK.js","sourcesContent":["import type { UfCode } from '@br-validators/core';\nimport type { MaybeRef } from 'vue';\nimport type { UseBrValidatorOptions, UseBrValidatorReturn } from './types.js';\nimport { useBrValidator } from './use-br-validator.js';\n\nexport type UseInscricaoEstadualOptions = Omit<UseBrValidatorOptions, 'pixType'> & {\n uf: MaybeRef<UfCode>;\n};\n\nexport function useInscricaoEstadual(options: UseInscricaoEstadualOptions): UseBrValidatorReturn {\n return useBrValidator('inscricao-estadual', options);\n}\n\nexport type { UfCode };\n"]}
@@ -0,0 +1,10 @@
1
+ import { useBrValidator } from './chunk-35WUWOHK.js';
2
+
3
+ // src/cpf.ts
4
+ function useCpf(options) {
5
+ return useBrValidator("cpf", options);
6
+ }
7
+
8
+ export { useCpf };
9
+ //# sourceMappingURL=chunk-CI4R5DEO.js.map
10
+ //# sourceMappingURL=chunk-CI4R5DEO.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/cpf.ts"],"names":[],"mappings":";;;AAGO,SAAS,OAAO,OAAA,EAA+E;AACpG,EAAA,OAAO,cAAA,CAAe,OAAO,OAAO,CAAA;AACtC","file":"chunk-CI4R5DEO.js","sourcesContent":["import type { UseBrValidatorOptions, UseBrValidatorReturn } from './types.js';\nimport { useBrValidator } from './use-br-validator.js';\n\nexport function useCpf(options?: Omit<UseBrValidatorOptions, 'uf' | 'pixType'>): UseBrValidatorReturn {\n return useBrValidator('cpf', options);\n}\n"]}
@@ -0,0 +1,10 @@
1
+ import { useBrValidator } from './chunk-35WUWOHK.js';
2
+
3
+ // src/pix.ts
4
+ function usePix(options) {
5
+ return useBrValidator("pix", options);
6
+ }
7
+
8
+ export { usePix };
9
+ //# sourceMappingURL=chunk-DEZXHKVO.js.map
10
+ //# sourceMappingURL=chunk-DEZXHKVO.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/pix.ts"],"names":[],"mappings":";;;AAGO,SAAS,OAAO,OAAA,EAAmE;AACxF,EAAA,OAAO,cAAA,CAAe,OAAO,OAAO,CAAA;AACtC","file":"chunk-DEZXHKVO.js","sourcesContent":["import type { UseBrValidatorOptions, UseBrValidatorReturn } from './types.js';\nimport { useBrValidator } from './use-br-validator.js';\n\nexport function usePix(options?: Omit<UseBrValidatorOptions, 'uf'>): UseBrValidatorReturn {\n return useBrValidator('pix', options);\n}\n"]}
@@ -0,0 +1,10 @@
1
+ import { useBrValidator } from './chunk-35WUWOHK.js';
2
+
3
+ // src/telefone.ts
4
+ function useTelefone(options) {
5
+ return useBrValidator("telefone", options);
6
+ }
7
+
8
+ export { useTelefone };
9
+ //# sourceMappingURL=chunk-RGJT7GFY.js.map
10
+ //# sourceMappingURL=chunk-RGJT7GFY.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/telefone.ts"],"names":[],"mappings":";;;AAGO,SAAS,YAAY,OAAA,EAA+E;AACzG,EAAA,OAAO,cAAA,CAAe,YAAY,OAAO,CAAA;AAC3C","file":"chunk-RGJT7GFY.js","sourcesContent":["import type { UseBrValidatorOptions, UseBrValidatorReturn } from './types.js';\nimport { useBrValidator } from './use-br-validator.js';\n\nexport function useTelefone(options?: Omit<UseBrValidatorOptions, 'uf' | 'pixType'>): UseBrValidatorReturn {\n return useBrValidator('telefone', options);\n}\n"]}
package/dist/cnpj.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ import { U as UseBrValidatorOptions, a as UseBrValidatorReturn } from './types-DNxSWfie.js';
2
+ import 'vue';
3
+ import '@br-validators/core';
4
+
5
+ declare function useCnpj(options?: Omit<UseBrValidatorOptions, 'uf' | 'pixType'>): UseBrValidatorReturn;
6
+
7
+ export { useCnpj };
package/dist/cnpj.js ADDED
@@ -0,0 +1,4 @@
1
+ export { useCnpj } from './chunk-73XHZZMR.js';
2
+ import './chunk-35WUWOHK.js';
3
+ //# sourceMappingURL=cnpj.js.map
4
+ //# sourceMappingURL=cnpj.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"cnpj.js"}
package/dist/cpf.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ import { U as UseBrValidatorOptions, a as UseBrValidatorReturn } from './types-DNxSWfie.js';
2
+ import 'vue';
3
+ import '@br-validators/core';
4
+
5
+ declare function useCpf(options?: Omit<UseBrValidatorOptions, 'uf' | 'pixType'>): UseBrValidatorReturn;
6
+
7
+ export { useCpf };
package/dist/cpf.js ADDED
@@ -0,0 +1,4 @@
1
+ export { useCpf } from './chunk-CI4R5DEO.js';
2
+ import './chunk-35WUWOHK.js';
3
+ //# sourceMappingURL=cpf.js.map
4
+ //# sourceMappingURL=cpf.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"cpf.js"}
@@ -0,0 +1,27 @@
1
+ import { B as BrValidatorV1TypeId, U as UseBrValidatorOptions, a as UseBrValidatorReturn, V as ValidatorContext, b as BrValidatorEvaluation } from './types-DNxSWfie.js';
2
+ export { c as BR_VALIDATOR_V1_TYPE_IDS, i as isBrValidatorV1TypeId } from './types-DNxSWfie.js';
3
+ export { useCpf } from './cpf.js';
4
+ export { useCnpj } from './cnpj.js';
5
+ export { useCep } from './cep.js';
6
+ export { useTelefone } from './telefone.js';
7
+ export { usePix } from './pix.js';
8
+ export { UseInscricaoEstadualOptions, useInscricaoEstadual } from './inscricao-estadual.js';
9
+ import { FormatResult, ValidationErrorCode } from '@br-validators/core';
10
+ import 'vue';
11
+
12
+ declare function useBrValidator(typeId: BrValidatorV1TypeId, options?: UseBrValidatorOptions): UseBrValidatorReturn;
13
+
14
+ declare function isEmptyBrValue(value: string): boolean;
15
+ declare function evaluateBrValidator(typeId: BrValidatorV1TypeId, value: string, context: ValidatorContext): BrValidatorEvaluation;
16
+
17
+ type ValidatorOutcome = {
18
+ ok: true;
19
+ } | {
20
+ ok: false;
21
+ code: ValidationErrorCode;
22
+ message: string;
23
+ };
24
+ declare function runBrValidator(typeId: BrValidatorV1TypeId, value: string, context: ValidatorContext): ValidatorOutcome;
25
+ declare function runBrFormatter(typeId: BrValidatorV1TypeId, value: string, context: ValidatorContext): FormatResult;
26
+
27
+ export { BrValidatorEvaluation, BrValidatorV1TypeId, UseBrValidatorOptions, UseBrValidatorReturn, ValidatorContext, evaluateBrValidator, isEmptyBrValue, runBrFormatter, runBrValidator, useBrValidator };
package/dist/index.js ADDED
@@ -0,0 +1,24 @@
1
+ export { useCep } from './chunk-AQCUZB5O.js';
2
+ export { useCnpj } from './chunk-73XHZZMR.js';
3
+ export { useCpf } from './chunk-CI4R5DEO.js';
4
+ export { useInscricaoEstadual } from './chunk-CA2VRLDK.js';
5
+ export { usePix } from './chunk-DEZXHKVO.js';
6
+ export { useTelefone } from './chunk-RGJT7GFY.js';
7
+ export { evaluateBrValidator, isEmptyBrValue, runBrFormatter, runBrValidator, useBrValidator } from './chunk-35WUWOHK.js';
8
+
9
+ // src/types.ts
10
+ var BR_VALIDATOR_V1_TYPE_IDS = [
11
+ "cpf",
12
+ "cnpj",
13
+ "cep",
14
+ "telefone",
15
+ "pix",
16
+ "inscricao-estadual"
17
+ ];
18
+ function isBrValidatorV1TypeId(value) {
19
+ return BR_VALIDATOR_V1_TYPE_IDS.includes(value);
20
+ }
21
+
22
+ export { BR_VALIDATOR_V1_TYPE_IDS, isBrValidatorV1TypeId };
23
+ //# sourceMappingURL=index.js.map
24
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/types.ts"],"names":[],"mappings":";;;;;;;;;AAYO,IAAM,wBAAA,GAA2B;AAAA,EACtC,KAAA;AAAA,EACA,MAAA;AAAA,EACA,KAAA;AAAA,EACA,UAAA;AAAA,EACA,KAAA;AAAA,EACA;AACF;AA6BO,SAAS,sBAAsB,KAAA,EAA6C;AACjF,EAAA,OAAQ,wBAAA,CAA+C,SAAS,KAAK,CAAA;AACvE","file":"index.js","sourcesContent":["import type { PixKeyType, UfCode } from '@br-validators/core';\nimport type { MaybeRef } from 'vue';\n\n/** Document types supported by `useBrValidator()` v1. */\nexport type BrValidatorV1TypeId =\n | 'cpf'\n | 'cnpj'\n | 'cep'\n | 'telefone'\n | 'pix'\n | 'inscricao-estadual';\n\nexport const BR_VALIDATOR_V1_TYPE_IDS = [\n 'cpf',\n 'cnpj',\n 'cep',\n 'telefone',\n 'pix',\n 'inscricao-estadual',\n] as const satisfies readonly BrValidatorV1TypeId[];\n\nexport type ValidatorContext = {\n uf?: UfCode;\n pixType?: PixKeyType;\n};\n\nexport type UseBrValidatorOptions = {\n initialValue?: string;\n /** Required for `inscricao-estadual`. Accepts a ref for reactive UF changes. */\n uf?: MaybeRef<UfCode | undefined>;\n /** Optional PIX key type constraint for `pix`. */\n pixType?: MaybeRef<PixKeyType | undefined>;\n};\n\nexport type BrValidatorEvaluation = {\n isValid: boolean;\n error: string | null;\n formatted: string | null;\n};\n\nexport type UseBrValidatorReturn = {\n value: import('vue').Ref<string>;\n isValid: import('vue').ComputedRef<boolean>;\n error: import('vue').ComputedRef<string | null>;\n formatted: import('vue').ComputedRef<string | null>;\n validate: () => boolean;\n};\n\nexport function isBrValidatorV1TypeId(value: string): value is BrValidatorV1TypeId {\n return (BR_VALIDATOR_V1_TYPE_IDS as readonly string[]).includes(value);\n}\n"]}
@@ -0,0 +1,11 @@
1
+ import { UfCode } from '@br-validators/core';
2
+ export { UfCode } from '@br-validators/core';
3
+ import { MaybeRef } from 'vue';
4
+ import { U as UseBrValidatorOptions, a as UseBrValidatorReturn } from './types-DNxSWfie.js';
5
+
6
+ type UseInscricaoEstadualOptions = Omit<UseBrValidatorOptions, 'pixType'> & {
7
+ uf: MaybeRef<UfCode>;
8
+ };
9
+ declare function useInscricaoEstadual(options: UseInscricaoEstadualOptions): UseBrValidatorReturn;
10
+
11
+ export { type UseInscricaoEstadualOptions, useInscricaoEstadual };
@@ -0,0 +1,4 @@
1
+ export { useInscricaoEstadual } from './chunk-CA2VRLDK.js';
2
+ import './chunk-35WUWOHK.js';
3
+ //# sourceMappingURL=inscricao-estadual.js.map
4
+ //# sourceMappingURL=inscricao-estadual.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"inscricao-estadual.js"}
package/dist/pix.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ import { U as UseBrValidatorOptions, a as UseBrValidatorReturn } from './types-DNxSWfie.js';
2
+ import 'vue';
3
+ import '@br-validators/core';
4
+
5
+ declare function usePix(options?: Omit<UseBrValidatorOptions, 'uf'>): UseBrValidatorReturn;
6
+
7
+ export { usePix };
package/dist/pix.js ADDED
@@ -0,0 +1,4 @@
1
+ export { usePix } from './chunk-DEZXHKVO.js';
2
+ import './chunk-35WUWOHK.js';
3
+ //# sourceMappingURL=pix.js.map
4
+ //# sourceMappingURL=pix.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"pix.js"}
@@ -0,0 +1,7 @@
1
+ import { U as UseBrValidatorOptions, a as UseBrValidatorReturn } from './types-DNxSWfie.js';
2
+ import 'vue';
3
+ import '@br-validators/core';
4
+
5
+ declare function useTelefone(options?: Omit<UseBrValidatorOptions, 'uf' | 'pixType'>): UseBrValidatorReturn;
6
+
7
+ export { useTelefone };
@@ -0,0 +1,4 @@
1
+ export { useTelefone } from './chunk-RGJT7GFY.js';
2
+ import './chunk-35WUWOHK.js';
3
+ //# sourceMappingURL=telefone.js.map
4
+ //# sourceMappingURL=telefone.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"telefone.js"}
@@ -0,0 +1,33 @@
1
+ import * as vue from 'vue';
2
+ import { MaybeRef } from 'vue';
3
+ import { UfCode, PixKeyType } from '@br-validators/core';
4
+
5
+ /** Document types supported by `useBrValidator()` v1. */
6
+ type BrValidatorV1TypeId = 'cpf' | 'cnpj' | 'cep' | 'telefone' | 'pix' | 'inscricao-estadual';
7
+ declare const BR_VALIDATOR_V1_TYPE_IDS: readonly ["cpf", "cnpj", "cep", "telefone", "pix", "inscricao-estadual"];
8
+ type ValidatorContext = {
9
+ uf?: UfCode;
10
+ pixType?: PixKeyType;
11
+ };
12
+ type UseBrValidatorOptions = {
13
+ initialValue?: string;
14
+ /** Required for `inscricao-estadual`. Accepts a ref for reactive UF changes. */
15
+ uf?: MaybeRef<UfCode | undefined>;
16
+ /** Optional PIX key type constraint for `pix`. */
17
+ pixType?: MaybeRef<PixKeyType | undefined>;
18
+ };
19
+ type BrValidatorEvaluation = {
20
+ isValid: boolean;
21
+ error: string | null;
22
+ formatted: string | null;
23
+ };
24
+ type UseBrValidatorReturn = {
25
+ value: vue.Ref<string>;
26
+ isValid: vue.ComputedRef<boolean>;
27
+ error: vue.ComputedRef<string | null>;
28
+ formatted: vue.ComputedRef<string | null>;
29
+ validate: () => boolean;
30
+ };
31
+ declare function isBrValidatorV1TypeId(value: string): value is BrValidatorV1TypeId;
32
+
33
+ export { type BrValidatorV1TypeId as B, type UseBrValidatorOptions as U, type ValidatorContext as V, type UseBrValidatorReturn as a, type BrValidatorEvaluation as b, BR_VALIDATOR_V1_TYPE_IDS as c, isBrValidatorV1TypeId as i };
package/package.json ADDED
@@ -0,0 +1,90 @@
1
+ {
2
+ "name": "@br-validators/vue",
3
+ "version": "1.6.0",
4
+ "description": "Vue 3 composables for Brazilian document validators — delegates to @br-validators/core",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/AlexandreZanata/br-validators.git",
10
+ "directory": "packages/br-validators-vue"
11
+ },
12
+ "homepage": "https://github.com/AlexandreZanata/br-validators/tree/main/packages/br-validators-vue#readme",
13
+ "bugs": {
14
+ "url": "https://github.com/AlexandreZanata/br-validators/issues"
15
+ },
16
+ "keywords": [
17
+ "brazil",
18
+ "vue",
19
+ "composable",
20
+ "validator",
21
+ "cpf",
22
+ "cnpj",
23
+ "cep"
24
+ ],
25
+ "publishConfig": {
26
+ "access": "public",
27
+ "tag": "alpha"
28
+ },
29
+ "main": "./dist/index.js",
30
+ "types": "./dist/index.d.ts",
31
+ "exports": {
32
+ ".": {
33
+ "types": "./dist/index.d.ts",
34
+ "import": "./dist/index.js"
35
+ },
36
+ "./cpf": {
37
+ "types": "./dist/cpf.d.ts",
38
+ "import": "./dist/cpf.js"
39
+ },
40
+ "./cnpj": {
41
+ "types": "./dist/cnpj.d.ts",
42
+ "import": "./dist/cnpj.js"
43
+ },
44
+ "./cep": {
45
+ "types": "./dist/cep.d.ts",
46
+ "import": "./dist/cep.js"
47
+ },
48
+ "./telefone": {
49
+ "types": "./dist/telefone.d.ts",
50
+ "import": "./dist/telefone.js"
51
+ },
52
+ "./pix": {
53
+ "types": "./dist/pix.d.ts",
54
+ "import": "./dist/pix.js"
55
+ },
56
+ "./inscricao-estadual": {
57
+ "types": "./dist/inscricao-estadual.d.ts",
58
+ "import": "./dist/inscricao-estadual.js"
59
+ }
60
+ },
61
+ "files": [
62
+ "dist",
63
+ "README.md"
64
+ ],
65
+ "peerDependencies": {
66
+ "vue": "^3.5.0",
67
+ "@br-validators/core": "1.6.0"
68
+ },
69
+ "dependencies": {
70
+ "@br-validators/core": "1.6.0"
71
+ },
72
+ "devDependencies": {
73
+ "@types/node": "^22.15.21",
74
+ "@vitest/coverage-v8": "^3.2.4",
75
+ "tsup": "^8.5.0",
76
+ "typescript": "^5.8.3",
77
+ "vitest": "^3.2.4",
78
+ "vue": "^3.5.17"
79
+ },
80
+ "scripts": {
81
+ "build": "tsup",
82
+ "pretypecheck": "pnpm --filter @br-validators/core build",
83
+ "pretest": "pnpm --filter @br-validators/core build",
84
+ "pretest:coverage": "pnpm --filter @br-validators/core build",
85
+ "test": "vitest run",
86
+ "test:coverage": "vitest run --coverage",
87
+ "typecheck": "tsc --noEmit",
88
+ "lint": "eslint src tests --max-warnings 0"
89
+ }
90
+ }