EctoCommons
Ecto common helpers such as validators and formatters.
Installation
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.1.0"}
]
end
Documentation is published on HexDocs and can be found at https://hexdocs.pm/ecto_commons.
Summary
The package contains common ecto helpers:
Changeset validators
EctoCommon.DateValidator:validate_date(changeset, field, opts): validates an equality (with approximation), before or after a given date.
EctoCommon.DateTimeValidatorvalidate_datetime(changeset, field, opts): validates an equality (with approximation), before or after a given date time.
EctoCommon.TimeValidatorvalidate_time(changeset, field, opts): validates an equality (with approximation), before or after a given time.
EctoCommon.EmailValidatorvalidate_email(changeset, field, opts): validates if an email is valid and if it uses a temporary inbox provider (exclude temporary emails)
EctoCommon.URLValidatorvalidate_url(changeset, field, opts): validates if an URL is corrent. Multiple checks can be added from looser validation to stricter.
EctoCommon.StringValidatorvalidate_has_prefix(changeset, field, opts): validates if a string starts with a given prefix. The prefix itself can depend on another field or on a dynamic value.
EctoCommon.PostalCodeValidatorvalidate_postal_code(changeset, field, opts): validates postal code depending on the country. This still needs improvement to support more countries.
EctoCommon.SocialSecurityValidatorvalidate_social_security(changeset, field, opts): validates social security numbers (SSN) depending on the country. This only validates french SSNs for now.
EctoCommon.LuhnValidatorvalidate_luhn(changeset, field, opts): validates a string with Luhn's algorithm such as credit card numbers and other administrative codes.
Changelog
ecto_commons follows semantic versioning. See CHANGELOG.md for more information.
License
MIT. Please see LICENSE for licensing details.