Skip to content
This repository has been archived by the owner on Nov 11, 2024. It is now read-only.

alloc/zod-file

Repository files navigation

zod-file

npm Code style: Prettier Donate

Binary and base64 validators

 

Usage

Extend zod with a custom module, like src/zod.ts in your project:

export * from 'zod'
export * from 'zod-file'

Use it in your schema:

import * as z from './zod'

const User = z.object({
  avatar: z.base64(),
})

const parsedUser = User.parse({
  // Pass a buffer or a base64 string.
  avatar: fs.readFileSync('avatar.png'),
})

// Receive a base64 string.
const base64Avatar = parsedUser.avatar

// Invalid base64 strings will throw.
User.parse({
  avatar: 'not base64',
})

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published