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

pass empty map, when embed is empty #18

Conversation

antonovga
Copy link

No description provided.

@coveralls
Copy link

coveralls commented Jul 19, 2022

Pull Request Test Coverage Report for Build a8bdbf495c9a87ebc4f8f3a126ff734ad203db6c-PR-18

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 2 of 2 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.1%) to 90.643%

Totals Coverage Status
Change from base Build c33f7ef2c6749bf70c3719da76ba8caafb43c70f: 0.1%
Covered Lines: 155
Relevant Lines: 171

💛 - Coveralls

@bluzky
Copy link
Owner

bluzky commented Jul 19, 2022

Hi @antonovga,
Thank you for your PR but I think this change will break current code, current behaviour, return nil by default but in this PR return empty map.
To handle your use case, you can use this

schema = %{
  user: [type: %{
     email: [type: :string, required: true]
  }, default: %{}]
}

@bluzky
Copy link
Owner

bluzky commented Jul 19, 2022

I'm gonna close this PR.

@bluzky bluzky closed this Jul 19, 2022
@antonovga
Copy link
Author

This PR addresses two problems with nested params:

  1. When you pass bad formed params, it fails to parse it and throws 500 error

  2. When you have schema with required nested field and don't pass nested fields at all, it validates params and returns valid: true

If this is intended behavior, you should definitely write this in documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants