Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ericgj/elm-validation
Tools for managing validity and error state of data, e.g. from user input.
https://github.com/ericgj/elm-validation
Last synced: about 2 months ago
JSON representation
Tools for managing validity and error state of data, e.g. from user input.
- Host: GitHub
- URL: https://github.com/ericgj/elm-validation
- Owner: ericgj
- License: mit
- Created: 2017-02-07T04:32:58.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-12-03T00:38:15.000Z (about 6 years ago)
- Last Synced: 2023-08-08T20:39:16.071Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 87.9 KB
- Stars: 7
- Watchers: 2
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# elm-validation
Tools for managing validity and error state of data, e.g. from user input.
## To install
```
$ elm install ericgj/elm-validation
```## Example
Basic usage for validation in an HTML form.
view : Form -> Html Msg
view form =
div []
[ input
[ type_ "text"
, value
(form.input
|> Validation.toString identity
)
, onInput
(Validation.validate isRequired
>> SetInput
)
]
[]
, div
[ class "error" ]
[ text
(Validation.message form.input
|> Maybe.withDefault ""
)
]
]Combining validation of form fields to determine overall validity of a model.
(For example, this could be used to determine if the submit button should be
enabled on the form.)validateForm : Form -> ValidationResult Model
validateForm form =
Validation.valid Model
|> Validation.andMap form.field1
|> Validation.andMap form.field2[See the Elm package for full usage docs][pkg].
[pkg]: http://package.elm-lang.org/packages/ericgj/elm-validation/latest