Generalize and reuse Zoi types
mainSince Zoi types are just functions, you can create reusable type definitions by wrapping them in standard Elixir modules. This allows you to maintain a single source of truth for common fields (like user info or currency codes) across multiple schemas.
defmodule MyApp.ZoiTypes do
def user_info() do
Zoi.map(%{
name: Zoi.string(description: "user full name"),
email: Zoi.email(description: "user email address")
})
end
end
# Reuse in another schema
schema = Zoi.map(%{
user: MyApp.ZoiTypes.user_info()
})