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 support for mapping booleans #64

Merged
merged 4 commits into from
May 11, 2017
Merged

Conversation

zenangst
Copy link
Owner

Add method for mapping boolean value from a Dictionary.

Add method for mapping boolean value from a Dictionary.
return nil
}

if let string = self[key] as? String {
Copy link
Collaborator

Choose a reason for hiding this comment

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

There 's another case of "1", "0"

Copy link
Owner Author

Choose a reason for hiding this comment

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

Yeah we could add that :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Blame the backend 😄

Copy link
Owner Author

Choose a reason for hiding this comment

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

assertFailure("Contact your backend devs because something is clearly not correct here.")

Consider "true" and "1" to be equal to true and "false", "0" to be
false when mapping booleans.

Otherwise return nil.
return true
} else if ["false", "0"].contains(string.lowercased()) {
return false
}
Copy link
Owner Author

Choose a reason for hiding this comment

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

@onmyway133 what do you think about this?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it is good 👍

@zenangst zenangst merged commit af2c52b into master May 11, 2017
@zenangst zenangst deleted the feature/boolean-mapping branch May 11, 2017 12:11
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.

2 participants