exiban v0.0.4 ExIban.EctoValidator
Validator for Ecto
Summary
Functions
Validate Ecto changeset. Returns changeset or tuple in format {field, error_msg}
which can be useful for Phoenix
Functions
Specs
validate_iban(map, bitstring) ::
map |
{:error, tuple}
Validate Ecto changeset. Returns changeset or tuple in format {field, error_msg}
which can be useful for Phoenix.
Examples
defmodule User do
use Ecto.Schema
use Ecto.Model
schema "users" do
field :email, :string
field :iban, :string
end
def changeset(user, params \\ :empty) do
user
|> cast(params, ~w(iban email), ~w())
|> ExIban.EctoValidator.validate_iban(:iban)
end
end