zod-br-tax-id
Advanced tools
Comparing version 1.0.0 to 1.0.1
# zod-br-tax-id | ||
## 1.0.1 | ||
### Patch Changes | ||
- 4190f72: update .npmignore and README | ||
## 1.0.0 | ||
@@ -4,0 +10,0 @@ |
{ | ||
"name": "zod-br-tax-id", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Zod Custom Objects for Brazilian Tax Ids", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
# Zod Brazilian Tax Ids | ||
[![npm version](https://badge.fury.io/js/zod-br-tax-id.svg)](https://badge.fury.io/js/zod-br-tax-id) | ||
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) | ||
## Installation | ||
`pnpm add zod-br-tax-id` | ||
`npm i zod-br-tax-id` | ||
`yarn add zod-br-tax-id` | ||
@@ -15,9 +17,9 @@ | ||
```typescript | ||
import { z } from 'zod'; | ||
import { cpf, cnpj } from 'zod-br-tax-id'; | ||
import { z } from "zod"; | ||
import { cpf, cnpj } from "zod-br-tax-id"; | ||
const schema = z.object({ | ||
cpf: cpf(), | ||
cnpj: cnpj({ strict: true, message: 'Invalid CNPJ, only number are allowed' }), | ||
optionalCpf: z.union([z.literal(''), cpf()]), | ||
cnpj: cnpj({ strict: true, message: "Invalid CNPJ, only number are allowed" }), | ||
optionalCpf: z.union([z.literal(""), cpf()]), | ||
undefinedCnpj: z.union([z.undefined(), cnpj()]), | ||
@@ -27,14 +29,13 @@ }); | ||
try { | ||
schema.parse({ | ||
cpf: '123.456.789-00', | ||
cnpj: '12.345.678/0001-00', | ||
optionalCpf: '', | ||
undefinedCnpj: undefined, | ||
}); | ||
} catch (err) { | ||
if (err instanceof z.ZodError) { | ||
console.log(err.issues); | ||
} | ||
schema.parse({ | ||
cpf: "123.456.789-00", | ||
cnpj: "12.345.678/0001-00", | ||
optionalCpf: "", | ||
undefinedCnpj: undefined, | ||
}); | ||
} catch (err) { | ||
if (err instanceof z.ZodError) { | ||
console.log(err.issues); | ||
} | ||
} | ||
``` | ||
@@ -44,5 +45,5 @@ | ||
| Option | Type | Default | Description | | ||
| --- | --- | --- | --- | | ||
| strict | boolean | false | If true, also invalidates masked strings | | ||
| message | string | 'Invalid CPF/CNPJ' | Custom error message | | ||
| Option | Type | Default | Description | | ||
| ------- | ------- | ------------------- | ---------------------------------------- | | ||
| strict | boolean | false | If true, also invalidates masked strings | | ||
| message | string | 'CPF/CNPJ inválido' | Custom error message | |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
47
0
12840
7
283