This is an alternative site for discovering Elm packages. You may be looking for the official Elm package site instead.
Elm validation library inspired by ecto changeset validations
version 2.0.0
license MIT
native-modules False
elm-version 0.18.0 <= v < 0.19.0
Tag 2.0.0
Committed At 2017-07-09 15:59:23 UTC
elm-lang/core 5.0.0 <= v < 6.0.0 5.1.1

Modules

README

elm-validate

Link to package: http://package.elm-lang.org/packages/esanmiguelc/elm-validate

Link to repository: https://github.com/esanmiguelc/elm-validate

Validation library inspired by ecto changeset validations. The idea behind this project is to be able to concatenate validations and ultimately get a ValidationResult which provides all of the errors produced by the pipeline, which can then be used in any desired manner.

The Gist:

You start by adding beginValidation which puts your Model inside a context that allows it to be piped through all of the validations.

beginValidation {password = "somepass"}
  |> validateLengthOf .password 8 "Password is too short"

Once you are done with it you can pattern match the result like so:

let
  result =
    beginValidation {email = "email@example.com", password = "somepass"}
      |> validatePresenceOf .email "Email must be present"
      |> validateLengthOf .password 8 "Password is too short"
in
  case result of
    Valid model ->
      {- do stuff with a valid model here -}
      ( model, logUserIn model )
    Err model errors ->
      {- do stuff with the errors here -}
      ( { model | errors = errors }, Cmd.none )

Contributing

After you have read the Code of conduct.

  1. Fork the repo.
  2. Write some tests.
  3. Make 'em pass
  4. Stuck? Ask a Question!
  5. Create a pull request - make sure your tests pass.
  6. Have a cup of :coffee:

Setting up

  1. Clone the repository.
$ git clone git@github.com:esanmiguelc/elm-validate.git
  1. Make sure you have npm installed.
  2. Install dependencies.
$ npm install
  1. Run the tests
$ npm run test