Skip to content

Commit

Permalink
Accept other options for Booleans values
Browse files Browse the repository at this point in the history
Hello,
We noticed (incorrect  but  ) booleans values in JSON returned were failing.
With this change this JSON would accepted:
{
    "testBool": "True",
    "testBool2": "False",
    "testBool3": "T",
    "testBool4": "F",
    "testBool5": "NO",
    "testBool6": "YES"
}
  • Loading branch information
frranck authored Sep 6, 2016
1 parent 43c38d1 commit 0736303
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Sources/Unbox.swift
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,12 @@ extension Bool: UnboxableRawType {
}

public static func transformUnboxedString(unboxedString: String) -> Bool? {
for element in [ "true", "t" , "y", "yes" ] where element.uppercased() == unboxedString.uppercased() {
return true
}
for element in [ "false", "f" , "n", "no" ] where element.uppercased() == unboxedString.uppercased() {
return false
}
return nil
}
}
Expand Down

0 comments on commit 0736303

Please sign in to comment.