NoRedInk/elm-rails/1.1.0

NOTE: this package is not compatible with Elm 0.19.1

Rails.Decode

Decoding

errors : Dict String field -> Decoder (List ( field, String ))

Function for creating a Decoder that decodes errors formatted by rails. It is expecting JSON formatted as:

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

To create the decoder, pass a dict mapping your Strings to Fields that mimic the expected nesting, eg.

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

railsErrorsDecoder =
    Rails.Decode.errors mappings