Skip to main content
Home

Built and signed on GitHub Actions

A simple deno module by @codemonument with a zod schema for validating semver. Uses official regex. Published to jsr & npm

This package works with Node.js, Deno, Bun, BrowsersIt is unknown whether this package works with Cloudflare Workers
It is unknown whether this package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
76%
Published
2 years ago (1.3.8)

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

Name Target
Git Repo https://github.com/codemonument/deno_zod_semver
JSR https://jsr.io/@codemonument/zod-semver/
NPM https://www.npmjs.com/package/zod-semver

Create new version of this package (for maintainers)

  1. Update CHANGELOG.md with your changes
  2. Run deno task uv <newVersion>
  3. Run deno task test
  4. Commit changes & add git tag for your version
  5. Push changes & tags => github actions will deploy
Built and signed on
GitHub Actions

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@codemonument/zod-semver

Import symbol

import * as zod_semver from "@codemonument/zod-semver";
or

Import directly with a jsr specifier

import * as zod_semver from "jsr:@codemonument/zod-semver";

Add Package

pnpm i jsr:@codemonument/zod-semver
or (using pnpm 10.8 or older)
pnpm dlx jsr add @codemonument/zod-semver

Import symbol

import * as zod_semver from "@codemonument/zod-semver";

Add Package

yarn add jsr:@codemonument/zod-semver
or (using Yarn 4.8 or older)
yarn dlx jsr add @codemonument/zod-semver

Import symbol

import * as zod_semver from "@codemonument/zod-semver";

Add Package

vlt install jsr:@codemonument/zod-semver

Import symbol

import * as zod_semver from "@codemonument/zod-semver";

Add Package

npx jsr add @codemonument/zod-semver

Import symbol

import * as zod_semver from "@codemonument/zod-semver";

Add Package

bunx jsr add @codemonument/zod-semver

Import symbol

import * as zod_semver from "@codemonument/zod-semver";