Skip to content

Commit e1d35cb

Browse files
committed
Types/AnyValue: support extracting as bool and add many more tests
1 parent c45e17f commit e1d35cb

File tree

2 files changed

+495
-0
lines changed

2 files changed

+495
-0
lines changed

Sources/CornucopiaCore/Types/AnyValue.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ public extension Cornucopia.Core {
6363
case is String.Type:
6464
guard case let .string(string) = self else { throw Error.typeMismatch(info: "Expected \(T.self), got \(self) instead") }
6565
return string as! T
66+
case is Bool.Type:
67+
guard case let .bool(bool) = self else { throw Error.typeMismatch(info: "Expected \(T.self), got \(self) instead") }
68+
return bool as! T
6669
case is Int.Type:
6770
guard case let .int(int) = self else { throw Error.typeMismatch(info: "Expected \(T.self), got \(self) instead") }
6871
return int as! T

0 commit comments

Comments
 (0)