Ecto common validators for Date, Time, URLs, Emails, PostalCodes, Phone Numbers, Luhn checks, etc.
MIT License
Ecto common helpers such as validators and formatters.
The package is available on hex, so it can be installed
by adding ecto_commons
to your list of dependencies in mix.exs
:
def deps do
[
{:ecto_commons, "~> 0.3.4"}
]
end
In order to check whether URLs are parseable, this library requires either a recent (>= 1.13.0) of Elixir, or an older (< 26) version of OTP.
Documentation is published on HexDocs and can be found at https://hexdocs.pm/ecto_commons.
The package contains common ecto helpers:
EctoCommons.DateValidator
:
validate_date(changeset, field, opts)
: validates an equality (withEctoCommons.DateTimeValidator
validate_datetime(changeset, field, opts)
: validates an equality (withEctoCommons.TimeValidator
validate_time(changeset, field, opts)
: validates an equality (withEctoCommons.EmailValidator
validate_email(changeset, field, opts)
: validates emails. As there is noEctoCommons.URLValidator
validate_url(changeset, field, opts)
: validates if an URL is correct. HereEctoCommons.StringValidator
validate_has_prefix(changeset, field, opts)
: validates if a string startsEctoCommons.PostalCodeValidator
validate_postal_code(changeset, field, opts)
: validates postal code formattingEctoCommons.SocialSecurityValidator
validate_social_security(changeset, field, opts)
: validates social securityEctoCommons.LuhnValidator
validate_luhn(changeset, field, opts)
: validates a string with Luhn'sEctoCommons.PhoneNumberValidator
validate_phone_number(changeset, field, opts)
: validates a phone numberEctoCommons.Helpers
validate_many(changeset, field, opts)
: validates multiple fields with the sameecto_commons
follows semantic versioning. See CHANGELOG.md
for more information.
Use Earthly to run tests against various versions of Elixir and Erlang.
earthly +all
MIT. Please see LICENSE for licensing details.