for more information visit the package's GitHub page
Package contains the following modules:
Provide a validator for elm.
elm install pastelInc/elm-validator
Export two functions and one type.
Rule
is validation rule.rule
return Rule
.validate
return Result (List error) subject
that is validated subject
.import Validator exposing (Rule, rule, validate)
ageValidator : Rule String { age : Int }
ageValidator =
rule
{ field = .age
, method = (>) 18
, validWhen = True
, error = "Age must be greater than 18."
}
isValidAge : { age : Int } -> Bool
isValidAge model =
case validate [ ageValidator ] model of
Ok _ ->
True
Err _ ->
False
ageErrors : { age : Int } -> List String
ageErrors model =
case validate [ ageValidator ] model of
Ok _ ->
[]
Err es ->
es
npm install -g elm-test@0.19.0-beta4
elm-test
git checkout -b my-new-feature
git commit -am 'Add some feature'
git push origin my-new-feature
MIT