isSemVer

Validates a version string according to the SemVer specification.

@safe pure @nogc
bool
isSemVer
(
string ver
)

Examples

enum testCTFE = isSemVer("1.0.0");

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

Meta