Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

zod-br-tax-id

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zod-br-tax-id - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

6

CHANGELOG.md
# zod-br-tax-id
## 1.0.1
### Patch Changes
- 4190f72: update .npmignore and README
## 1.0.0

@@ -4,0 +10,0 @@

2

package.json
{
"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 |
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc