Closed solnic closed 1 year ago
This adds support for defining a value that can have multiple types. You can also specify any extra constraints that should be applied:
defmodule TestContract do use Drops.Contract schema do %{required(:test) => type([:integer, {:string, [:filled?]}])} end end TestContract.conform(%{test: 312}) # {:ok, %{test: 312}} TestContract.conform(%{test: "Hello"}) # {:ok, %{test: "Hello"}} TestContract.conform(%{test: :invalid}) # {:error, [error: {:string?, [:test], :invalid}]} TestContract.conform(%{test: :invalid}) # {:error, [error: {:filled?, [:test], ""}]}
Closes #17
This adds support for defining a value that can have multiple types. You can also specify any extra constraints that should be applied:
Closes #17