pylon / spect

Type specification extensions for Elixir
21 stars 3 forks source link

Date strings are not converted to Date.t() automatically #17

Open 23Skidoo opened 2 years ago

23Skidoo commented 2 years ago

Current behaviour:

> ~D[2021-01-01] |> Jason.encode! |> Spect.to_spec!(Date)
** (Spect.ConvertError) expected: map, found: "\"2021-01-01\""
    (spect 0.4.1) lib/spect.ex:443: Spect.to_map!/4

Would be nice if it tried to convert the date string to a Date.t() instead of failing immediately.

23Skidoo commented 2 years ago

The existing support for DateTime.t() doesn't work for literals either - only nested data, but doing the same for Date.t() would be enough for my use case.