isValidVersion

Validates a version string according to the SemVer specification.

@safe
bool
isValidVersion
pure @nogc
(
string ver
)

Examples

1 assert(isValidVersion("1.9.0"));
2 assert(isValidVersion("0.10.0"));
3 assert(!isValidVersion("01.9.0"));
4 assert(!isValidVersion("1.09.0"));
5 assert(!isValidVersion("1.9.00"));
6 assert(isValidVersion("1.0.0-alpha"));
7 assert(isValidVersion("1.0.0-alpha.1"));
8 assert(isValidVersion("1.0.0-0.3.7"));
9 assert(isValidVersion("1.0.0-x.7.z.92"));
10 assert(isValidVersion("1.0.0-x.7-z.92"));
11 assert(!isValidVersion("1.0.0-00.3.7"));
12 assert(!isValidVersion("1.0.0-0.03.7"));
13 assert(isValidVersion("1.0.0-alpha+001"));
14 assert(isValidVersion("1.0.0+20130313144700"));
15 assert(isValidVersion("1.0.0-beta+exp.sha.5114f85"));
16 assert(!isValidVersion(" 1.0.0"));
17 assert(!isValidVersion("1. 0.0"));
18 assert(!isValidVersion("1.0 .0"));
19 assert(!isValidVersion("1.0.0 "));
20 assert(!isValidVersion("1.0.0-a_b"));
21 assert(!isValidVersion("1.0.0+"));
22 assert(!isValidVersion("1.0.0-"));
23 assert(!isValidVersion("1.0.0-+a"));
24 assert(!isValidVersion("1.0.0-a+"));
25 assert(!isValidVersion("1.0"));
26 assert(!isValidVersion("1.0-1.0"));

Meta