Skip to content

Return index of undecodable element in dynamic.list DecodeError path #627

@johtso

Description

@johtso

pub fn list(
of decoder_type: fn(Dynamic) -> Result(inner, DecodeErrors),
) -> Decoder(List(inner)) {
fn(dynamic) {
use list <- result.try(shallow_list(dynamic))
list
|> list.try_map(decoder_type)
|> map_errors(push_path(_, "*"))
}
}

I think it would be nice to return the index of the offending element instead of just "*"

I'm new to gleam, but I had a little play around trying to implement this and could open a pull request..

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions