Skip to content

Conversation

@mbuhot
Copy link
Collaborator

@mbuhot mbuhot commented Apr 20, 2019

Resolves #60

Main changes in this PR are:

  • Supports casting a simple string to an atom in enum list
  • Supports casting a string-keyed map to atom keyed map in enum list
  • Add tests for casting string keyed map to schema struct in enum list (was already supported by existing code)

Casting from a string keyed map to a struct enum without an explicit object schema is disallowed - if a struct is required, then a schema should be defined.

@mbuhot mbuhot requested a review from fenollp April 20, 2019 11:31

assert Error.message_with_path(error2) == "#/3: Invalid integer. Got: string"
end

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests moved into the new test/cast/enum_test.exs file

@mbuhot mbuhot changed the title Convert string to atom when casting enum containing atoms Convert string to atom when casting enum schema Apr 21, 2019
Copy link
Contributor

@moxley moxley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice @mbuhot!

Copy link
Contributor

@fenollp fenollp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Enum.find a value in the Schema.enum that satisfies equivalent?
@mbuhot mbuhot merged commit 08e76b4 into master Apr 28, 2019
@mbuhot mbuhot deleted the feature/atomify-enum-on-cast branch April 28, 2019 06:15
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.

cast does not "atomify" keys in maps of enum payloads

4 participants