Git Product home page Git Product logo

ecto_commons's Introduction

EctoCommons

Build Status Coverage Status Hex Version License

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.DateTimeValidator
    • validate_datetime(changeset, field, opts): validates an equality (with approximation), before or after a given date time.
  • EctoCommon.TimeValidator
    • validate_time(changeset, field, opts): validates an equality (with approximation), before or after a given time.
  • EctoCommon.EmailValidator
    • validate_email(changeset, field, opts): validates emails. As there is no perfect validation possible, multiple options are available depending on your requirements. Can also reject temporary/burner emails.
  • EctoCommon.URLValidator
    • validate_url(changeset, field, opts): validates if an URL is correct. Here too, there is no perfection possible. Multiple options are available depending on the precision required.
  • EctoCommon.StringValidator
    • validate_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.PostalCodeValidator
    • validate_postal_code(changeset, field, opts): validates postal code formatting using regular expressions depending on the country. This only ensures the postal code "looks ok" but doesn't check it really exists (that will need a complete database of all postal codes worldwide).
  • EctoCommon.SocialSecurityValidator
    • validate_social_security(changeset, field, opts): validates social security numbers (SSN) depending on the country. This only validates french SSNs for now.
  • EctoCommon.LuhnValidator
    • validate_luhn(changeset, field, opts): validates a string with Luhn's algorithm such as credit card numbers and other administrative codes.

Changeset helpers

  • EctoCommon.Helpers
    • validate_many(changeset, field, opts): validates multiple fields with the same validation function as well as the same options.

Changelog

ecto_commons follows semantic versioning. See CHANGELOG.md for more information.

License

MIT. Please see LICENSE for licensing details.

ecto_commons's People

Contributors

achedeuzot avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.