# `Cucumber.ParameterTypes`
[🔗](https://github.com/huddlz-hq/cucumber/blob/main/lib/cucumber/parameter_types.ex#L1)

Defines custom parameter types for use in cucumber expressions.

Custom parameter types let step patterns use domain vocabulary like
`{flight}` with automatic transformation into domain values. Define them in
a support file (loaded before step definitions):

    # test/features/support/parameter_types.exs
    defmodule MyApp.ParameterTypes do
      use Cucumber.ParameterTypes

      parameter_type :flight,
        regexp: ~r/([A-Z]{3})-([A-Z]{3})/,
        transform: fn from, to -> %{from: from, to: to} end

      parameter_type :color, regexp: ~r/red|blue|green/
    end

Then use them in step definitions like any built-in type:

    step "{flight} has been delayed", %{args: [flight]} do
      # flight is %{from: "LHR", to: "CDG"}
    end

## Options

  * `:regexp` (required) - the regex a value must match. It is matched
    against the step text at the parameter's position.
  * `:transform` (optional) - a function converting the matched text into
    a value. With no capture groups in the regexp, it receives the full
    match; with capture groups, it receives one argument per group (`nil`
    for unmatched optional groups). Without a transform, the parameter
    yields the full matched string.

Names must consist of lowercase letters and underscores, and cannot shadow
the built-in types (`string`, `int`, `float`, `word`, `atom`).

# `parameter_type`
*macro* 

Registers a custom parameter type. See the module documentation.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
