View Source Flamel.Ecto.Validators (flamel v1.10.0)
Some validation functions for Ecto
Summary
Functions
A validate function that checks to see at least one of the fields is not blank
A validate function that requires a field have a value if a condition is met
Functions
@spec validate_at_least_one_required(Ecto.Changeset.t(), [atom()], binary()) :: Ecto.Changeset.t()
A validate function that checks to see at least one of the fields is not blank
Example
iex> Flamel.Ecto.Validators.validate_at_least_one_required(changeset, [:phone, :email], "either phone or email is required")
@spec validate_required_if(Ecto.Changeset.t(), atom(), function(), keyword()) :: Ecto.Changeset.t()
A validate function that requires a field have a value if a condition is met
Example
iex> Flamel.Ecto.Validators.validate_required_if(changeset, :confirm, fn _changeset -> true end) "confirm is required")