NPM.validateVersion()

Validate (and potentially coerce) the specified string, verifying that it is compatible for use as an NPM version string.

Usage

Hover over inputs/exits for more info.

var NPM = require('machinepack-npm');


// Validate (and potentially coerce) the specified string, verifying that it is compatible for use as an NPM version string.

NPM.validateVersion({

string: '1.0.0',

strict: false,

}).execSync();

Inputs

string required

The string to validate as a NPM-compatible/semver version string.

'1.0.0'
strict

If set, instead of coercing, the validation will fail as "not strictly valid".

false

Exits

error

An unexpected error occurred.

isEmpty

The specified string is empty (or at least it is after coercion).

tooLong

The specified string is too long (or at least it is after coercion).

invalidSemanticVersion

The specified string is not a valid semver (semantic version).

notStrictlyValid

The specified string is close, but not strictly valid (only relevant if `strict` is enabled).

success

OK.

'1.0.0'