Funx.Validator.Contains (funx v0.8.4)

View Source

Validates that a collection contains a specific element using an Eq comparator.

Contains enforces a membership constraint of the form: "collection must contain X".

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

Options

  • :value (required) The element that must be present in the collection.

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

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

Semantics

  • Succeeds if the collection is a list and contains the element under Eq.
  • Fails if the collection does not contain the element or is not a list.
  • Nothing values pass unchanged.
  • Just values are unwrapped before validation.

Summary

Functions

validate(value)

validate(value, opts)