Socket
Socket
Sign inDemoInstall

joi-extension-semver

Package Overview
Dependencies
7
Maintainers
2
Versions
13
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    joi-extension-semver

Semver extension for the Joi validation library


Version published
Maintainers
2
Install size
78.4 kB
Created

Changelog

Source

5.0.0

  • BREAKING CHANGE: Require [joi][] >=17.2.0 instead of deprecated [@hapi/joi][].
  • BREAKING CHANGE: Require Node 12+

Readme

Source

joi-extension-semver

version license build

Semver extension for the Joi validation library

Usage

const { semver, semverRange } = require('joi-extension-semver')
const Joi = require('joi')
    .extend(semver)
    .extend(semverRange)

Joi.attempt('1.2.3', Joi.semver().valid()) // '1.2.3'
Joi.attempt('>=1.2.3', Joi.semverRange().valid()) // '>=1.2.3'

Joi.attempt('1.2.3', Joi.semver().gte('1.2.3')) // '1.2.3'
Joi.attempt('1.2.3', Joi.semver().lt('1.2.3')) // throws ValidationError
Joi.attempt('1.2.3', Joi.semver().satisfies('^1.0.0')) // '1.2.3'

Validation chains

See semver documentation. All boolean returning comparisons are supported.

semver

Starts the chain.

semver.valid()

Asserts valid(value).

semver.gt(exp)

Asserts gt(value, exp).

semver.gte(exp)

Asserts gte(value, exp).

semver.lt(exp)

Asserts lt(value, exp).

semver.lte(exp)

Asserts lte(value, exp).

semver.eq(exp)

Asserts eq(value, exp).

semver.neq(exp)

Asserts neq(value, exp).

semver.cmp(comp, exp)

Asserts cmp(value, comp, exp).

semver.satisfies(rng)

Asserts satisfies(value, rng).

semver.gtr(rng)

Asserts gtr(value, rng).

semver.ltr(rng)

Asserts ltr(value, rng).

semver.outside(hilo, rng)

Asserts outside(value, hilo, rng).

semverRange

Starts the chain.

semverRange.valid()

Asserts validRange(value).

Keywords

FAQs

Last updated on 28 Sep 2020

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc