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

joi-extension-semver

Package Overview
Dependencies
Maintainers
2
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

joi-extension-semver

Semver extension for the Joi validation library

  • 5.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
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

Package last updated on 28 Sep 2020

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