Funx.Validator.In (funx v0.8.0)
View SourceValidates 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 toFunx.Eq.Protocol.:message(optional) A custom error message callback(value -> String.t()).
Semantics
- Succeeds if the value equals any element in
:valuesunderEq, or if the value is a struct whose module is listed in:values. - Fails otherwise.
Nothingpasses through.Justis unwrapped before comparison.