Commit a7a0da6f authored by Karol M's avatar Karol M

Add hex metadata and stuff

parent 5cf46b5d
MIT License
Copyright (c) 2019 Karol Moroz
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
# EmailTldValidator
**TODO: Add description**
A simple email address validator for Elixir that first checks the address with a regular
expression and then checks if the Top-Level Domain of the host is included in ICANN's
[List of Top-Level Domains](https://www.icann.org/resources/pages/tlds-2012-02-25-en).
The package is meant for use with `Ecto.Changeset`.
## Installation
......@@ -15,7 +18,20 @@ def deps do
end
```
Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc)
and published on [HexDocs](https://hexdocs.pm). Once published, the docs can
be found at [https://hexdocs.pm/email_tld_validator](https://hexdocs.pm/email_tld_validator).
## Usage
The features of this library are split into two modules: `EmailTldValidator` and
`EmailTldValidator.Ecto`.
To just check if an e-mail is valid outside of an `Ecto.Changeset`, use `EmailTldValidator/1`:
```elixir
EmailTldValidator.email_valid?("[email protected]")
# => true
EmailTldValidator.email_valid?("[email protected]")
# => false (does not match the regular expression)
EmailTldValidator.email_valid?("[email protected]")
# => false (non-existent TLD)
```
......@@ -18,6 +18,10 @@ defmodule EmailTldValidator do
def tld_valid?(_), do: false
def email_valid?(email) do
regexp_validate(email) && tld_validate(email)
end
def tld_validate(email) do
email
|> String.split(".")
......
......@@ -7,7 +7,17 @@ defmodule EmailTldValidator.MixProject do
version: "0.1.0",
elixir: "~> 1.9",
start_permanent: Mix.env() == :prod,
deps: deps()
deps: deps(),
package: package(),
description: description(),
# Docs
name: "EmailTldValidator",
source_url: "https://gitlab.com/moroz2137/email_tld_validator",
docs: [
main: "readme",
extras: ["README.md"]
]
]
end
......@@ -16,10 +26,32 @@ defmodule EmailTldValidator.MixProject do
[]
end
def description do
"""
A simple email address validator for Elixir that first checks the address with a regular
expression and then checks if the Top-Level Domain of the host is included in ICANN's
List of Top-Level Domains.
The package is meant for use with `Ecto.Changeset`.
"""
end
def package do
[
maintainers: ["Karol Moroz <[email protected]>"],
licenses: ["MIT"],
links: %{
"GitLab" => "https://gitlab.com/moroz2137/email_tld_validator"
}
]
end
# Run "mix help deps" to learn about dependencies.
defp deps do
[
{:ecto, ">= 2.0.0"}
{:ecto, ">= 2.0.0"},
# Docs
{:ex_doc, "~> 0.19", only: :dev, runtime: false}
]
end
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment