Funx.Validator.In (funx v0.8.0)

View Source

Validates that a value is a member of a given collection using an Eq comparator.

In enforces a membership constraint of the form: "value must be one of these".

Membership is defined by an Eq instance, not by structural equality or Elixir's in operator.

Options

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

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

  • :message (optional) A custom error message callback (value -> String.t()).

Semantics

  • Succeeds if the value equals any element in :values under Eq, or if the value is a struct whose module is listed in :values.
  • Fails otherwise.
  • Nothing passes through.
  • Just is unwrapped before comparison.

Summary

Functions

validate(value)

validate(value, opts)