utils/node_modules/validator/es/lib/isSemVer.js
2024-02-07 01:33:07 -05:00

14 lines
597 B
JavaScript

import assertString from './util/assertString';
import multilineRegexp from './util/multilineRegex';
/**
* Regular Expression to match
* semantic versioning (SemVer)
* built from multi-line, multi-parts regexp
* Reference: https://semver.org/
*/
var semanticVersioningRegex = multilineRegexp(['^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)', '(?:-((?:0|[1-9]\\d*|\\d*[a-z-][0-9a-z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-z-][0-9a-z-]*))*))', '?(?:\\+([0-9a-z-]+(?:\\.[0-9a-z-]+)*))?$'], 'i');
export default function isSemVer(str) {
assertString(str);
return semanticVersioningRegex.test(str);
}