NoRedInk/elm-rails/4.0.4

NOTE: this package is not compatible with Elm 0.19.1

Rails.Decode

Types

type alias ErrorList field =
List ( field, String )

ErrorList is a type alias for a list of fields to String, where field is expected to be a type for matching errors to


type Field = Name | Password

decode : ErrorList Field

Decoding

errors : Dict String field -> Decoder (ErrorList field)

Decodes errors passed from rails formatted as

{ errors: {errorName: ["Error String"] } }.

This function takes a Dict that is a map of all the fields you need decoded. It should be formatted nest

Dict.fromList
    [ ( "school", School )
    , ( "school.name", SchoolName )
    , ( "school.address", SchoolAddress )
    , ( "school.city", City )
    , ( "school.state", State )
    , ( "school.zip", Zip )
    , ( "school.country", Country )
    ]