Closed solnic closed 1 year ago
This adds atomize: true | false option to schema DSL which can be used to have string-based maps turned into atom-based maps:
atomize: true | false
schema
defmodule TestContract do use Drops.Contract schema(atomize: true) do %{ required(:user) => %{ required(:name) => type(:string, [:filled?]), required(:age) => type(:integer), required(:address) => %{ required(:city) => type(:string, [:filled?]), required(:street) => type(:string, [:filled?]), required(:zipcode) => type(:string, [:filled?]) } } } end end TestContract.conform(%{ "user" => %{ "name" => "John", "age" => 21, "address" => %{ "city" => "New York", "street" => "Central Park", "zipcode" => "10001" } } }) # {:ok, # %{ # user: %{ # name: "John", # address: %{city: "New York", street: "Central Park", zipcode: "10001"}, # age: 21 # } # }}
This adds
atomize: true | false
option toschema
DSL which can be used to have string-based maps turned into atom-based maps: