Skip to content

[semver] allows invalid version number 1.0.0-beta..1, not allowed by semver.org suggested regex #21383

@o-l-a-v

Description

@o-l-a-v

Prerequisites

Steps to reproduce

Here are some examples of invalid semantic versioning version numbers that are not valid by semver.org suggested regex:

## Should work
[semver]'1'
[semver]'1.0.0'
[semver]'1.0.0-beta'
[semver]'1.0.0-beta1'
[semver]'1.0.0-beta.1'

## Should error but doesn't
[semver]'1.0.0-beta..1'
[semver]'1.0.0-beta...1'

## Should error and does
[semver]'1.0.0-beta!1'

This tells me [semver] isn't fully compliant with semantic versioning v2.0.0.

Additional search tags:

  • SemanticVersion, [SemanticVersion]
  • System.Management.Automation.SemanticVersion, [System.Management.Automation.SemanticVersion]

Expected behavior

Follow semver specification. Throw an error on non-valid version numbers. Like with [semver]'1.0.0-beta!1' which gives:

InvalidArgument: Cannot convert value "1.0.0-beta!1" to type "System.Management.Automation.SemanticVersion". Error: "The input string '' was not in a correct format."

Actual behavior

PS > [semver]'1.0.0-beta...1'

Major  Minor  Patch  PreReleaseLabel BuildLabel
-----  -----  -----  --------------- ----------
1      0      0      beta...1

PS >

Error details

No response

Environment data

  • PowerShell v7.4.1 x64
  • Windows 11 23H2 x64

Visuals

No response

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions