Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dockyard/valid_field
https://github.com/dockyard/valid_field
elixir testing
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/dockyard/valid_field
- Owner: DockYard
- License: mit
- Created: 2015-10-26T00:18:01.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2019-07-10T07:07:04.000Z (over 5 years ago)
- Last Synced: 2024-11-09T09:15:54.815Z (2 months ago)
- Topics: elixir, testing
- Language: Elixir
- Homepage: https://hex.pm/packages/valid_field
- Size: 43.9 KB
- Stars: 48
- Watchers: 3
- Forks: 6
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# ValidField [![Build Status](https://travis-ci.org/DockYard/valid_field.svg?branch=master)](https://travis-ci.org/DockYard/valid_field) [![Inline docs](http://inch-ci.org/github/dockyard/valid_field.svg?branch=master)](http://inch-ci.org/github/dockyard/valid_field)
**[ValidField is built and maintained by DockYard, contact us for expert Elixir and Phoenix consulting](https://dockyard.com/phoenix-consulting)**.
ValidField allows you to unit test changesets
## Usage
Add valid_field to your list of dependencies in `mix.exs`:
```elixir
def deps do
[{:valid_field, "~> 0.6.0", only: :test}]
end
```Then in your unit test:
```elixir
defmodule App.UserTest do
import ValidField
alias App.Usertest ".changeset - Validations" do
with_changeset(%User{})
|> assert_valid_field(:email, ["[email protected]"])
|> assert_invalid_field(:email, ["", nil, "test"])
|> assert_valid_field(:password, ["password123!"])
|> assert_invalid_field(:password, [nil, "", "test", "nospecialcharacters1", "nonumber!"])
end
end
```Alternatively you can combine the `assert_valid_field/3` and
`assert_invalid_field/3` syntax into `assert_field/4`. Refactoring the
same example above using `assert_field/4` would yield:```elixir
defmodule App.UserTest do
import ValidField
alias App.Usertest ".changeset - Validations" do
with_changeset(%User{})
|> assert_field(:email, ["[email protected]"], ["", nil, "test"])
|> assert_field(:password, ["password123!"], [nil, "", "test", "nospecialcharacters1", "nonumber!"])
end
end
```## Authors
* [Dan McClain](http://twitter.com/_danmcclain)
* [Brian Cardarella](http://twitter.com/bcardarella)[We are very thankful for the many contributors](https://github.com/DockYard/valid_field/graphs/contributors)
## Versioning
This library follows [Semantic Versioning](http://semver.org)
## Want to help?
Please do! We are always looking to improve this library. Please see our
[Contribution Guidelines](https://github.com/DockYard/valid_field/blob/master/CONTRIBUTING.md)
on how to properly submit issues and pull requests.## Legal
[DockYard](http://dockyard.com/), Inc. © 2016
[@dockyard](http://twitter.com/DockYard)
[Licensed under the MIT license](http://www.opensource.org/licenses/mit-license.php)