Version.match-question-mark

You're seeing just the function match-question-mark, go back to Version module for more information.
Link to this function

match?(version, requirement, opts \\ [])

View Source

Specs

match?(version(), requirement(), keyword()) :: boolean()

Checks if the given version matches the specification.

Returns true if version satisfies requirement, false otherwise. Raises a Version.InvalidRequirementError exception if requirement is not parsable, or a Version.InvalidVersionError exception if version is not parsable. If given an already parsed version and requirement this function won't raise.

Options

  • :allow_pre (boolean) - when false, pre-release versions will not match unless the operand is a pre-release version. Defaults to true. For examples, please refer to the table above under the "Requirements" section.

Examples

iex> Version.match?("2.0.0", "> 1.0.0")
true

iex> Version.match?("2.0.0", "== 1.0.0")
false

iex> Version.match?("2.1.6-dev", "~> 2.1.2")
true

iex> Version.match?("2.1.6-dev", "~> 2.1.2", allow_pre: false)
false

iex> Version.match?("foo", "== 1.0.0")
** (Version.InvalidVersionError) invalid version: "foo"

iex> Version.match?("2.0.0", "== == 1.0.0")
** (Version.InvalidRequirementError) invalid requirement: "== == 1.0.0"