xBacon v0.1.0 XBacon.Changeset.Email

Defines a set of validations that can be applied on a changeset using the XBacon.Matchers.Email matchers.

Summary

Functions

Validates the given changeset looking for the email field, it allows customization of lookup field and error messages

Functions

validate_email(changeset, field \\ :email, opts \\ [])

Validates the given changeset looking for the email field, it allows customization of lookup field and error messages.

Example

struct
|> cast(params, @fields)
|> validate_email

It will look up for a field named :email to acquire the value, if you do not use this name on field you can customize as second arity. To use a customized error message, you can pass a keyword list with message key set.

Example

 struct
 |> cast(params, @fields)
 |> validate_email(:user_email, message: "Your email is not valid.")