Funx.Predicate.In (funx v0.8.4)

View Source

Predicate that checks if a value is a member of a given collection using an Eq comparator.

Options

  • :values (required) The list of allowed values to compare against.

  • :eq (optional) An equality comparator. Defaults to Funx.Eq.Protocol.

Examples

use Funx.Predicate

# Check if status is one of allowed values
pred do
  check :status, {In, values: [:active, :pending, :completed]}
end

# Check if struct type is in list
pred do
  check :event, {In, values: [Click, Scroll, Submit]}
end

# With custom Eq comparator
pred do
  check :item, {In, values: allowed_items, eq: Item.Eq}
end