pylon / spect

Type specification extensions for Elixir
21 stars 3 forks source link

Spect does not complain about non-nullable struct fields missing #18

Open 23Skidoo opened 2 years ago

23Skidoo commented 2 years ago

For example, given the following struct definition:

typed_struct enforce: true do
    field :foo, String.t()
end

Spect will happily accept an empty map as valid:

> Spect.to_spec(%{}, __MODULE__)
{:ok, %__MODULE__{foo: nil}}
23Skidoo commented 2 years ago

"Extra" fields being present also don't result in an error:

> Spect.to_spec(%{bar: "baz"}, __MODULE__)
{:ok, %__MODULE__{foo: nil}}