node-semver icon indicating copy to clipboard operation
node-semver copied to clipboard

[FEATURE] Function to check for validity of a prerelease identifier

Open boxcee opened this issue 5 years ago • 1 comments

What / Why

Problem described in #349: An 'invalid' identifier will lead to an invalid semver. Now, there is no way to check beforehand whether an identifier is valid, except doing this:

const isValidIdentifier(identifier) => !!valid(inc(parse('0.0.1'), 'prerelease', identifier));

This is a request for a more straight-forward function, e.g. identifier(), which returns null (or false) if the identifier is invalid.

References

  • Related to #349

boxcee avatar Nov 11 '20 09:11 boxcee

#754 adds a check to inc. Do we need a new function when you can just look up the spec to see what's valid for a pre-release?

Or get the regex for it from semver:

semver.src[semver.tokens.PRERELEASE]
semver.src[semver.tokens.PRERELEASEIDENTIFIER]

mbtools avatar Jan 21 '25 20:01 mbtools