Skip to main content

Semantic Version

FunctionDescriptionMeta
semver.compare

result := semver.compare(a, b)

Compares valid SemVer formatted version strings.

Arguments:
a (string)

first version string

b (string)

second version string

Returns:
result (number)

-1 if a < b; 1 if a > b; 0 if a == b

v0.22.0 SDK-dependent
semver.is_valid

result := semver.is_valid(vsn)

Validates that the input is a valid SemVer string.

Arguments:
vsn (any)

input to validate

Returns:
result (boolean)

true if vsn is a valid SemVer; false otherwise

v0.22.0 SDK-dependent
Example of semver.is_valid

The result := semver.is_valid(vsn) function checks to see if a version string is of the form: MAJOR.MINOR.PATCH[-PRERELEASE][+METADATA], where items in square braces are optional elements.

warning

When working with Go-style semantic versions, remember to remove the leading v character, or the semver string will be marked as invalid!

data.json
"{}"
input.json
"{}"
package semverisvalid

leadingV := semver.is_valid("v1.1.12-rc1+foo")

valid := semver.is_valid("1.1.12-rc1+foo")