isValidVersion

Validates a version string according to the SemVer specification.

@safe pure @nogc
bool
isValidVersion
(
string ver
)

Examples

assert(isValidVersion("1.9.0"));
assert(isValidVersion("0.10.0"));
assert(!isValidVersion("01.9.0"));
assert(!isValidVersion("1.09.0"));
assert(!isValidVersion("1.9.00"));
assert(isValidVersion("1.0.0-alpha"));
assert(isValidVersion("1.0.0-alpha.1"));
assert(isValidVersion("1.0.0-0.3.7"));
assert(isValidVersion("1.0.0-x.7.z.92"));
assert(isValidVersion("1.0.0-x.7-z.92"));
assert(!isValidVersion("1.0.0-00.3.7"));
assert(!isValidVersion("1.0.0-0.03.7"));
assert(isValidVersion("1.0.0-alpha+001"));
assert(isValidVersion("1.0.0+20130313144700"));
assert(isValidVersion("1.0.0-beta+exp.sha.5114f85"));
assert(!isValidVersion(" 1.0.0"));
assert(!isValidVersion("1. 0.0"));
assert(!isValidVersion("1.0 .0"));
assert(!isValidVersion("1.0.0 "));
assert(!isValidVersion("1.0.0-a_b"));
assert(!isValidVersion("1.0.0+"));
assert(!isValidVersion("1.0.0-"));
assert(!isValidVersion("1.0.0-+a"));
assert(!isValidVersion("1.0.0-a+"));
assert(!isValidVersion("1.0"));
assert(!isValidVersion("1.0-1.0"));

Meta