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

zod-metadata

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zod-metadata

Extends Zod with metadata

  • 1.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
14K
increased by8.1%
Maintainers
1
Weekly downloads
 
Created
Source

zod-metadata

Metadata support for Zod schemas.

Install

npm install zod-metadata

Register the Zod extension

Automatic

Import zod-metadata/register at the top of your entry files:

JavaScript

require('zod-metadata/register');

TypeScript

import 'zod-metadata/register';

Manual

JavaScript

const { register } = require('zod-metadata');
const zod = require('zod');

register(zod);

TypeScript

import { register } from 'zod-metadata';
import zod from 'zod';

register(zod);

Preload

JavaScript

node -r zod-metadata/register my-script.js
// my-script.js
require('zod-metadata'); // make type declarations available

TypeScript

ts-node -r zod-metadata/register my-script.js
// my-script.ts
import {} from 'zod-metadata'; // make type declarations available

API

The API provices two methods that will read and write to schema._def.meta.

schema.meta(meta: Record<string, unknown>): this

Accumulates metadata mutating the schema:

schema
  .meta({ key1: value1 })
  .meta({ key2: value2 });

schema.getMeta(): Record<string, unknown>

Returns the metadata:

schema.getMeta(); // => { key1: value1, key2: value2 }

Keywords

FAQs

Package last updated on 11 Mar 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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