maca/form-toolkit/1.0.0

NOTE: the latest version is 2.0.0

FormToolkit.Value

Value is used to set default input values of type either string, integer, float, boolean, date, month, time, or json.

Init

type Value
= Value Value
string : String -> Value
int : Int -> Value
float : Float -> Value
bool : Bool -> Value
date : Posix -> Value
month : Posix -> Value
time : Posix -> Value

Convert

toString : Value -> Maybe String

All values except for blank have a string representation.

toString (string "Hello") == Just "Hello"


toString (int 42) == Just "42"


toString blank == Nothing
toBool : Value -> Maybe Bool

Convert boolean values to Bool.

toBool (bool True) == Just True


toBool (string "True") == Nothing
toFloat : Value -> Maybe Float

Convert float values to Float.

toFloat (float 3.14) == Just 3.14


toFloat (string "3.14") == Nothing
toInt : Value -> Maybe Int

Convert int values to Int.

toInt (int 42) == Just 42


toInt (string "42") == Nothing
toPosix : Value -> Maybe Posix

Convert posix values to Posix.

toPosix (time (Time.millisToPosix 0))
    == Just (Time.millisToPosix 0)


toPosix blank == Nothing