🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

joi-extension-semver

Package Overview
Dependencies
Maintainers
1
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

2.0.0
Source
npm
Version published
Weekly downloads
8.8K
2.4%
Maintainers
1
Weekly downloads
 
Created
Source

joi-extension-semver

Build Status

Semver extension for the Joi validation library

Usage


var joi = require('joi')
  .extend(require('joi-extension-semver'));

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. Does not perform any validation in itself. The reason for this is that it is possible to continue with semver.validRange() in which case the expected value should be a range instead of a version.

semver.valid()

Validates that the value is a semver version.

semver.gt(exp)

semver.gte(exp)

semver.lt(exp)

semver.lte(exp)

semver.eq(exp)

semver.neq(exp)

semver.cmp(cmp, exp)

semver.validRange()

Validates that the value is a semver range.

semver.satisfies(rng)

semver.gtr(rng)

semver.ltr(rng)

semver.outside(hilo, rng)

Keywords

semver

FAQs

Package last updated on 27 Jan 2017

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