stoeffel/elm-verify/1.0.0

NOTE: this package is not compatible with Elm 0.19.1

Verify.String

Functions to verify properties of a String.

notBlank : error -> Validator error String String

Fails if a String is blank (empty or only whitespace).

notBlank "error" ""
--> Err [ "error" ]
minLength : Int -> error -> Validator error String String

Fails if a String is smaller than a given minimum.

minLength 3 "error" "ab"
--> Err [ "error" ]


minLength 3 "error" "abc"
--> Ok "abc"
maxLength : Int -> error -> Validator error String String

Fails if a String is smaller than a given maximum.

maxLength 3 "error" "abc"
--> Ok "abc"


maxLength 3 "error" "abcd"
--> Err [ "error" ]
isInt : error -> Validator error String Int

Fails if a String is not an Int. It will return the Int in the result.

isInt "error" "a"
--> Err [ "error" ]


isInt "error" "42"
--> Ok 42