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

[BUG] Transforms don't run on nested schemas #12

Closed
nickdichev-firework opened this issue Nov 20, 2024 · 0 comments · Fixed by #15
Closed

[BUG] Transforms don't run on nested schemas #12

nickdichev-firework opened this issue Nov 20, 2024 · 0 comments · Fixed by #15
Assignees
Labels
bug Something isn't working

Comments

@nickdichev-firework
Copy link

Describe the bug
Transforms do not run on fields if their type is a schema but they do run if the type is :map.

To Reproduce

fun = fn _value -> raise("boom") end

nested_schema = %{
  foo: :string
}

parent_schema = %{
  bar: {nested_schema, {:transform, fun}}
}

map_schema = %{
  bar: {:map, {:transform, fun}}
}

Peri.validate(parent_schema, %{bar: %{foo: "hello"}})
{:ok, %{bar: %{foo: "hello"}}}

Peri.validate(map_schema, %{bar: %{foo: "hello"}})
** (RuntimeError) boom

Expected behavior
Transform runs on the validated schema field

Environment
• Elixir version: 1.16.3
• Peri version: 0.2.11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants