8000 GitHub - alissonfpmorais/elm-guards: elm library to help in form validation
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

alissonfpmorais/elm-guards

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

elm-guards

Usage

To create a new guard, pass the data to validate and a list of contraints:

guard : Guard String Float
guard =
  Guard.new
    4.5
    [ Guard.constraint "Number is not positive" Rule.positive
    , Guard.constraint "Number different from 5" (Rule.equal 5)
    ]

Validate and get a list of errors, use:

validate : Guard String Float -> Guard String Float
validate guard =
  guard
    |> Guard.validate
    |> Guard.listErrors

-- ["Number different from 5"] : List String

What about update the input value?

update : Float -> Guard String Float -> Guard String Float
update number guard =
  guard
    |> <
55D5
span class="pl-c1">Guard.updateInput number

About

elm library to help in form validation

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

0