Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misc doc changes #67

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 26 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,29 @@
/ebin
/deps
/doc
# The directory Mix will write compiled artifacts to.
/_build/

# If you run "mix test --cover", coverage assets end up here.
/cover/

# The directory Mix downloads your dependencies sources to.
/deps/

# Where third-party dependencies like ExDoc output generated docs.
/doc/

# Ignore .fetch files in case you like to edit your project deps locally.
/.fetch

# If the VM crashes, it generates a dump, let's ignore it too.
erl_crash.dump

# Also ignore archive artifacts (built via "mix archive.build").
*.ez

# Ignore package tarball (built via "mix hex.build").
vex-*.tar

# Temporary files for e.g. tests.
/tmp/

# Misc.
*.swp
_build
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) Bruce Williams
Copyright (c) 2013 CargoSense, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
39 changes: 32 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Vex

[![Build Status](https://travis-ci.org/CargoSense/vex.svg)](https://travis-ci.org/CargoSense/vex)
[![Module Version](https://img.shields.io/hexpm/v/vex.svg)](https://hex.pm/packages/vex)
[![Hex Docs](https://img.shields.io/badge/hex-docs-lightgreen.svg)](https://hexdocs.pm/vex/)
[![Total Download](https://img.shields.io/hexpm/dt/vex.svg)](https://hex.pm/packages/vex)
[![License](https://img.shields.io/hexpm/l/vex.svg)](https://github.com/CargoSense/vex/blob/master/LICENSE)
[![Last Updated](https://img.shields.io/github/last-commit/CargoSense/vex.svg)](https://github.com/CargoSense/vex/commits/master)


An extensible data validation library for Elixir.

Expand Down Expand Up @@ -135,7 +141,7 @@ Ensure a value is a number is within a given range:
Vex.valid? value, number: [greater_than_or_equal_to: 0, less_than: 10]
```

This validation can be skipped for `nil` or blank values by including
This validation can be skipped for `nil` or blank values by including
`allow_nil: true` or `allow_blank: true` respectively in the options.

See the documentation on `Vex.Validators.Number` for details
Expand All @@ -155,7 +161,7 @@ Ensure a value is a valid UUID string in a given format:
Vex.valid? value, uuid: [format: :hex]
```

This validation can be skipped for `nil` or blank values by including
This validation can be skipped for `nil` or blank values by including
`allow_nil: true` or `allow_blank: true` respectively in the options.

See the documentation on `Vex.Validators.Uuid` for details
Expand All @@ -164,7 +170,7 @@ on available options.
### Acceptance

Ensure an attribute is set to a positive (or custom) value. For use
expecially with "acceptance of terms" checkboxes in web applications.
especially with "acceptance of terms" checkboxes in web applications.

```elixir
Vex.valid?(user, accepts_terms: [acceptance: true])
Expand Down Expand Up @@ -234,7 +240,7 @@ See the documentation on `Vex.Validators.By` for details on available options.
Validation Conditions
---------------------

A validation can be made applicable (or unapplicable) by using the `:if`,
A validation can be made applicable (or inapplicable) by using the `:if`,
`:if_any`, `:unless` and `:unless_any` options.

Note `Vex.results` will return tuples with `:not_applicable` for validations that
Expand Down Expand Up @@ -595,7 +601,26 @@ Report bugs and request features via [Issues](https://github.com/CargoSense/vex/
kudos if you do it from pull requests you submit that fix the bugs or add
the features. ;)

License
-------
## Copyright and License

The MIT License (MIT)

Copyright (c) 2013 CargoSense, Inc.

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.

Released under the [MIT License](http://www.opensource.org/licenses/MIT).
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.
1 change: 0 additions & 1 deletion lib/vex/error_renderer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ defmodule Vex.ErrorRenderer do

Result of `message` function appears in `Vex.errors` error tuple as last element, for those
validators who use `Vex.Validator.ErrorMessage` (in general they should).
```
"""

@callback message(validator_options :: list(), default_message :: String.t(), context :: list()) ::
Expand Down
3 changes: 2 additions & 1 deletion lib/vex/validator.ex
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ defmodule Vex.Validator do
end

@doc """
Determine if a validation should be executed based on any conditions provided
Determine if a validation should be executed based on any conditions provided.

## Examples

Expand Down Expand Up @@ -69,6 +69,7 @@ defmodule Vex.Validator do
false
iex> Vex.Validator.validate?([name: "foo", state: "persisted"], unless_any: [name: "bar", state: "new"])
true

"""
def validate?(data, options) when is_list(options) do
cond do
Expand Down
2 changes: 1 addition & 1 deletion lib/vex/validator/skipping.ex
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ defmodule Vex.Validator.Skipping do
end

@doc """
If a validation can be skipped, basoed on the value and options given.
If a validation can be skipped, based on the value and options given.

## Examples

Expand Down
2 changes: 1 addition & 1 deletion lib/vex/validators/number.ex
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ defmodule Vex.Validators.Number do
* `:message`: A custom error message. May be in EEx format and use the fields described
in [Custom Error Messages](#module-custom-error-messages).
* `:allow_nil`: A boolean whether to skip this validation for `nil` values.
* `:allow_blank`: A boolean whether to skip this validaton for blank values.
* `:allow_blank`: A boolean whether to skip this validation for blank values.

The `:is` option can be provided in place of the keyword list if no other options are set.
When multiple options are than the validator will do an `and` logic between them.
Expand Down
12 changes: 6 additions & 6 deletions lib/vex/validators/uuid.ex
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ defmodule Vex.Validators.Uuid do
* `:message`: A custom error message. May be in EEx format
and use the fields described in [Custom Error Messages](#module-custom-error-messages).
* `:allow_nil`: A boolean whether to skip this validation for `nil` values.
* `:allow_blank`: A boolean whether to skip this validaton for blank values.
* `:allow_blank`: A boolean whether to skip this validation for blank values.

The value for `:format` can be provided instead of the options keyword list.
Additionally, if the options is a boolean value, then:
Expand All @@ -31,7 +31,7 @@ defmodule Vex.Validators.Uuid do

## Examples

Examples when using the `:any` or `true` options:
When using the `:any` or `true` options:

iex> Vex.Validators.Uuid.validate("02aa7f48-3ccd-11e4-b63e-14109ff1a304", format: :any)
:ok
Expand All @@ -43,7 +43,7 @@ defmodule Vex.Validators.Uuid do
iex> Vex.Validators.Uuid.validate("02aa7f48-3ccd-11e4-b63e-14109ff1a30", true)
{:error, "must be a valid UUID string"}

Examples when using the `:not_any` or `false` options:
When using the `:not_any` or `false` options:

iex> Vex.Validators.Uuid.validate("not_a_uuid", format: :not_any)
:ok
Expand All @@ -55,21 +55,21 @@ defmodule Vex.Validators.Uuid do
iex> Vex.Validators.Uuid.validate("02aa7f48-3ccd-11e4-b63e-14109ff1a304", false)
{:error, "must not be a valid UUID string"}

Examples when using the `:default` option:
When using the `:default` option:

iex> Vex.Validators.Uuid.validate("02aa7f48-3ccd-11e4-b63e-14109ff1a304", format: :default)
:ok
iex> Vex.Validators.Uuid.validate("02aa7f483ccd11e4b63e14109ff1a304", format: :default)
{:error, "must be a valid UUID string in default format"}

Examples when using the `:hex` option:
When using the `:hex` option:

iex> Vex.Validators.Uuid.validate("02aa7f483ccd11e4b63e14109ff1a304", format: :hex)
:ok
iex> Vex.Validators.Uuid.validate("urn:uuid:02aa7f48-3ccd-11e4-b63e-14109ff1a304", format: :hex)
{:error, "must be a valid UUID string in hex format"}

Examples when using the `:urn` option:
When using the `:urn` option:

iex> Vex.Validators.Uuid.validate("urn:uuid:02aa7f48-3ccd-11e4-b63e-14109ff1a304", format: :urn)
:ok
Expand Down
35 changes: 24 additions & 11 deletions mix.exs
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
defmodule Vex.Mixfile do
use Mix.Project

@source_url "https://github.com/CargoSense/vex"
@version "0.8.0"

def project do
[
app: :vex,
version: "0.8.0",
elixir: "~> 1.6",
deps: deps(),
name: "Vex",
consolidate_protocols: Mix.env() != :test,
deps: deps(),
package: package(),

# Docs
name: "Vex",
source_url: "https://github.com/CargoSense/vex",
homepage_url: "https://github.com/CargoSense/vex",
docs: [main: "readme", extras: ["README.md"]]
docs: docs()
]
end

# Configuration for the OTP application
def application do
[applications: [:eex]]
[
extra_applications: [:eex]
]
end

defp deps do
[{:ex_doc, "~> 0.19", only: :dev, runtime: false}]
[
{:ex_doc, ">= 0.0.0", only: :dev, runtime: false}
]
end

defp package do
Expand All @@ -33,7 +35,18 @@ defmodule Vex.Mixfile do
maintainers: ["Bruce Williams", "Ben Wilson", "John Hyland"],
licenses: ["MIT License"],
description: "An extensible data validation library for Elixir",
links: %{github: "https://github.com/CargoSense/vex"}
links: %{GitHub: @source_url}
]
end

defp docs do
[
extras: ["README.md"],
main: "readme",
homepage_url: "https://github.com/CargoSense/vex",
source_url: "https://github.com/CargoSense/vex",
source_ref: "v#{@version}",
formatters: ["html"]
]
end
end
7 changes: 4 additions & 3 deletions mix.lock
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
%{
"earmark": {:hex, :earmark, "1.2.4", "99b637c62a4d65a20a9fb674b8cffb8baa771c04605a80c911c4418c69b75439", [:mix], [], "hexpm", "1b34655872366414f69dd987cb121c049f76984b6ac69f52fff6d8fd64d29cfd"},
"earmark_parser": {:hex, :earmark_parser, "1.4.10", "6603d7a603b9c18d3d20db69921527f82ef09990885ed7525003c7fe7dc86c56", [:mix], [], "hexpm", "8e2d5370b732385db2c9b22215c3f59c84ac7dda7ed7e544d7c459496ae519c0"},
"ex_doc": {:hex, :ex_doc, "0.23.0", "a069bc9b0bf8efe323ecde8c0d62afc13d308b1fa3d228b65bca5cf8703a529d", [:mix], [{:earmark_parser, "~> 1.4.0", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm", "f5e2c4702468b2fd11b10d39416ddadd2fcdd173ba2a0285ebd92c39827a5a16"},
"earmark_parser": {:hex, :earmark_parser, "1.4.12", "b245e875ec0a311a342320da0551da407d9d2b65d98f7a9597ae078615af3449", [:mix], [], "hexpm", "711e2cc4d64abb7d566d43f54b78f7dc129308a63bc103fbd88550d2174b3160"},
"ex_doc": {:hex, :ex_doc, "0.24.1", "15673de99154f93ca7f05900e4e4155ced1ee0cd34e0caeee567900a616871a4", [:mix], [{:earmark_parser, "~> 1.4.0", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "07972f17bdf7dc7b5bd76ec97b556b26178ed3f056e7ec9288eb7cea7f91cce2"},
"makeup": {:hex, :makeup, "1.0.5", "d5a830bc42c9800ce07dd97fa94669dfb93d3bf5fcf6ea7a0c67b2e0e4a7f26c", [:mix], [{:nimble_parsec, "~> 0.5 or ~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "cfa158c02d3f5c0c665d0af11512fed3fba0144cf1aadee0f2ce17747fba2ca9"},
"makeup_elixir": {:hex, :makeup_elixir, "0.15.0", "98312c9f0d3730fde4049985a1105da5155bfe5c11e47bdc7406d88e01e4219b", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.1", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "75ffa34ab1056b7e24844c90bfc62aaf6f3a37a15faa76b07bc5eba27e4a8b4a"},
"makeup_elixir": {:hex, :makeup_elixir, "0.15.1", "b5888c880d17d1cc3e598f05cdb5b5a91b7b17ac4eaf5f297cb697663a1094dd", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.1", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "db68c173234b07ab2a07f645a5acdc117b9f99d69ebf521821d89690ae6c6ec8"},
"makeup_erlang": {:hex, :makeup_erlang, "0.1.1", "3fcb7f09eb9d98dc4d208f49cc955a34218fc41ff6b84df7c75b3e6e533cc65f", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "174d0809e98a4ef0b3309256cbf97101c6ec01c4ab0b23e926a9e17df2077cbb"},
"nimble_parsec": {:hex, :nimble_parsec, "1.1.0", "3a6fca1550363552e54c216debb6a9e95bd8d32348938e13de5eda962c0d7f89", [:mix], [], "hexpm", "08eb32d66b706e913ff748f11694b17981c0b04a33ef470e33e11b3d3ac8f54b"},
}