Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add supports for Phoenix.Ecto changeset errors #35

Open
Matsa59 opened this issue Jun 4, 2021 · 0 comments
Open

Add supports for Phoenix.Ecto changeset errors #35

Matsa59 opened this issue Jun 4, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@Matsa59
Copy link
Member

Matsa59 commented Jun 4, 2021

Imagine we add a mark that doesn't exist, an invalid changeset will be returned.

We have to transform thoses changeset to inline it and allow user to display error using

<%= error_tag f, :field %>

Example of invalid changeset

#Ecto.Changeset<
  action: nil,
  changes: %{
    title: #Ecto.Changeset<
      action: :insert,
      changes: %{
        content: #Ecto.Changeset<
          action: :insert,
          changes: %{
            content: [
              #Ecto.Changeset<
                action: :insert,
                changes: %{
                  content: [
                    #Ecto.Changeset<
                      action: :insert,
                      changes: %{text: "Hello world"},
                      errors: [marks: {"is invalid", []}],
                      data: #ExProsemirror.Block.Text<>,
                      valid?: false
                    >
                  ]
                },
                errors: [],
                data: #ExProsemirror.Block.Paragraph<>,
                valid?: false
              >
            ]
          },
          errors: [],
          data: #ExProsemirror.Block.Doc<>,
          valid?: false
        >
      },
      errors: [],
      data: #ExProsemirror.Schema<>,
      valid?: false
    >,
    title_plain: "{\"type\":\"doc\",\"content\":[{\"type\":\"p\",\"content\":[{\"type\":\"text\",\"marks\":[{\"type\":\"em\"},{\"type\":\"strong\"},{\"type\":\"underline\"}],\"text\":\"Hello world\"}]}]}"
  },
  errors: [],
  data: #ExProsemirrorSample.Article<>,
  valid?: false
>
@Matsa59 Matsa59 added the enhancement New feature or request label Jun 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant