You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

zod-semver

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zod-semver

A simple deno module by @codemonument with a zod schema for validating semver. Uses official regex and is cross-posted to npm as zod-semver

1.3.8
latest
Source
npm
Version published
Weekly downloads
334
-15.66%
Maintainers
1
Weekly downloads
 
Created
Source

Zod SemVer

JSR NPM Version

A simple deno module by @codemonument with a zod schema for validating semver. Uses official regex.

[!WARNING] Not published to deno.land/x/zod_semver anymore! Use the jsr package instead:
jsr:@codemonument/zod-semver!

Usage

Import in Deno

deno add @codemonument/zod-semver
import {ZodSemver} from '@codemonument/zod-semver';

Import in Node

npm add @codemonument/zod-semver
import {ZodSemver} from 'zod-semver';

Usage after Import

// Use like any other Zod Schema:
ZodSemver.parse('1.0.0');

// Or include in another Zod Schema like this:

const MyObjectSchema = z.object({
	version: ZodSemver,
	name: z.string(),
	age: z.number().optional(),
});

Using the branded ZodSemver type

At it's base, the ZodSemver type is simply a more refined string. So the TS type for it is string. However, sometimes it might be useful for a function to make sure that it only receives an already parsed semver string. This is possible via the branded ZodSemver type.

'branded' means that the type is a string, but with a special property atached that makes it unique. See the zod docs for more information: https://zod.dev/?id=brand

NameTarget
Git Repohttps://github.com/codemonument/deno_zod_semver
JSRhttps://jsr.io/@codemonument/zod-semver/
NPMhttps://www.npmjs.com/package/zod-semver

Create new version of this package (for maintainers)

  • Update CHANGELOG.md with your changes
  • Run deno task uv <newVersion>
  • Run deno task test
  • Commit changes & add git tag for your version
  • Push changes & tags => github actions will deploy

FAQs

Package last updated on 31 Mar 2024

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