absinthe_error_payload icon indicating copy to clipboard operation
absinthe_error_payload copied to clipboard

Ranges are not handled

Open tonnenpinguin opened this issue 5 years ago • 1 comments

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

tonnenpinguin avatar May 14 '20 08:05 tonnenpinguin

We're having the exact same problem. We're also happy to open a PR to solve it! :D

ren90 avatar Jan 14 '25 10:01 ren90