Skip to content

Ranges are not handled #16

@tonnenpinguin

Description

@tonnenpinguin

Hi guys,

I ran into an issue with elixirs Range not being handled properly.

This snippet from my changeset

    |> validate_inclusion(:value, 6..20)

produces this error message when the condition is not met (shortened as it just goes on stating a ton of types)

 ** (Protocol.UndefinedError) protocol String.Chars not implemented for 6..20 of type Range (a struct). This protocol is implemented for the following type(s): Postgrex.Copy, [...], DateTime

I played around a bit and it seems like changing the interpolated_value_to_string/1 function to use inspect/1 rather than to_string fixes the issue. I'm not sure what the exact difference in behaviour is and if this might break people's code, but if you guys are interested I'm happy to open a PR for this.

I'm on 1.1.2 with elixir 1.9.4 and OTP 22 if that makes any difference

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