Skip to content

Zoi + Ecto and Changesets #158

Description

@phcurado

Following the discussion on Elixir Forum, we should have a way to create Zoi schemas and generate different outputs such as ecto embedded schemas. Ecto will be an optional library, and if the project have it, Zoi will offer functions that will help integrating ecto schemas (for now embeds) with zoi plain schemas.

So far the API design agreed was:

defmodule Project.Inputs.OnboardUser do
   require Zoi.Ecto

  @schema Zoi.map(%{email: Zoi.email()})

  # Macro that will create the embedded in this module
  Zoi.Ecto.generate_embedded_schema(@schema)

  def schema, do: @schema
end

Zoi should also provide a way to integrate with changesets. For now we agreed to convert zoi parsed results (or errors) into a changeset container but the API will be later defined

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions