Skip to main content

VersionReq

SemVer version requirement describing the intersection of some version comparators, such as >=1.2.3, <1.8.

Spec: https://docs.rs/semver/1.0.20/semver/struct.VersionReq.html

Properties

comparators

This item is read only and cannot be modified. Read Only
VersionReq.comparators: {Comparator}

STAR

This item is read only and cannot be modified. Read OnlyStatic
VersionReq.STAR: VersionReq

A VersionReq with no constraint on the version numbers it matches. Equivalent to VersionReq.parse("*").

In terms of comparators this is equivalent to >=0.0.0.

Counterintuitively a * VersionReq does not match every possible version number. In particular, in order for any VersionReq to match a pre-release version, the VersionReq must contain at least one Comparator that has an explicit major, minor, and patch version identical to the pre-release being matched, and that has a nonempty pre-release component. Since * is not written with an explicit major, minor, and patch version, and does not contain a nonempty pre-release component, it does not match any pre-release versions.

Functions

parse

VersionReq.parse(inputstring) → VersionReq

Possible reasons for the parse to fail include:

Errors

TypeDescription
UnexpectedChar (">a.b")unexpected characters in the partial version.
UnexpectedChar ("@1.0.0)unrecognized comparison operator.
UnexpectedEnd ("^1.0.0,")unexpected end of input.
ExpectedCommaFound (">=1.0 <2.0")missing comma between comparators.
UnexpectedAfterWildcard ("*.*")unsupported wildcard syntax.

is

VersionReq.is(objany) → boolean

Returns true if obj is a VersionReq.

matches

VersionReq:matches(verVersion) → boolean

Evaluate whether the given Version satisfies the version requirement described by self.

__tostring

VersionReq:__tostring() → string

This metamethod transforms self into a string.

__eq

VersionReq:__eq(otherVersionReq) → boolean

This metamethod tests for self and other values to be equal and is used by the operators == and ~=.

Show raw api
{
    "functions": [
        {
            "name": "parse",
            "desc": "Possible reasons for the parse to fail include:",
            "params": [
                {
                    "name": "input",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "VersionReq\n"
                }
            ],
            "function_type": "static",
            "errors": [
                {
                    "lua_type": "UnexpectedChar (\">a.b\")",
                    "desc": "unexpected characters in the partial version."
                },
                {
                    "lua_type": "UnexpectedChar (\"@1.0.0)",
                    "desc": "unrecognized comparison operator."
                },
                {
                    "lua_type": "UnexpectedEnd (\"^1.0.0,\")",
                    "desc": "unexpected end of input."
                },
                {
                    "lua_type": "ExpectedCommaFound (\">=1.0 <2.0\")",
                    "desc": "missing comma between comparators."
                },
                {
                    "lua_type": "UnexpectedAfterWildcard (\"*.*\")",
                    "desc": "unsupported wildcard syntax."
                }
            ],
            "source": {
                "line": 56,
                "path": "lib/CargoSemver/src/VersionReq.luau"
            }
        },
        {
            "name": "is",
            "desc": "Returns `true` if `obj` is a [VersionReq].",
            "params": [
                {
                    "name": "obj",
                    "desc": "",
                    "lua_type": "any"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 110,
                "path": "lib/CargoSemver/src/VersionReq.luau"
            }
        },
        {
            "name": "matches",
            "desc": "Evaluate whether the given [Version] satisfies the version requirement described by `self`.",
            "params": [
                {
                    "name": "ver",
                    "desc": "",
                    "lua_type": "Version"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 125,
                "path": "lib/CargoSemver/src/VersionReq.luau"
            }
        },
        {
            "name": "__tostring",
            "desc": "This metamethod transforms `self` into a string.",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 154,
                "path": "lib/CargoSemver/src/VersionReq.luau"
            }
        },
        {
            "name": "__eq",
            "desc": "This metamethod tests for `self` and `other` values to be equal and is used by the operators `==` and `~=`.",
            "params": [
                {
                    "name": "other",
                    "desc": "",
                    "lua_type": "VersionReq"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 172,
                "path": "lib/CargoSemver/src/VersionReq.luau"
            }
        }
    ],
    "properties": [
        {
            "name": "comparators",
            "desc": "",
            "lua_type": "{Comparator}",
            "readonly": true,
            "source": {
                "line": 41,
                "path": "lib/CargoSemver/src/VersionReq.luau"
            }
        },
        {
            "name": "STAR",
            "desc": "A `VersionReq` with no constraint on the version numbers it matches. Equivalent to `VersionReq.parse(\"*\")`.\n\nIn terms of comparators this is equivalent to `>=0.0.0`.\n\nCounterintuitively a `*` VersionReq does not match every possible version number. In particular, in order for *any* `VersionReq` to match a pre-release version, the `VersionReq` must contain at least one [Comparator] that has an explicit major, minor, and patch version identical to the pre-release being matched, and that has a nonempty pre-release component. Since `*` is not written with an explicit major, minor, and patch version, and does not contain a nonempty pre-release component, it does not match any pre-release versions.",
            "lua_type": "VersionReq",
            "tags": [
                "Static"
            ],
            "readonly": true,
            "source": {
                "line": 197,
                "path": "lib/CargoSemver/src/VersionReq.luau"
            }
        }
    ],
    "types": [],
    "name": "VersionReq",
    "desc": "SemVer version requirement describing the intersection of some version comparators, such as `>=1.2.3, <1.8`.\n\nSpec: https://docs.rs/semver/1.0.20/semver/struct.VersionReq.html",
    "source": {
        "line": 36,
        "path": "lib/CargoSemver/src/VersionReq.luau"
    }
}